Alot sets up a widget tree and an mainloop in the constructor of alot.ui.UI. The visible area is a urwid.Frame, where the footer is used as a status line and the body part displays the currently active alot.buffers.Buffer.
To be able to bind keystrokes and translate them to Commands, keypresses are not propagated down the widget tree as is customary in urwid. Instead, the root widget given to urwids mainloop is a custom wrapper (alot.ui.Inputwrap) that interprets key presses. A dedicated SendKeypressCommand can be used to trigger key presses to the wrapped root widget and thereby accessing standard urwid behaviour.
In order to keep the interface non-blocking, alot makes use of twisted’s deferred - a framework that makes it easy to deal with callbacks. Many commands in alot make use of inline callbacks, which allow you to treat deferred-returning functions almost like syncronous functions. Consider the following example of a function that prompts for some input and acts on it:
from twisted.internet import defer @defer.inlineCallbacks def greet(ui): # ui is instance of alot.ui.UI name = yield ui.prompt(prefix='pls enter your name>') ui.notify('your name is: ' + name)
This class integrates all components of alot and offers methods for user interaction like prompt(), notify() etc. It handles the urwid widget tree and mainloop (we use twisted) and is responsible for opening, closing and focussing buffers.
list of active buffers
applies a command
This calls the pre and post hooks attached to the command, as well as cmd.apply().
|Parameters:||cmd (Command) – an applicable command|
prompt for text input
prompt user to make a choice
opens notification popup
an urwid widget (this notification) that can be handed to clear_notify() for removal
clears notification popups. Call this to ged rid of messages that don’t time out.
|Parameters:||messages – The popups to remove. This should be exactly what notify() returned when creating the popup|
closes given Buffer.
This it removes it from the bufferlist and calls its cleanup() method.
returns currently open buffers for a given subclass of alot.buffer.Buffer
A buffer defines a view to your data. It knows how to render itself, to interpret keypresses and is visible in the “body” part of the widget frame. Different modes are defined by subclasses of the following base class.
Abstract base class for buffers.
tells the buffer to (re)construct its visible content.
called before buffer is dismissed
Available modes are:
selectable list of active buffers
message composition mode
toggles visibility of all envelope headers
shows a result set for a Thread query, one line per Thread
terminates the process that fills this buffers PipeWalker.
returns curently focussed alot.widgets.ThreadlineWidget from the result list.
shows a single mailthread as a (collapsible) tree of MessageWidgets.
What follows is a list of the non-standard urwid widgets used in alot. Some of them respect user settings, themes in particular.
text widget that renders a tagstring.
It looks up the string it displays in the tag-translate section of the config as well as custom theme settings for its tag.
Flow widget that renders a Message.
toggles if message headers are shown
get contained :class`~alot.message.Message`
get contained email
one line summary of a Message.
renders a pile of header values as key/value list
displays printable parts of an email
alot.ui.UI.prompt() allows tab completion using a Completer object handed as ‘completer’ parameter. alot.completion defines several subclasses for different occasions like completing email addresses from an AddressBook, notmuch tagstrings. Some of these actually build on top of each other; the QueryCompleter for example uses a TagsCompleter internally to allow tagstring completion after “is:” or “tag:” keywords when typing a notmuch querystring.
All these classes overide the method complete, which for a given string and cursor position in that string returns a list of tuples (completed_string, new_cursor_position) that are taken to be the completed values. Note that completed_string does not need to have the original string as prefix.
base class for completers
returns a list of completions and cursor positions for the string original from position pos on.
pairs of completed string and cursor position in the new string
list of (str, int)
calculates the subword in a sep-splitted list of substrings of original that pos is ia.n
completion for a notmuch query string
completion for a comma separated list of tagstrings
|Parameters:||dbman (DBManager) – used to look up avaliable tagstrings|
completes users’ own mailaddresses
|Parameters:||accountman (AccountManager) – used to look up the list of addresses|
|Parameters:||mode (str) – mode identifier|
completion for commandline
completion for paths