summaryrefslogtreecommitdiff
path: root/alot/ui.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-08-28 22:08:59 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-09-03 22:14:08 +0100
commit3f0c099b80a792674a1d03e59ef0ff4489f77939 (patch)
tree89614665e06977b18abf9522884280b0895420bb /alot/ui.py
parentb643f49dfa48301e57a60aa0d407dcaceb9f6b2f (diff)
add UI.apply_commandline
that reads a cmdline string, possibly splits it in separate subcommand strings and fires the (sequence of) Command object(s).
Diffstat (limited to 'alot/ui.py')
-rw-r--r--alot/ui.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/alot/ui.py b/alot/ui.py
index 81d61556..e9413c81 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -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
@@ -141,6 +143,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