Expand description
Events — the Event enum and the key/mouse records that fill it.
Event is the sum type a View matches arm-by-arm:
mouse presses/releases/moves/wheel, key presses, commands, broadcasts,
timer expiries, and paste. The keyboard side lives in the key submodule
(Key, KeyEvent, KeyModifiers); the mouse record (MouseEvent)
and the EventMask opt-in for expensive event classes live here.
Two events carry payloads worth naming up front. Event::Broadcast adds
an optional source: ViewId naming which view the broadcast is about
(e.g. which scrollbar changed) — a resolvable handle, None for broadcasts
about no particular view. Event::Timer carries which TimerId
expired.
One primitive is deliberately not reproduced: a synchronous, return-valued
message round-trip (the kind used for “may I close?” vetoes). A view here is
borrowed downward by the event loop and cannot synchronously call back into a
sibling and read a return value, so there is no event that carries a reply.
Code that needs that pattern queries the tree owner directly via
find_mut instead.
Guide: Commands & events.
§Turbo Vision heritage
Replaces the single TEvent tagged union (system.h) with a Rust sum type
(deviation D4). The original message event carried a command plus an untyped
pointer used three ways; here a command event carries only the Command, the
“which view” case becomes Event::Broadcast’s resolvable ViewId
source, and the timer-id case becomes the typed Event::Timer variant.
Structs§
- Event
Mask - Per-view opt-in mask for the expensive continuous event classes.
- KeyEvent
- A key-down event: the logical
Keythat was pressed plus theKeyModifiersheld at that moment. - KeyModifiers
- The keyboard modifiers active when a key or mouse event occurred — a struct
of three named
boolflags. - Mouse
Buttons - Which mouse buttons are currently held at the time of a
MouseEvent. - Mouse
Event - A mouse event record: cursor position, buttons down, wheel direction, click/move flags, and keyboard modifiers held at event time.
- Mouse
Event Flags - Per-event flags for click-repeat detection and movement — a struct of named
boolflags carried in everyMouseEvent.
Enums§
- Event
- An event a
Viewhandles, matched arm-by-arm. - Key
- A logical, modifier-free key — the base of a
KeyEvent. - Mouse
Wheel - The direction of mouse wheel motion carried by a
MouseEvent.
Functions§
- ctrl_
to_ arrow - Map WordStar Ctrl-letter navigation keys to their arrow/nav equivalents.
- hot_key
- Extract the hotkey character from a label string.
- is_
alt_ hotkey - Test whether a key event is the Alt-accelerator for a given hotkey char.
- is_
plain_ hotkey - Test whether a key event is a plain (non-modified) hotkey press.