Expand description
Crossterm → KeyChord adapter for the TUI renderer.
Phase 5.4 split: the renderer-neutral chord types (KeyChord,
KeyKind, SpecialKey, KeyMods, ChordParseError,
parse_chord_sequence, last_chord_token_byte_len, and the
FromStr / Display impls) live in
lattice_host::chord. This module is the TUI-side adapter
that turns a crossterm::KeyEvent into the canonical
KeyChord the keymap trie indexes by.
from_event (the canonical crossterm-side entry) lives here
as a free function rather than an impl KeyChord method
because orphan rules forbid extending a foreign type from
this crate. Existing call sites change from
KeyChord::from_event(&ev) to chord::from_event(&ev); the
re-export below means crate::chord::KeyChord (and every
other neutral type) still resolves unchanged.
The future lattice-ui-gpui ships its own analogous
gpui_chord::from_event(&GpuiKeyEvent) -> Option<KeyChord>
adapter; both renderers feed the same KeyChord into
lattice_host’s dispatch.
Structs§
- KeyChord
- Canonical, stack-allocated representation of one chord.
- KeyMods
- Modifier bitfield.
Copy + Eq + Hashso the wholeKeyChordfits in a CPU register.
Enums§
- Chord
Parse Error - Parse-side error variants. Detail-level so
:bind-style error messages can surface what was wrong. - Chord
Pattern - One element of a keymap registration path.
- KeyKind
- What kind of key the chord represents.
- Special
Key - Named special keys. Renderer-neutral; crossterm’s
KeyCode::BackTabis normalised away by the TUI adapter (from_crossterm) intoSpecial(Tab) + KeyMods::SHIFTso the trie has one entry for “shift-tab” rather than two ambiguous ones.
Functions§
- format_
chord - Render a single crossterm key event as canonical chord
notation. Returns
Nonefor events that have no chord representation. Thin shim overfrom_event+to_string. - from_
event - Normalise a
crossterm::KeyEventinto a canonicalKeyChord. ReturnsNonefor events that have no chord representation (release events on terminals that emit them, modifier-only presses, key codes we don’t recognise). - last_
chord_ token_ byte_ len - Number of bytes the last chord token occupies at the end of
text, treating it as a sequence of chord tokens (one chord per logical keypress). Used by chord-capture’s backspace handler to remove a whole token instead of a single char. - parse_
chord_ sequence - Parse a chord-sequence string into the canonical
Vec<KeyChord>the keymap trie indexes by. - special_
label - Canonical name for a
SpecialKey. Round-trips throughparse_special. Renderer-neutral text; both the TUI’sformat_chordand any future GPUI describe-key renderer use this label.