Guide API
Skip to main content

Module status_line

Module status_line 

Source
Expand description

The bottom StatusLine — a one-row View at the bottom of the screen showing the items of the help-context-selected StatusDef.

It draws the items, hit-tests mouse clicks, runs the mouse press-and-hold drag-highlight, handles the Command::COMMAND_SET_CHANGED broadcast (regraying its disabled items), and matches keyboard accelerators against all items (including the hidden, text-less ones).

§Mouse press-and-hold drag-highlight

Pressing the mouse over the status line highlights the item under the cursor and follows it as the cursor moves, firing the item’s command on release only if the cursor is still over an enabled item:

  • MouseDown: hit-test → set pressed_item, start tracking with TrackMask{ mouse_move: true }. Do NOT post yet.
  • MouseMove (while tracking): re-derive the item under the cursor; update pressed_item (→ None when off all items). The next redraw shows the new highlight.
  • MouseUp (while tracking): if pressed_item is Some(idx) and its command is enabled, post the command. Clear pressed_item / tracking.

The abs_origin field caches the view-local (0, 0) in absolute screen coords from the last draw, used by the capture to localize events.

§Help-context updates and keyboard accelerators

Program pre-routes key and status-line mouse events to the status line before normal dispatch, and on idle refreshes its help context from the topmost view (via set_help_ctx) so the shown def follows the focused view. A key matching an item’s accelerator is transformed in place into a command event so it propagates to the rest of the UI.

§Themes only — no palettes

Colors resolve directly from the Theme via the Status* Roles (StatusColors), like MenuColors.

§Turbo Vision heritage

Ports TStatusLine (tstatusl.cpp). The palette-index color indirection becomes direct theme-role lookups (deviation D7), and the streaming machinery is dropped (deviation D12). Structurally it embeds a ViewState with hand-written View methods rather than delegating, like MenuBar.

Structs§

StatusColors
The four (lo, hi) style pairs a status item is drawn in — normal, selected, normal-disabled, and selected-disabled — resolved once per draw from the Theme via the Status* Roles. Each pair is (label style, shortcut-highlight style).
StatusLine
The bottom status line. Owns its defs, caches the selected def index and a command-set snapshot for graying.