def cursor_right(self, n=1):
"""ESCnC CUF (Cursor Forward)"""
#logging.debug('cursor_right(%s)' % n)
if not n:
n = 1
n = int(n)
# This logic takes care of double-width unicode characters
if self.double_width_right:
self.double_width_right = False
return
self.cursorX += n
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_right = True
try:
for callback in self.callbacks[CALLBACK_CURSOR_POS].values():
callback()
except TypeError:
pass
评论列表
文章目录