def setup_console(self): """Initializes the screen frame buffer. Swaps the current screen buffer with a brand new created back buffer where the characters can be written to the flicker-free rectangular region. """ self._console = get_std_handle(STD_OUTPUT_HANDLE) # could not get the standard # console handle, raise an exception if self._console == INVALID_HANDLE_VALUE: raise TermInitializationError() buffer_info = CONSOLE_SCREEN_BUFFER_INFO() get_console_screen_buffer_info(self._console, byref(buffer_info)) get_console_cursor_info(self._console, byref(self._cursor_info)) self._cursor_info.visible = False self._cols = buffer_info.size.x self._rows = buffer_info.size.y self._size = COORD(self._cols, self._rows) self._rect = SMALL_RECT(0, 0, self._cols - 1, self._rows - 1) self._char_buffer = (CHAR_INFO * (self._size.x * self._size.y))() self._framebuffer = create_console_screen_buffer( GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, None, CONSOLE_TEXTMODE_BUFFER, None) if self._framebuffer == INVALID_HANDLE_VALUE: raise TermInitializationError() # hide the cursor and swap # the console active screen buffer set_console_cursor_info(self._framebuffer, byref(self._cursor_info)) set_console_active_screen_buffer(self._framebuffer)
def setup_console(self): """Initializes the screen frame buffer. Swaps the current screen buffer with a brand new created back buffer where the characters can be written to the flicker-free rectangular region. """ self._console = get_std_handle(STD_OUTPUT_HANDLE) # could not get the standard # console handle, raise an exception if self._console == INVALID_HANDLE_VALUE: raise TermInitializationError() buffer_info = CONSOLE_SCREEN_BUFFER_INFO() get_console_screen_buffer_info(self._console, byref(buffer_info)) get_console_cursor_info(self._console, byref(self._cursor_info)) self._cursor_info.visible = False self._cols = buffer_info.size.x self._rows = buffer_info.size.y self._size = COORD(self._cols, self._rows) self._rect = SMALL_RECT(0, 0, self._cols - 1, self._rows - 1) self._char_buffer = (CHAR_INFO * (self._size.x * self._size.y))() self._framebuffer = create_console_screen_buffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, None, CONSOLE_TEXTMODE_BUFFER, None) if self._framebuffer == INVALID_HANDLE_VALUE: raise TermInitializationError() # hide the cursor and swap # the console active screen buffer set_console_cursor_info(self._framebuffer, byref(self._cursor_info)) set_console_active_screen_buffer(self._framebuffer)
def _show_cursor(self, visible=True): self.cursor_info.visible = visible set_console_cursor_info(self.console_handle, byref(self.cursor_info))
def _show_cursor(self, visible=True): self.cursor_info.visible = visible set_console_cursor_info(self.console_handle, byref(self.cursor_info))
def restore_console(self): if self._console: set_console_active_screen_buffer(self._console) self._cursor_info.visible = True self._term_ready = False set_console_cursor_info(self._console, byref(self._cursor_info))
def restore_console(self): if self._console: set_console_active_screen_buffer(self._console) self._cursor_info.visible = True set_console_cursor_info(self._console, byref(self._cursor_info))