(self, scroll_ok=True)
Check if we have crossed the screen boundaries and move as needed.
Check if we have crossed the screen boundaries and move as needed.
Check if we have crossed the screen boundaries and move as needed .
def _update_cursor_position(self, scroll_ok=True):
        """Check if we have crossed the screen boundaries and move as needed."""
        oldrow, oldcol = self.current_row, self.current_col
        if self._bottom_row_allowed:
            if self.current_row == self.mode.height:
                self.current_col = min(self.mode.width, self.current_col)
                if self.current_col < 1:
                    self.current_col += 1
                self._move_cursor(self.current_row, self.current_col)
                return self.current_col == oldcol
            else:
                # if row > height, we also end up here
                # (eg if we do INPUT on the bottom row)
                # adjust viewport if necessary
                self._bottom_row_allowed = False
        # see if we need to move to the next row
        if self.current_col > self.mode.width:
            if self.current_row < self.scroll_area.bottom or scroll_ok:
                # either we don't need to scroll, or we're allowed to
                self.current_col -= self.mode.width
                self.current_row += 1
            else:
                # we can't scroll, so we just stop at the right border
                self.current_col = self.mode.width
        # see if we need to move a row up
        elif self.current_col < 1:
            if self.current_row > self.scroll_area.top:
                self.current_col += self.mode.width
                self.current_row -= 1
            else:
                self.current_col = 1
        # see if we need to scroll
        if self.current_row > self.scroll_area.bottom:
            if scroll_ok:
                self.scroll()
            self.current_row = self.scroll_area.bottom
        elif self.current_row < self.scroll_area.top:
            self.current_row = self.scroll_area.top
        self._move_cursor(self.current_row, self.current_col)
def _update_cursor_position ( self , scroll_ok = True ) : oldrow , oldcol = self . current_row , self . current_col if self . _bottom_row_allowed : if self . current_row == self . mode . height : self . current_col = min ( self . mode . width , self . current_col ) if self . current_col < 1 : self . current_col += 1 self . _move_cursor ( self . current_row , self . current_col ) return self . current_col == oldcol else : # if row > height, we also end up here # (eg if we do INPUT on the bottom row) # adjust viewport if necessary self . _bottom_row_allowed = False # see if we need to move to the next row if self . current_col > self . mode . width : if self . current_row < self . scroll_area . bottom or scroll_ok : # either we don't need to scroll, or we're allowed to self . current_col -= self . mode . width self . current_row += 1 else : # we can't scroll, so we just stop at the right border self . current_col = self . mode . width # see if we need to move a row up elif self . current_col < 1 : if self . current_row > self . scroll_area . top : self . current_col += self . mode . width self . current_row -= 1 else : self . current_col = 1 # see if we need to scroll if self . current_row > self . scroll_area . bottom : if scroll_ok : self . scroll ( ) self . current_row = self . scroll_area . bottom elif self . current_row < self . scroll_area . top : self . current_row = self . scroll_area . top self . _move_cursor ( self . current_row , self . current_col )