4.3. User Interface¶
Alot sets up a widget tree and a 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 and react to events like terminal size changes, alot makes use of asyncio - which allows asynchronous calls without the use of callbacks. Alot makes use of the python 3.5 async/await syntax
async def greet(ui): # ui is instance of alot.ui.UI
name = await ui.prompt('pls enter your name')
ui.notify('your name is: ' + name)
4.3.1. UI
- the main component¶
4.3.2. Buffers¶
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.
Available modes are:
Mode |
Buffer Subclass |
---|---|
search |
|
thread |
|
bufferlist |
|
taglist |
|
namedqueries |
|
envelope |
|
4.3.3. Widgets¶
What follows is a list of the non-standard urwid widgets used in alot. Some of them respect user settings, themes in particular.
4.3.3.1. utils¶
Utility Widgets not specific to alot
- class alot.widgets.utils.AttrFlipWidget(*args: Any, **kwargs: Any)¶
An AttrMap that can remember attributes to set
- class alot.widgets.utils.DialogBox(*args: Any, **kwargs: Any)¶
4.3.3.2. globals¶
4.3.3.3. bufferlist¶
Widgets specific to Bufferlist mode
- class alot.widgets.bufferlist.BufferlineWidget(*args: Any, **kwargs: Any)¶
selectable text widget that represents a
Buffer
in theBufferlistBuffer
.
4.3.3.4. search¶
4.3.3.5. thread¶
4.3.4. Completion¶
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.
complete()
may rise alot.errors.CompletionError
exceptions.