diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-11-09 21:32:40 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-02-19 18:43:17 +0000 |
commit | 1be9a27f4d1a90bd8736eb889d6721853a16d1c0 (patch) | |
tree | e32d833263d2264cc7054fdf788b83da071713ff | |
parent | ef7d2b0e48ba68f2f4c7646dfcb7af697e5d18c2 (diff) |
remember and re-interpret command*line* for repeat
... commands. At some point we might want to add a command
history for an undo feature. For this I'd keep a history of
the applied Command objects and in reverse order call its .undo() method.
For this to work we need one Command object for each application.
If however we re-use a Command object using 'repeat' we'd most certainly lose
local information on how to undo the first application..
-rw-r--r-- | alot/commands/globals.py | 4 | ||||
-rw-r--r-- | alot/ui.py | 16 |
2 files changed, 9 insertions, 11 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 3f55bcf2..a04aecef 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -314,8 +314,8 @@ class PythonShellCommand(Command): class RepeatCommand(Command): """Repeats the command executed last time""" def apply(self, ui): - if ui.last_command != None: - ui.apply_command(ui.last_command) + if ui.last_commandline is not None: + ui.apply_commandline(ui.last_commandline) else: ui.notify('no last command') @@ -10,9 +10,6 @@ from buffers import BufferlistBuffer from commands import commandfactory from alot.commands import CommandParseError from alot.commands.globals import CommandSequenceCommand -from alot.commands.globals import FlushCommand -from alot.commands.globals import PromptCommand -from alot.commands.globals import RepeatCommand from alot.helper import string_decode from alot.helper import split_commandline from alot.widgets.globals import CompleteEdit @@ -40,8 +37,8 @@ class UI(object): """history of the command line prompt""" input_queue = [] """stores partial keyboard input""" - last_command = None - """saves the last executed command""" + last_commandline = None + """saves the last executed commandline""" def __init__(self, dbman, initialcmd): """ @@ -174,10 +171,11 @@ class UI(object): else: cmd = CommandSequenceCommand(cmdlist) self.apply_command(cmd) - if not isinstance(cmd, RepeatCommand) and \ - not isinstance(cmd, PromptCommand) and \ - not isinstance(cmd, FlushCommand): - self.last_command = cmd + + # store cmdline for use with 'repeat' command + cmdline = cmdline.lstrip() + if not cmdline.startswith('prompt') and not cmdline.startswith('repeat'): + self.last_commandline = cmdline def _unhandeled_input(self, key): """ |