self.__hide_cursor()
self.__move(0, len(self.screen) - 1)
self.__write("\n")
- self.__posxy = 0, len(self.screen)
+ self.posxy = 0, len(self.screen)
self.screen.append("")
else:
while len(self.screen) < len(screen):
self.__gone_tall = 1
self.__move = self.__move_tall
- px, py = self.__posxy
+ px, py = self.posxy
old_offset = offset = self.__offset
height = self.height
if old_offset > offset and self._ri:
self.__hide_cursor()
self.__write_code(self._cup, 0, 0)
- self.__posxy = 0, old_offset
+ self.posxy = 0, old_offset
for i in range(old_offset - offset):
self.__write_code(self._ri)
oldscr.pop(-1)
elif old_offset < offset and self._ind:
self.__hide_cursor()
self.__write_code(self._cup, self.height - 1, 0)
- self.__posxy = 0, old_offset + self.height - 1
+ self.posxy = 0, old_offset + self.height - 1
for i in range(offset - old_offset):
self.__write_code(self._ind)
oldscr.pop(0)
while y < len(oldscr):
self.__hide_cursor()
self.__move(0, y)
- self.__posxy = 0, y
+ self.posxy = 0, y
self.__write_code(self._el)
y += 1
self.event_queue.insert(Event("scroll", None))
else:
self.__move(x, y)
- self.__posxy = x, y
+ self.posxy = x, y
self.flushoutput()
def prepare(self):
self.__buffer = []
- self.__posxy = 0, 0
+ self.posxy = 0, 0
self.__gone_tall = 0
self.__move = self.__move_short
self.__offset = 0
self.__write_code(self._clear)
self.__gone_tall = 1
self.__move = self.__move_tall
- self.__posxy = 0, 0
+ self.posxy = 0, 0
self.screen = []
@property
# if we need to insert a single character right after the first detected change
if oldline[x_pos:] == newline[x_pos + 1 :] and self.ich1:
if (
- y == self.__posxy[1]
- and x_coord > self.__posxy[0]
+ y == self.posxy[1]
+ and x_coord > self.posxy[0]
and oldline[px_pos:x_pos] == newline[px_pos + 1 : x_pos + 1]
):
x_pos = px_pos
self.__move(x_coord, y)
self.__write_code(self.ich1)
self.__write(newline[x_pos])
- self.__posxy = x_coord + character_width, y
+ self.posxy = x_coord + character_width, y
# if it's a single character change in the middle of the line
elif (
character_width = wlen(newline[x_pos])
self.__move(x_coord, y)
self.__write(newline[x_pos])
- self.__posxy = x_coord + character_width, y
+ self.posxy = x_coord + character_width, y
# if this is the last character to fit in the line and we edit in the middle of the line
elif (
):
self.__hide_cursor()
self.__move(self.width - 2, y)
- self.__posxy = self.width - 2, y
+ self.posxy = self.width - 2, y
self.__write_code(self.dch1)
character_width = wlen(newline[x_pos])
self.__move(x_coord, y)
self.__write_code(self.ich1)
self.__write(newline[x_pos])
- self.__posxy = character_width + 1, y
+ self.posxy = character_width + 1, y
else:
self.__hide_cursor()
if wlen(oldline) > wlen(newline):
self.__write_code(self._el)
self.__write(newline[x_pos:])
- self.__posxy = wlen(newline), y
+ self.posxy = wlen(newline), y
if "\x1b" in newline:
# ANSI escape characters are present, so we can't assume
self.__write_code(fmt, *args)
def __move_y_cuu1_cud1(self, y):
- dy = y - self.__posxy[1]
+ assert self._cud1 is not None
+ assert self._cuu1 is not None
+ dy = y - self.posxy[1]
if dy > 0:
self.__write_code(dy * self._cud1)
elif dy < 0:
self.__write_code((-dy) * self._cuu1)
def __move_y_cuu_cud(self, y):
- dy = y - self.__posxy[1]
+ dy = y - self.posxy[1]
if dy > 0:
self.__write_code(self._cud, dy)
elif dy < 0:
self.__write_code(self._cuu, -dy)
def __move_x_hpa(self, x: int) -> None:
- if x != self.__posxy[0]:
+ if x != self.posxy[0]:
self.__write_code(self._hpa, x)
def __move_x_cub1_cuf1(self, x: int) -> None:
- dx = x - self.__posxy[0]
+ assert self._cuf1 is not None
+ assert self._cub1 is not None
+ dx = x - self.posxy[0]
if dx > 0:
self.__write_code(self._cuf1 * dx)
elif dx < 0:
self.__write_code(self._cub1 * (-dx))
def __move_x_cub_cuf(self, x: int) -> None:
- dx = x - self.__posxy[0]
+ dx = x - self.posxy[0]
if dx > 0:
self.__write_code(self._cuf, dx)
elif dx < 0:
def repaint(self):
if not self.__gone_tall:
- self.__posxy = 0, self.__posxy[1]
+ self.posxy = 0, self.posxy[1]
self.__write("\r")
ns = len(self.screen) * ["\000" * self.width]
self.screen = ns
else:
- self.__posxy = 0, self.__offset
+ self.posxy = 0, self.__offset
self.__move(0, self.__offset)
ns = self.height * ["\000" * self.width]
self.screen = ns
self._hide_cursor()
self._move_relative(0, len(self.screen) - 1)
self.__write("\n")
- self.__posxy = 0, len(self.screen)
+ self.posxy = 0, len(self.screen)
self.screen.append("")
- px, py = self.__posxy
+ px, py = self.posxy
old_offset = offset = self.__offset
height = self.height
# portion of the window. We need to scroll the visible portion and the
# entire history
self._scroll(scroll_lines, self._getscrollbacksize())
- self.__posxy = self.__posxy[0], self.__posxy[1] + scroll_lines
+ self.posxy = self.posxy[0], self.posxy[1] + scroll_lines
self.__offset += scroll_lines
for i in range(scroll_lines):
y = len(newscr)
while y < len(oldscr):
self._move_relative(0, y)
- self.__posxy = 0, y
+ self.posxy = 0, y
self._erase_to_end()
y += 1
if wlen(newline) == self.width:
# If we wrapped we want to start at the next line
self._move_relative(0, y + 1)
- self.__posxy = 0, y + 1
+ self.posxy = 0, y + 1
else:
- self.__posxy = wlen(newline), y
+ self.posxy = wlen(newline), y
- if "\x1b" in newline or y != self.__posxy[1] or '\x1a' in newline:
+ if "\x1b" in newline or y != self.posxy[1] or '\x1a' in newline:
# ANSI escape characters are present, so we can't assume
# anything about the position of the cursor. Moving the cursor
# to the left margin should work to get to a known position.
self.screen = []
self.height, self.width = self.getheightwidth()
- self.__posxy = 0, 0
+ self.posxy = 0, 0
self.__gone_tall = 0
self.__offset = 0
pass
def _move_relative(self, x: int, y: int) -> None:
- """Moves relative to the current __posxy"""
- dx = x - self.__posxy[0]
- dy = y - self.__posxy[1]
+ """Moves relative to the current posxy"""
+ dx = x - self.posxy[0]
+ dy = y - self.posxy[1]
if dx < 0:
self.__write(MOVE_LEFT.format(-dx))
elif dx > 0:
self.event_queue.insert(0, Event("scroll", ""))
else:
self._move_relative(x, y)
- self.__posxy = x, y
+ self.posxy = x, y
def set_cursor_vis(self, visible: bool) -> None:
if visible:
def clear(self) -> None:
"""Wipe the screen"""
self.__write(CLEAR)
- self.__posxy = 0, 0
+ self.posxy = 0, 0
self.screen = [""]
def finish(self) -> None: