4.6. Commands¶
User actions are represented by Command objects that can then be triggered by
alot.ui.UI.apply_command().
Command-line strings given by the user via the prompt or key bindings can be translated to
Command objects using alot.commands.commandfactory().
Specific actions are defined as subclasses of Command and can be registered
to a global command pool using the registerCommand decorator.
Note
that the return value
of commandfactory() depends on the current mode the user interface is in.
The mode identifier is a string that is uniquely defined by the currently focuses
Buffer.
Note
The names of the commands available to the user in any given mode do not correspond one-to-one to these subclasses. You can register a Command multiple times under different names, with different forced constructor parameters and so on. See for instance the definition of BufferFocusCommand in ‘commands/globals.py’:
@registerCommand(MODE, 'bprevious', forced={'offset': -1},
help='focus previous buffer')
@registerCommand(MODE, 'bnext', forced={'offset': +1},
help='focus next buffer')
class BufferFocusCommand(Command):
def __init__(self, buffer=None, offset=0, **kwargs):
...