pub struct InputParser { /* private fields */ }Expand description
Terminal input parser with DoS protection.
Parse terminal input bytes into events:
let mut parser = InputParser::new();
let events = parser.parse(b"\x1b[A"); // Up arrow
assert_eq!(events.len(), 1);Implementations§
Source§impl InputParser
impl InputParser
Sourcepub fn set_expect_x10_mouse(&mut self, enabled: bool)
pub fn set_expect_x10_mouse(&mut self, enabled: bool)
Enable or disable X10 mouse event parsing.
When enabled, bare CSI M triggers X10 coordinate collection
(3 raw bytes). This should generally follow mouse-capture state.
Sourcepub fn set_allow_legacy_mouse(&mut self, enabled: bool)
pub fn set_allow_legacy_mouse(&mut self, enabled: bool)
Enable or disable legacy numeric mouse fallback parsing.
When enabled, parse CSI Cb;Cx;Cy M as mouse input. This is useful when
mouse capture is active but the terminal does not honor SGR 1006 mode.
Default: false.
Sourcepub const fn has_pending_timeout_state(&self) -> bool
pub const fn has_pending_timeout_state(&self) -> bool
Whether the parser is currently waiting on additional bytes for a timeout-resolved sequence (bare ESC or partial UTF-8).
Sourcepub fn timeout(&mut self) -> Option<Event>
pub fn timeout(&mut self) -> Option<Event>
Handle a timeout in the input stream.
If the parser is waiting for more bytes to complete an ambiguous sequence (specifically a bare ESC), a timeout indicates the sequence has ended.
Sourcepub fn parse(&mut self, input: &[u8]) -> Vec<Event>
pub fn parse(&mut self, input: &[u8]) -> Vec<Event>
Parse input bytes and return any completed events.
Sourcepub fn parse_with<F>(&mut self, input: &[u8], emit: F)
pub fn parse_with<F>(&mut self, input: &[u8], emit: F)
Parse input bytes and emit each completed event through emit.
Sourcepub fn parse_into(&mut self, input: &[u8], events: &mut Vec<Event>)
pub fn parse_into(&mut self, input: &[u8], events: &mut Vec<Event>)
Parse input bytes and append completed events to events.
This variant lets callers reuse a scratch buffer across parses to avoid repeated allocations on hot input paths.