def get(): if KeyMap.key_map: return KeyMap.key_map cmd_map = CommandMap.get() KeyMap.key_map = keymap.KeyMap(keymap.AniLogKeyParser()) KeyMap.key_map.add_key('k', commands.Scroll(enums.Scroll.UP, '', '')) KeyMap.key_map.add_key('j', commands.Scroll(enums.Scroll.DOWN, '', '')) KeyMap.key_map.add_key('h', commands.Scroll(enums.Scroll.LEFT, '', '')) KeyMap.key_map.add_key('l', commands.Scroll(enums.Scroll.RIGHT, '', '')) KeyMap.key_map.add_key('gg', commands.Scroll(enums.Scroll.HOME, '', '')) KeyMap.key_map.add_key('G', commands.Scroll(enums.Scroll.END, '', '')) KeyMap.key_map.add_key('<Ctrl-b>', commands.Scroll(enums.Scroll.PAGE_UP, '', '')) KeyMap.key_map.add_key('<Ctrl-f>', commands.Scroll(enums.Scroll.PAGE_DOWN, '', '')) KeyMap.key_map.add_key('^', commands.Scroll(enums.Scroll.H_HOME, '', '')) KeyMap.key_map.add_key('$', commands.Scroll(enums.Scroll.H_END, '', '')) KeyMap.key_map.add_key('i', cmd_map['new_entry']) KeyMap.key_map.add_key('yy', commands.Copy('', '')) KeyMap.key_map.add_key('p', cmd_map['paste']) KeyMap.key_map.add_key('gt', cmd_map['next_browser']) KeyMap.key_map.add_key('gT', cmd_map['prev_browser']) KeyMap.key_map.add_key(':', commands.Write('', '', '')) KeyMap.key_map.add_key('cc', commands.Write('update %p %v', '', "")) KeyMap.key_map.add_key('C', commands.Write('update %p ', '', "")) KeyMap.key_map.add_key('dd', commands.Write('del_entry %p', '', '')) KeyMap.key_map.add_key('/', commands.Write('filter ', '', '')) KeyMap.key_map.add_key('<Rsz>', cmd_map['resize']) KeyMap.key_map.add_key('v', cmd_map['select']) KeyMap.key_map.add_key('++', cmd_map['increment']) return KeyMap.key_map
def test1(): signal.signal(signal.SIGINT, signal_handler) dispatcherA = DispatcherA() dispatcherB = DispatcherB() _keymap = keymap.KeyMap() _customkeymap = customkeymap.keymap_remote _keydispatcher = keydispatcher.KeyDispatcher(_keymap, _customkeymap) _keydispatcher.register_default_listener(dispatcherA) _keydispatcher.register_key_listener('KEY_1', dispatcherB) _keydispatcher.register_key_listener('KEY_2', dispatcherB) _keydispatcher.register_key_listener('KEY_3', dispatcherB) rc = remotecontrol.RemoteControl(_keydispatcher) rc.readLoop()
def test(): global mainthread signal.signal(signal.SIGINT, signal_handler) input = inputbuffer.InputBuffer() fdispatcher = FKeyDispatcher(input) _keymap = keymap.KeyMap() _keydispatcher = keydispatcher.KeyDispatcher(_keymap) _keydispatcher.register_default_listener(input) _keydispatcher.register_key_listener('KEY_1', fdispatcher) _keydispatcher.register_key_listener('KEY_Q', fdispatcher) rc = remotecontrol.RemoteControl(_keydispatcher) mainthread = mainthread.MainThread(input) mainthread.start() rc.readLoop()
def __init__(self, stdscreen): global mainthread global _keydispatcher global rc logger.info('started') input = inputbuffer.InputBuffer() fdispatcher = FKeyDispatcher(input) child = childprocess.ChildProcess() _keymap = keymap.KeyMap() _customkeymap = customkeymap.keymap_remote _keydispatcher = keydispatcher.KeyDispatcher(_keymap, _customkeymap) _keydispatcher.register_default_listener(input) _keydispatcher.register_default_listener(child) _keydispatcher.register_key_listener('KEY_1', fdispatcher) _keydispatcher.register_key_listener('KEY_Q', fdispatcher) rc = remotecontrol.RemoteControl(_keydispatcher) mainthread = mainthread.MainThread(input, stdscreen, child) mainthread.start() logger.info('rc.loop') rc.readLoop()
def get(): if CommandLineKeyMap.key_map: return CommandLineKeyMap.key_map cmd_map = CommandMap.get() CommandLineKeyMap.key_map = keymap.KeyMap(keymap.AniLogKeyParser()) CommandLineKeyMap.key_map.add_key( '<Ctrl-p>', commands.CmdLineScroll(enums.Scroll.UP, '', '')) CommandLineKeyMap.key_map.add_key( '<Ctrl-n>', commands.CmdLineScroll(enums.Scroll.DOWN, '', '')) CommandLineKeyMap.key_map.add_key( '<Left>', commands.CmdLineScroll(enums.Scroll.LEFT, '', '')) CommandLineKeyMap.key_map.add_key( '<Right>', commands.CmdLineScroll(enums.Scroll.RIGHT, '', '')) CommandLineKeyMap.key_map.add_key( '<S-Tab>', commands.CmdLineScroll(enums.Scroll.PAGE_UP, '', '')) CommandLineKeyMap.key_map.add_key( '<Tab>', commands.CmdLineScroll(enums.Scroll.PAGE_DOWN, '', '')) CommandLineKeyMap.key_map.add_key('<BS>', cmd_map['del_char']) # Whenever there is an <Enter>, there must be a <C-m> and <C-j>. # This is a law of curses. CommandLineKeyMap.key_map.add_key('<Enter>', cmd_map['press_enter']) CommandLineKeyMap.key_map.add_key('<Ctrl-m>', cmd_map['press_enter']) CommandLineKeyMap.key_map.add_key('<Ctrl-j>', cmd_map['press_enter']) return CommandLineKeyMap.key_map