A scheme for an event-driven Sidebar
This guide will show all the stages in setting up the Sidebar in an event-driven NeoMutt. It will list all the objects, their owners, and all the possible events that could affect the Sidebar.
NeoMutt initialised
Index
start index dialog
All events begin in the event loop which waits for external events to happen. e.g.
Anything that causes a change to a Subject (Data, View, Window, etc) will cause a notification to be sent out. The observer can then respond.
Note: The observer doesn’t take action yet. That will happen in the reflow or recalc stages.
After the event has been processed, the screen panels will be given a chance to refresh themselves. This happens in three stages:
Reflow: If any windows have changed, the layout will be recalculated.
Any Windows that are resized will be notified.
Recalc: If any Data has changed, the panels can recalculated what’s needed to refresh the screen.
This step may be time-consuming.
Repaint: This step should be an instantaneous redrawing of the panel.
Below is an exhaustive list of every event that affects the Sidebar.
Data/View Change | Affects | Result |
---|---|---|
Account new | Displayed text | recalc |
Account change | Displayed text | recalc |
Account deleted | Displayed text | recalc |
AccountView changed | Displayed text | recalc |
Mailbox new | Displayed text | recalc |
Mailbox changed | Displayed text | recalc |
Mailbox deleted | Displayed text | recalc |
MailboxView changed | Displayed text | recalc |
Config Change | Affects | Result | Notes |
---|---|---|---|
ascii_chars | Divider | repaint | Unless character changes width |
folder | Displayed text | recalc | |
sidebar_component_depth | Displayed text | recalc | |
sidebar_delim_chars | Displayed text | recalc | |
sidebar_divider_char | Dividing line | repaint | Unless character changes width |
sidebar_folder_indent | Displayed text | recalc | |
sidebar_format | Displayed text | recalc | |
sidebar_indent_string | Displayed text | recalc | |
sidebar_new_mail_only | Displayed text | recalc | |
sidebar_next_new_wrap | Behaviour | none | |
sidebar_non_empty_mailbox_only | Displayed text | recalc | |
sidebar_on_right | Window position | repaint | See: Window position |
sidebar_short_path | Displayed text | recalc | |
sidebar_sort_method | Displayed text | recalc | |
sidebar_visible | Window visibility | reflow | See: Window become visible/hidden |
sidebar_width | Window size | reflow | See: Window narrow/widen |
spoolfile | Colour of text | repaint |
Colour Change | Affects | Result |
---|---|---|
indicator | Colour of text | repaint |
normal | Colour of text | repaint |
sidebar_divider | Colour of text | repaint |
sidebar_flagged | Colour of text | repaint |
sidebar_highlight | Colour of text | repaint |
sidebar_indicator | Colour of text | repaint |
sidebar_new | Colour of text | repaint |
sidebar_ordinary | Colour of text | repaint |
sidebar_spoolfile | Colour of text | repaint |
Function | Change | Result | Notes |
---|---|---|---|
<sidebar-next-new> | Move highlight | repaint | Unless highlight moves offscreen, in which case recalc |
<sidebar-next> | Move highlight | repaint | Unless highlight moves offscreen, in which case recalc |
<sidebar-open> | Open Mailbox | recalc | It’s possible that stats will change for the Mailbox |
<sidebar-page-down> | Move display | recalc | |
<sidebar-page-up> | Move display | recalc | |
<sidebar-prev-new> | Move highlight | repaint | Unless highlight moves offscreen, in which case recalc |
<sidebar-prev> | Move highlight | repaint | Unless highlight moves offscreen, in which case recalc |
<sidebar-toggle-virtual> | none | none | Obsolete |
<sidebar-toggle-visible> | Window visibility | reflow | See: Window become visible/hidden |
Command | Affects | Result |
---|---|---|
sidebar_whitelist | Displayed text | recalc |
unsidebar_whitelist | Displayed text | recalc |
These changes are the effect of other events, e.g. resizing the terminal, changing config. In some cases the result will depend on the exact setup of the screen. When possible, the Sidebar will just be repainted.
Window Change | Result | Notes |
---|---|---|
Become taller | recalc | Only if there is more text to display, otherwise repaint |
Become shorter | none | Unless highlight is moved offscreen, in which case recalc |
Become narrower | recalc | Affects sidebar_format |
Become wider | recalc | Affects sidebar_format |
Become moved | repaint | If dimensions are the same, otherwise recalc |
Become visible | repaint | If nothing else has changed, otherwise recalc |
Become hidden | none | Ignore recalc requests while hidden |
These examples list all the notifications involved in some common tasks.
User sources a config file.
Processing
Config: color error white red
Sidebar: No action (not relevant)
Config: color indicator white blue
Sidebar: No action (sidebar_indicator is set)
Config: color sidebar_flagged black yellow
Sidebar: Relevant, add repaint flag to Sidebar Window
Config: color sidebar_divider brightblack default
Sidebar: Relevant, add repaint flag to Sidebar Window
Update
Note: Repaint flag is set twice, but the Sidebar is only repainted once
User makes the terminal shorter.
Processing
SIGWINCH
Update
Note: If the highlight had still been on-screen after the resize, the Sidebar would not have needed to recalc or repaint.
The goal is to make the Sidebar completely independent. Achieving this would mean that a developer could then create a new panel without having to change large amounts of core code.
An independent panel would need to be able to dynamically define its own: