Beispiel #1
0
def _loop(controller, screen):
    patched_screen = _Screen(screen)
    buf = ""
    while True:
        controller.render(patched_screen)
        ch = screen.getch()
        if ch > 255:
            if ch == curses.KEY_BACKSPACE:
                buf = to_binary(BS)
            elif ch == curses.KEY_ENTER:
                buf = to_binary(CR)
            else:
                buf = ""
                continue
        else:
            buf += chr(ch)
        try:
            unicode_character = to_unicode(buf, fail=True)
        except UnicodeDecodeError:
            # We are dealing with an incomplete multi-byte character.
            pass
        else:
            buf = ""
            result = controller.process_input(unicode_character)
            if result:
                return result
Beispiel #2
0
 def _get_output(self):
     return to_binary(self._get_selected_item())