diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-04 20:01:12 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-09-04 20:01:12 +0100 |
commit | 3d66ca079370e9d948b3c4554de313db464c0e69 (patch) | |
tree | 9afd423b7d38abdd4e4268384f3da2b9f6abb96d /alot/ui.py | |
parent | 9dfd5c7f3ff8b8929f81f212b677195006c47a1f (diff) | |
parent | e63d5c9f1275901f93e2ce7ad3bdb09a7703fcc0 (diff) |
Merge branch '0.3.2-feature-metacommands-78'
Diffstat (limited to 'alot/ui.py')
-rw-r--r-- | alot/ui.py | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -9,7 +9,9 @@ from settings import settings from buffers import BufferlistBuffer from commands import commandfactory from alot.commands import CommandParseError +from alot.commands.globals import CommandSequenceCommand from alot.helper import string_decode +from alot.helper import split_commandline from alot.widgets.globals import CompleteEdit from alot.widgets.globals import ChoiceWidget @@ -118,19 +120,17 @@ class UI(object): keyseq = ' '.join(self.input_queue) cmdline = settings.get_keybinding(self.mode, keyseq) if cmdline: + clear() logging.debug("cmdline: '%s'" % cmdline) # move keys are always passed if cmdline.startswith('move '): movecmd = cmdline[5:].rstrip() logging.debug("GOT MOVE: '%s'" % movecmd) if movecmd in ['up', 'down', 'page up', 'page down']: - clear() return [movecmd] elif not self._locked: try: - clear() - cmd = commandfactory(cmdline, self.mode) - self.apply_command(cmd) + self.apply_commandline(cmdline) except CommandParseError, e: self.notify(e.message, priority='error') @@ -141,6 +141,21 @@ class UI(object): # update statusbar self.update() + def apply_commandline(self, cmdline): + # split commandline if necessary + cmd = None + cmdlist = split_commandline(cmdline) + if len(cmdlist) == 1: + try: + # translate cmdstring into :class:`Command` + cmd = commandfactory(cmdlist[0], self.mode) + except CommandParseError, e: + self.notify(e.message, priority='error') + return + else: + cmd = CommandSequenceCommand(cmdlist) + self.apply_command(cmd) + def _unhandeled_input(self, key): """ Called by :class:`urwid.MainLoop` if a keypress was passed to the root @@ -523,3 +538,4 @@ class UI(object): d = defer.maybeDeferred(cmd.apply, self) d.addErrback(errorHandler) d.addCallback(call_posthook) + return d |