@classmethod
    def wrapper(cls, func, height=200, catch_interrupt=False, arguments=None):
        if sys.platform == "win32":
            # I don't like this, but we need to track the last screen for
            # resizing commands in Windows 10.
            global _last_screen_buffer

            # Clone the standard output buffer so that we can do whatever we
            # need for the application, but restore the buffer at the end.
            # Note that we need to resize the clone to ensure that it is the
            # same size as the original in some versions of Windows.
            old_out = win32console.PyConsoleScreenBufferType(
                win32file.CreateFile("CONOUT$",
                                     GENERIC_READ | GENERIC_WRITE,
                                     FILE_SHARE_WRITE,
                                     None,
                                     OPEN_ALWAYS,
                                     0,
                                     None))
            try:
                if _last_screen_buffer is None:
                    info = old_out.GetConsoleScreenBufferInfo()
                else:
                    info = _last_screen_buffer.GetConsoleScreenBufferInfo()
            except pywintypes.error:
                info = None
            win_out = win32console.CreateConsoleScreenBuffer()
            if info:
                win_out.SetConsoleScreenBufferSize(info['Size'])
            else:
                win_out.SetStdHandle(win32console.STD_OUTPUT_HANDLE)
            win_out.SetConsoleActiveScreenBuffer()

            # Get the standard input buffer.
            win_in = win32console.PyConsoleScreenBufferType(
                win32file.CreateFile("CONIN$",
                                     GENERIC_READ | GENERIC_WRITE,
                                     FILE_SHARE_READ,
                                     None,
                                     OPEN_ALWAYS,
                                     0,
                                     None))
            win_in.SetStdHandle(STD_INPUT_HANDLE)

            # Hide the cursor.
            (size, visible) = win_out.GetConsoleCursorInfo()
            win_out.SetConsoleCursorInfo(1, 0)

            # Disable scrolling
            out_mode = win_out.GetConsoleMode()
            win_out.SetConsoleMode(
                out_mode & ~ win32console.ENABLE_WRAP_AT_EOL_OUTPUT)

            # Enable mouse input and disable ctrl-c if needed.
            in_mode = win_in.GetConsoleMode()
            new_mode = in_mode | win32console.ENABLE_MOUSE_INPUT
            if catch_interrupt:
                # Ignore ctrl-c handlers if specified.
                new_mode &= ~win32console.ENABLE_PROCESSED_INPUT
            win_in.SetConsoleMode(new_mode)

            try:
                # Create the screen and invoke the wrapped function.
                win_screen = _WindowsScreen(win_out, win_in, height)
                if arguments:
                    func(win_screen, *arguments)
                else:
                    func(win_screen)

                # Only restore the screen if we are genuinely finished - and so
                # have not raised an exception.  This stops the restore from
                # overriding any resize events.
                old_out.SetConsoleActiveScreenBuffer()
                win_out = old_out
            finally:
                # Remember the last window buffer just in case.
                _last_screen_buffer = win_out

                # Reset the original screen settings.
                win_out.SetConsoleCursorInfo(size, visible)
                win_out.SetConsoleMode(out_mode)
                win_out.SetConsoleTextAttribute(7)
                win_in.SetConsoleMode(in_mode)
        else:
            def _wrapper(win):
                cur_screen = _CursesScreen(win,
                                           height,
                                           catch_interrupt=catch_interrupt)
                if arguments:
                    func(cur_screen, *arguments)
                else:
                    func(cur_screen)

            curses.wrapper(_wrapper)
Construct a new Screen for any platform.  This will initialize and tidy
dataset/ETHPy150Open peterbrittain/asciimatics/asciimatics/screen.py/Screen.wrapper