Expand description
A streaming push parser for the VT/xterm protocol.
Use VTPushParser::feed_with to feed bytes into the parser, handling the
VTEvents as they are emitted.
use vt_push_parser::VTPushParser;
use vt_push_parser::event::VTEvent;
let mut parser = VTPushParser::new();
let mut output = String::new();
parser.feed_with(b"\x1b[32mHello, world!\x1b[0m", &mut |event: VTEvent| {
output.push_str(&format!("{:?}", event));
});
assert_eq!(output, "Csi('32', '', 'm')Raw('Hello, world!')Csi('0', '', 'm')");§Interest
The parser can be configured to only emit certain types of events by setting
the INTEREST parameter. Other event types will be parsed and discarded.
For example, to only emit CSI (and Raw) events:
use vt_push_parser::{VTPushParser, VT_PARSER_INTEREST_CSI};
let mut parser = VTPushParser::new_with_interest::<VT_PARSER_INTEREST_CSI>();§Input parsing
This crate is designed to be used for parsing terminal output, but it can also be used for parsing input. Input is not always well-formed, however and may contain mode-switching escapes that require the parser to turn off its normal parsing behaviours (ie: bracketed-paste mode, xterm mouse events, etc).
The capture::VTCapturePushParser is useful for parsing input that may
work in this way.
Modules§
- ascii
- ASCII control codes.
- capture
- Raw-input-capturing push parser.
- event
- Event types.
- iter
- Iterator wrapper around
VTPushParser. - signature
- Escape sequence signature matching.
Structs§
- VTPush
Parser - A push parser for the VT/xterm protocol.
Constants§
- VT_
PARSER_ INTEREST_ ALL - Request all events from parser.
- VT_
PARSER_ INTEREST_ CSI - Request CSI events from parser.
- VT_
PARSER_ INTEREST_ DCS - Request DCS events from parser.
- VT_
PARSER_ INTEREST_ DEFAULT - Default interest level.
- VT_
PARSER_ INTEREST_ ESCAPE_ RECOVERY - Request escape recovery events from parser.
- VT_
PARSER_ INTEREST_ NONE - No events from parser (ie, only emits
VTEvent::Rawevents) - VT_
PARSER_ INTEREST_ OSC - Request OSC events from parser.
- VT_
PARSER_ INTEREST_ OTHER - Request other events from parser.
Traits§
- VTEvent
Callback - Receives a single
VTEvent. - VTEvent
Callback Abortable - Receives a single
VTEvent, returning a boolean indicating whether to continue parsing (true) or stop parsing (false).