def cursor_forward(self, amount): sr = self.get_win32_screen_buffer_info().dwCursorPosition # assert sr.X + amount >= 0, 'Negative cursor position: x=%r amount=%r' % (sr.X, amount) pos = COORD(max(0, sr.X + amount), sr.Y) self._winapi(windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos))
def erase_screen(self): start = COORD(0, 0) sbinfo = self.get_win32_screen_buffer_info() length = sbinfo.dwSize.X * sbinfo.dwSize.Y self.cursor_goto(row=0, column=0) self._erase(start, length)
def cursor_up(self, amount): sr = self.get_win32_screen_buffer_info().dwCursorPosition pos = COORD(sr.X, sr.Y - amount) self._winapi(windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos))
def cursor_goto(self, row=0, column=0): pos = COORD(x=column, y=row) self._winapi(windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos))
def cursor_move(self, drow=0, dcolumn=0): sr = self.get_win32_screen_buffer_info().dwCursorPosition pos = COORD(sr.X + dcolumn, sr.Y - drow) self._winapi(windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos))
def cursor_goto(self, row: int = 0, column: int = 0) -> None: pos = COORD(X=column, Y=row) self._winapi(windll.kernel32.SetConsoleCursorPosition, self.hconsole, _coord_byval(pos))