def test_shift(self): cuiapp = app.CuiApp(kaa.options.build_parser().parse_args([])) with raises(KaaError): cuiapp.translate_key({keyboard.shift}, 'A') assert [curses.KEY_SRIGHT] == cuiapp.translate_key({keyboard.shift}, keyboard.right)
def test_alt(self): cuiapp = app.CuiApp(kaa.options.build_parser().parse_args([])) assert '\x1ba' == cuiapp.translate_key({keyboard.alt}, 'a') assert '\x1b\x01' == cuiapp.translate_key( {keyboard.ctrl, keyboard.alt}, 'a') assert ['\x1b', curses.KEY_RIGHT] == cuiapp.translate_key({keyboard.alt}, keyboard.right) assert ['\x1b', curses.KEY_SRIGHT ] == cuiapp.translate_key({keyboard.alt, keyboard.shift}, keyboard.right)
def test_keytrans(self): cuiapp = app.CuiApp(kaa.options.build_parser().parse_args([])) assert 'A' == cuiapp.translate_key((), 'A') assert [curses.KEY_RIGHT] == cuiapp.translate_key((), keyboard.right) with raises(KaaError): cuiapp.translate_key((), keyboard.insert)
def main(stdscr): conf = config.Config(opt) sys.path.insert(0, conf.KAADIR) kaa.log.init(conf.LOGDIR) _init(stdscr) try: keydef.init(conf) kaa.app = app.CuiApp(conf) kaa.app.storage = fileio.FileStorage() if not opt.no_init: fname = opt.init_script if not fname: fname = os.path.join(kaa.app.config.KAADIR, '__kaa__.py') run_userinit(fname) from kaa.cui import frame mainframe = frame.MainFrame(stdscr) kaa.app.init(mainframe) if not opt.file: # no file args. show new document. doc = kaa.app.storage.newfile(temporary=True) kaa.app.show_doc(doc) else: dirname = None for filename in opt.file: if os.path.isdir(filename): if not dirname: dirname = filename else: doc = kaa.app.storage.openfile(filename) editor = kaa.app.show_doc(doc) kaa.app.file_commands.restore_file_loc(editor) if dirname: from kaa.ui.selectfile import selectfile def cb(filename, encoding, newline): if filename: doc = kaa.app.storage.openfile(filename, encoding, newline) kaa.app.show_doc(doc) else: if not kaa.app.mainframe.childframes: doc = kaa.app.storage.newfile(temporary=True) kaa.app.show_doc(doc) selectfile.show_fileopen(dirname, cb) if opt.command: cmd = kaa.app.focus.document.mode.get_command(opt.command) is_available, command = cmd if command: command(kaa.app.focus) else: sys.exit('Unknown command: {}'.format(opt.command)) # kaa.app.call_later(10, _check_newversion) kaa.app.run() mainframe.destroy() kaa.app.on_shutdown() finally: _restore()