Expand description
Terminal input parsing: a pure bytes-in / events-out state machine.
This is a 1:1 port of ink’s two-stage terminal input pipeline:
- The (private)
segmentermodule portsinput-parser.ts— the stateful segmentation layer that splits a raw byte stream into opaque key/text byte runs and decoded bracketed-paste payloads, with partial-sequence buffering across chunks. It is an internal detail wrapped byParser. keypressportsparse-keypress.ts(plus the kitty-protocol decoding fromkitty-keyboard.ts) — the pure function that decodes one key sequence into aKey, trying the kitty CSI-u and kitty-enhanced special-key parsers first, then the legacy enquirer-derived table.
There is no I/O and no stream coupling: callers feed bytes and receive a
Vec<InputEvent>. This mirrors the future napi push_input(bytes) -> Vec<InputEvent> surface.
§Layering rationale
The two ink files are genuinely different layers and are tested separately
upstream: input-parser.ts asserts raw segment strings (['a', "[A", 'b'], [{paste: 'hello'}]); parse-keypress.ts and the kitty tests assert
Key fields. Keeping the segmenter and parse_keypress as distinct,
independently testable units lets both upstream test suites be ported
verbatim. Parser composes them for the napi consumer.
Re-exports§
pub use keypress::EventType;pub use keypress::Key;pub use keypress::parse_keypress;
Modules§
- keypress
- Port of
parse-keypress.tsand the kitty-protocol decoding fromkitty-keyboard.ts.
Structs§
- Parser
- The public input parser: bytes in,
InputEvents out, with partial-sequence buffering held acrossfeedcalls.
Enums§
- Input
Event - A high-level input event handed to the host (the napi
push_inputconsumer). Mirrors ink’sInputEvent(KeyfromparseKeypress, plus the{paste}arm), composed from the two ported layers.