def test_compile_keymap(): k = compile_keymap({ b'a': 'test', b'bc': 'test2', }) assert k == {b'a': 'test', b'b': {b'c': 'test2'}}
def EventQueue(fd, encoding): keycodes = general_keycodes() if os.isatty(fd): backspace = tcgetattr(fd)[6][VERASE] keycodes[backspace] = unicode('backspace') k = keymap.compile_keymap(keycodes) trace('keymap {k!r}', k=k) return EncodedQueue(k, encoding)
def EventQueue(fd, encoding): keycodes = general_keycodes() if os.isatty(fd): backspace = tcgetattr(fd)[6][VERASE] keycodes[backspace] = unicode("backspace") k = keymap.compile_keymap(keycodes) trace("keymap {k!r}", k=k) return EncodedQueue(k, encoding)
def __init__(self, fd): our_keycodes = {} for key, tiname in _keynames.items(): keycode = curses.tigetstr(tiname) if keycode: our_keycodes[keycode] = unicode(key) our_keycodes[tcgetattr(fd)[6][VERASE]] = u'backspace' self.k = self.ck = keymap.compile_keymap(our_keycodes) self.events = [] self.buf = []
def __init__(self, keymap, verbose=0, invalid_cls=None, character_cls=None): self.verbose = verbose from pyrepl.keymap import compile_keymap, parse_keys self.keymap = keymap self.invalid_cls = invalid_cls self.character_cls = character_cls d = {} for keyspec, command in keymap: keyseq = tuple(parse_keys(keyspec)) d[keyseq] = command if self.verbose: print d self.k = self.ck = compile_keymap(d, ()) self.results = [] self.stack = []
def __init__(self, keymap, verbose=0, invalid_cls=None, character_cls=None): self.verbose = verbose from pyrepl.keymap import compile_keymap, parse_keys self.keymap = keymap self.invalid_cls = invalid_cls self.character_cls = character_cls d = {} for keyspec, command in keymap: keyseq = tuple(parse_keys(keyspec)) d[keyseq] = command if verbose: trace('[input] keymap: {}', pprint.pformat(d)) self.k = self.ck = compile_keymap(d, ()) self.results = deque() self.stack = []