Ejemplo n.º 1
0
def test_compile_keymap():
    k = compile_keymap({
        b'a': 'test',
        b'bc': 'test2',
    })

    assert k == {b'a': 'test', b'b': {b'c': 'test2'}}
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 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 = []
Ejemplo n.º 5
0
 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 = []
Ejemplo n.º 6
0
 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 = []
Ejemplo n.º 7
0
 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 = []
Ejemplo n.º 8
0
 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 = []
Ejemplo n.º 9
0
 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 = []