예제 #1
0
    def get(self, allow_empty=False):
        """
        Get input from screen and search if it matches any user-defined
        keycodes

        @param allow_empty: If set, returns empty list if nothing was typed
        """

        INPUT_TIMEOUT=0.25
        _input = None

        if allow_empty:
            if is_lowui_ge_0_9_9():
                self.xyz.screen.set_input_timeouts(INPUT_TIMEOUT)

        while True:
            _in = self.xyz.screen.get_input()

            if not _in:
                if allow_empty:
                    _input = _in
                    break
                else:
                    continue

            if self.WIN_RESIZE in _in:
                self._resized = True

            try:
                _input = [self.keycodes[tuple(_in)]]
            except KeyError:
                _input = _in

            break

        if allow_empty:
            if is_lowui_ge_0_9_9():
                self.xyz.screen.set_input_timeouts(None)

        return _input