Skip to main content

Module event_source

Module event_source 

Source
Expand description

Crossterm event stream → Msg.

One of two branches in the main loop’s central select!. Crossterm’s EventStream yields key presses, mouse events, pastes, and resize notifications; we translate each into the typed Msg vocabulary the reducer understands.

The event source knows nothing about state. The reducer owns the transitions; the event source just produces typed inputs.

For --replay, a second event source (in recorder.rs) reads previously-recorded JSONL and yields the same Msg stream. The main loop can’t tell live crossterm events apart from replayed ones — that’s the point.

Functions§

coalesce_key_burst
Coalesce a burst of character/Enter key presses into a single paste.
event_to_msg
Translate one crossterm event into Msg. Returns None for events the reducer doesn’t care about (focus gained/lost, unknown media keys, key repeats, etc.).
parse_slash_command
Parse a slash-command input line (without the leading /) into a SlashCmd. Returns SlashCmd::Unknown if the command isn’t in the registry. Shared between the TUI dispatcher (C8) and any non-interactive command dispatch.