pub enum Token {
Text(String),
Control(u8),
Csi {
private: Option<char>,
params: Vec<u16>,
intermediates: Vec<u8>,
final_byte: char,
},
Esc {
intermediates: Vec<u8>,
final_byte: u8,
},
Osc(String),
Other {
intro: u8,
data: Vec<u8>,
},
}Expand description
One parsed unit of terminal output.
Variants§
Text(String)
A run of printable text (valid UTF-8; invalid input bytes become
U+FFFD). Runs are flushed at each control byte and at the end of each
feed call, so adjacent Text tokens are equivalent to one.
Control(u8)
A C0 control byte executed on its own (BEL, BS, TAB, LF, CR, …) or
DEL. ESC never appears here; it introduces a sequence.
Csi
ESC [ ...: a CSI sequence with an optional private marker (?, >, <,
=), numeric parameters, intermediate bytes, and the final byte.
Missing parameters parse as 0; colon sub-parameters are truncated.
Esc
A non-CSI escape: ESC + optional intermediates + final byte
(e.g. ESC 7, ESC ( B).
Osc(String)
ESC ] ...: an OSC string, terminated by BEL or ST (ESC \).
Payload bytes are decoded as UTF-8 (lossily).
Other
A DCS/SOS/PM/APC string (intro is P, X, ^, or _), swallowed
whole and surfaced raw rather than interpreted.