self.win.addch(0, 0, curses.ACS_UARROW, cjc_globals.theme_manager.attrs["scroll_mark"]) self.win.addstr(s, cjc_globals.theme_manager.attrs["default"]) self.win.clrtoeol() self.win.insch(0, self.w - 1, curses.ACS_DARROW, cjc_globals.theme_manager.attrs["scroll_mark"]) self.win.move(0, 1) if now: self.win.refresh() else: self.win.noutrefresh() finally: cjc_globals.screen.lock.release() from keytable import KeyFunction ktb = keytable.KeyTable("list-input", 50, ( KeyFunction("accept-input", ListInput.key_enter, "Accept input", ("ENTER", "\n", "\r")), KeyFunction("abort-input", ListInput.key_abort, "Abort input", "ESCAPE"), KeyFunction("next-option", ListInput.key_down, "Select the next option", "DOWN"), KeyFunction("previous-option", ListInput.key_up, "Select the previous option", "UP"), KeyFunction("select-option", ListInput.key_select, "Select current option", " "), )) keytable.install(ktb) # vi: sts=4 et sw=4
return if refresh: self.win.erase() s = self.prompt.encode(cjc_globals.screen.encoding, "replace") self.win.addstr(0, 0, s) s = self.content.encode(cjc_globals.screen.encoding, "replace") self.win.addstr(s) else: self.win.move(0, len(self.prompt) + len(self.content)) if now: self.win.refresh() else: self.win.noutrefresh() finally: cjc_globals.screen.lock.release() from keytable import KeyFunction ktb = keytable.KeyTable("bool-input", 50, ( KeyFunction("accept-input", BooleanInput.key_enter, "Accept input", ("ENTER", "\n", "\r")), KeyFunction("abort-input", BooleanInput.key_abort, "Abort input", "ESCAPE"), KeyFunction("answer-yes", BooleanInput.answer_yes, "Answer 'yes'", "y"), KeyFunction("answer-no", BooleanInput.answer_no, "Answer 'no'", "n"), )) keytable.install(ktb) # vi: sts=4 et sw=4
ret += s ret += "\n" finally: self.lock.release() return ret def dump_content(self): self.lock.acquire() try: dump = "List buffer dump of %r:\n" % (self.info["buffer_name"], ) for i in range(0, len(self.items)): dump += "%5i. %r: %r\n" % (i, self.keys[i], self.items[i]) finally: self.lock.release() self.__logger.debug("%s", dump) from keytable import KeyFunction ktb = keytable.KeyTable("list-buffer", 30, ( KeyFunction("page-up", ListBuffer.page_up, "Scroll buffer one page up", "PPAGE"), KeyFunction("page-down", ListBuffer.page_down, "Scroll buffer one page down", "NPAGE"), KeyFunction("dump-content", ListBuffer.dump_content, "Dump buffer content to the debug output", "M-d"), )) keytable.install(ktb) # vi: sts=4 et sw=4
self.win.refresh() cjc_globals.screen.cursync() else: self.win.noutrefresh() finally: cjc_globals.screen.lock.release() keytable.KeyTable("window", 60, ( keytable.KeyFunction("switch-to-active-buffer", Window.switch_to_active_buffer, "Switch to the first active buffer", "M-a"), keytable.KeyFunction("switch-to-buffer()", Window.switch_to_buffer, "Switch to buffer <arg>"), keytable.KeyBinding("switch-to-buffer(1)", "M-1"), keytable.KeyBinding("switch-to-buffer(2)", "M-2"), keytable.KeyBinding("switch-to-buffer(3)", "M-3"), keytable.KeyBinding("switch-to-buffer(4)", "M-4"), keytable.KeyBinding("switch-to-buffer(5)", "M-5"), keytable.KeyBinding("switch-to-buffer(6)", "M-6"), keytable.KeyBinding("switch-to-buffer(7)", "M-7"), keytable.KeyBinding("switch-to-buffer(8)", "M-8"), keytable.KeyBinding("switch-to-buffer(9)", "M-9"), keytable.KeyBinding("switch-to-buffer(0)", "M-0"), )).install() cmdtable.CommandTable("window", 80, (cmdtable.Command("clear", Window.cmd_clear, "/clear", "Clears current window"), )).install() # vi: sts=4 et sw=4
cjc_globals.screen.lock.acquire() try: if not cjc_globals.screen.active: return if refresh: self.win.move(0, 0) self.win.clrtoeol() s = self.prompt.encode(cjc_globals.screen.encoding, "replace") self.win.addstr(s) s = self.content.encode(cjc_globals.screen.encoding, "replace") self.win.addstr(s) self.win.move(0, self.pos + len(self.prompt)) if now: self.win.refresh() else: self.win.noutrefresh() finally: cjc_globals.screen.lock.release() from keytable import KeyFunction ktb = keytable.KeyTable("choice-input", 50, ( KeyFunction("accept-input", ChoiceInput.key_enter, "Accept input", ("ENTER", "\n", "\r")), KeyFunction("abort-input", ChoiceInput.key_abort, "Abort input", "ESCAPE"), KeyFunction("backward-delete-char", ChoiceInput.key_bs, "Delete previous character", ("BACKSPACE", "^H")), )) keytable.install(ktb) # vi: sts=4 et sw=4
self.active=False curses.reset_shell_mode() finally: self.lock.release() def prog_mode(self): self.lock.acquire() try: curses.reset_prog_mode() self.active=True self.redraw() finally: self.lock.release() keytable.KeyTable("screen",20,( keytable.KeyBinding("command(next)","M-^I"), keytable.KeyFunction("redraw-screen",Screen.redraw,"Redraw the screen","^L"), )).install() cmdtable.CommandTable("screen",90,( cmdtable.Command("next",Screen.cmd_next, "/next", "Change active window to the next one"), cmdtable.Command("prev",Screen.cmd_prev, "/previous", "Change active window to the previous one"), cmdtable.Command("nextbuf",Screen.cmd_nextbuf, "/nextbuf", "Change buffer in active window to next available"), cmdtable.Command("prevbuf",Screen.cmd_prevbuf, "/nextbuf", "Change buffer in active window to next available"),
ktb=keytable.KeyTable("text-input",50,( KeyFunction("complete", TextInput.key_complete, "Complete input", ("\t")), KeyFunction("accept-line", TextInput.key_enter, "Accept input", ("ENTER","\n","\r")), KeyFunction("beginning-of-line", TextInput.key_home, "Move to the begining", ("HOME","^A")), KeyFunction("end-of-line", TextInput.key_end, "Move to the end", ("END","^E")), KeyFunction("forward-char", TextInput.key_right, "Move right", ("RIGHT","^F")), KeyFunction("backward-char", TextInput.key_left, "Move left", ("LEFT","^B")), KeyFunction("previous-history", TextInput.history_prev, "Previous history item", ("UP","^P")), KeyFunction("next-history", TextInput.history_next, "Next history item", ("DOWN","^N")), KeyFunction("backward-delete-char", TextInput.key_bs, "Delete previous character", ("BACKSPACE","^H")), KeyFunction("delete-char", TextInput.key_del, "Delete current character", ("DC","^D")), KeyFunction("kill-line", TextInput.key_kill, "Erase whole text", "^K"), KeyFunction("unix-word-rubout", TextInput.key_wrubout, "Kill the word behind cursor", "^W"), KeyFunction("unix-line-discard", TextInput.key_uclean, "Kill backward from cursor to the beginning of the line", "^U"), ))