diff options
author | mathieui <mathieui@mathieui.net> | 2012-07-26 12:57:42 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-07-26 12:57:42 +0200 |
commit | 1c29b39a6e882a7e5dd262ed1f5602740bcdd199 (patch) | |
tree | 0d2951fa794215363b32c4c33ba08c0827d2fd46 /src | |
parent | d8623d1c509e8f90234d239e61bb0e8bd93851e6 (diff) | |
download | poezio-1c29b39a6e882a7e5dd262ed1f5602740bcdd199.tar.gz poezio-1c29b39a6e882a7e5dd262ed1f5602740bcdd199.tar.bz2 poezio-1c29b39a6e882a7e5dd262ed1f5602740bcdd199.tar.xz poezio-1c29b39a6e882a7e5dd262ed1f5602740bcdd199.zip |
Add a /runkey command
This allows the user to run the action defined on a key without having
to press that key. The completion completes all the available keys that
will have an effect.
Diffstat (limited to 'src')
-rw-r--r-- | src/core.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/core.py b/src/core.py index 9de580b8..27b8c880 100644 --- a/src/core.py +++ b/src/core.py @@ -177,6 +177,7 @@ class Core(object): 'bookmarks': (self.command_bookmarks, _("Usage: /bookmarks\nBookmarks: Show the current bookmarks."), None), 'remove_bookmark': (self.command_remove_bookmark, _("Usage: /remove_bookmark [jid]\nRemove Bookmark: Remove the specified bookmark, or the bookmark on the current tab, if any."), self.completion_remove_bookmark), 'xml_tab': (self.command_xml_tab, _("Usage: /xml_tab\nXML Tab: Open an XML tab."), None), + 'runkey': (self.command_runkey, _("Usage: /runkey <key>\nRunkey: Execute the action defined for <key>."), self.completion_runkey), } # We are invisible @@ -1162,6 +1163,32 @@ class Core(object): commands = list(self.commands.keys()) + list(self.current_tab().commands.keys()) return the_input.auto_completion(commands, ' ', quotify=False) + def command_runkey(self, arg): + """ + /runkey <key> + """ + def replace_line_breaks(key): + if key == '^J': + return '\n' + return key + char = arg.strip() + func = self.key_func.get(char, None) + if func: + func() + else: + res = self.do_command(replace_line_breaks(char), False) + if res: + self.refresh_window() + + def completion_runkey(self, the_input): + """ + Completion for /runkey + """ + list_ = [] + list_.extend(self.key_func.keys()) + list_.extend(self.current_tab().key_func.keys()) + return the_input.auto_completion(list_, '', quotify=False) + def command_status(self, arg): """ /status <status> [msg] |