Converts byte streams into high-level tokens representing ANSI escape sequences, SGR attributes, and plain text. The parser handles partial input: incomplete escape sequences and UTF-8 multi-byte characters at chunk boundaries are buffered until the next feed call.
Parsing never raises on malformed input. Unrecognized sequences become Unknown controls and invalid UTF-8 is replaced with U+FFFD. Maximum sequence lengths (max_escape_length for CSI, max_osc_length for OSC) prevent unbounded buffering.
The type for SGR (Select Graphic Rendition) attributes. Represents individual style changes from a single SGR sequence. A sequence like ESC [ 1 ; 31 m produces [`Bold; `Fg Red].
reset p clears internal buffers and returns p to the default state. Discards buffered partial sequences.
Feeding
Sourceval feed : t->bytes ->off:int ->len:int ->(token-> unit)-> unit
feed p buf ~off ~len f processes len bytes from buf starting at off, calling f for each complete token. Incomplete sequences are buffered until the next call.
pending p is a copy of raw input bytes not yet consumed. Escape sequence bodies being accumulated (CSI parameters, OSC payloads) are stored in separate internal buffers and are not included. Use has_pending to avoid allocation when only checking for pending data.