def cursor_left(self, n=1):
"""ESCnD CUB (Cursor Back)"""
# Commented out to save CPU (and the others below too)
#logging.debug('cursor_left(%s)' % n)
n = int(n)
# This logic takes care of double-width unicode characters
if self.double_width_left:
self.double_width_left = False
return
self.cursorX = max(0, self.cursorX - n) # Ensures positive value
try:
char = self.screen[self.cursorY][self.cursorX]
except IndexError: # Cursor is past the right-edge of the screen; ignore
char = u' ' # This is a safe default/fallback
if unicodedata.east_asian_width(char) == 'W':
# This lets us skip the next call (get called 2x for 2x width)
self.double_width_left = True
try:
for callback in self.callbacks[CALLBACK_CURSOR_POS].values():
callback()
except TypeError:
pass
评论列表
文章目录