Expand description
P5-4 (§2 module 30): a terminal-library-agnostic key event — the
crate::tui::state::TuiState::handle_key state machine consumes THIS
type, not crossterm::event::KeyEvent, so the whole view-model core
stays free of a crossterm/ratatui dependency (neither is in
crates/harness’s Cargo.toml — see that crate’s own doc comment for why:
a real terminal can’t be driven in a unit test, but this struct can be
constructed by hand). crates/cli’s render/event-loop layer is the one
place that translates a real crossterm::event::KeyEvent into this
shape before handing it to the state machine.
Structs§
- KeyEvent
- A
Keyplus the modifier keys held with it. Named fields (not a bitflag) so a test/keymap-string reader can construct one by hand without needing to know a bit layout.
Enums§
- Key
- One logical key, independent of any terminal library’s own enum.
#[non_exhaustive]so a future key (e.g. a specific F-key pastF(12), or a media key) can be added without breaking a downstreammatch.