def _get_input(self, wait_tenths):
# this works around a strange curses bug with window resizing
# not being reported correctly with repeated calls to this
# function without a doupdate call in between
curses.doupdate()
key = self._getch(wait_tenths)
resize = False
raw = []
keys = []
while key >= 0:
raw.append(key)
if key==KEY_RESIZE:
resize = True
elif key==KEY_MOUSE:
keys += self._encode_mouse_event()
else:
keys.append(key)
key = self._getch_nodelay()
processed = []
try:
while keys:
run, keys = escape.process_keyqueue(keys, True)
processed += run
except escape.MoreInputRequired:
key = self._getch(self.complete_tenths)
while key >= 0:
raw.append(key)
if key==KEY_RESIZE:
resize = True
elif key==KEY_MOUSE:
keys += self._encode_mouse_event()
else:
keys.append(key)
key = self._getch_nodelay()
while keys:
run, keys = escape.process_keyqueue(keys, False)
processed += run
if resize:
processed.append('window resize')
return processed, raw
评论列表
文章目录