pub struct Parser { /* private fields */ }Expand description
An incremental parser for terminal input.
Feed it bytes as they arrive with Parser::feed, then pull events out
with Parser::next_event. A sequence split across two reads is handled:
the parser waits for the rest. Unknown or malformed sequences are skipped
and never panic or block later input.
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn next_event(&mut self) -> Option<Event>
pub fn next_event(&mut self) -> Option<Event>
The next complete event, or None if more bytes are needed.
Sourcepub fn expect_cursor_position(&mut self)
pub fn expect_cursor_position(&mut self)
Tells the parser that a cursor position report (ESC [ row ; col R) is
on its way, in answer to a ESC [ 6 n query. The next such sequence is
then kept for Parser::take_cursor_position instead of being read as
a key, because it is otherwise indistinguishable from Ctrl+F3.
Sourcepub fn take_cursor_position(&mut self) -> Option<(u32, u32)>
pub fn take_cursor_position(&mut self) -> Option<(u32, u32)>
The (row, column) of the last cursor position report, counted from 1,
or None if none has arrived since this was last called.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Whether bytes are waiting for the rest of an escape sequence. After
Parser::next_event returns None, this is true if more input could
still complete an event, so the caller should wait a moment and then
call Parser::flush.