Expand description
Shared ANSI escape parser and stripping utilities for VT Code.
Plain-text stripping is delegated to anstream’s ANSI state machine, which
is already a workspace dependency. The hand-rolled parser below remains for
the one thing anstream does not expose: the byte boundaries and payloads
of individual escape sequences (OSC 8 link ranges, echo suppression).
See docs/reference/ansi-in-vtcode.md for the workspace usage map.
Structs§
- Ansi
Strip Stream - Stateful ANSI stripper for chunked input such as a PTY byte stream.
Functions§
- contains_
unicode - Detect if text contains unicode characters that need special handling
- parse_
ansi_ sequence - Parse and determine the length of the ANSI escape sequence at the start of text.
- strip_
ansi - Strip ANSI escape codes from text, keeping only plain text.
- strip_
ansi_ ascii_ only - ANSI stripping for ASCII-only text.
- strip_
ansi_ codes - Strip ANSI escape codes from text, returning a borrowed
Cowwhen the input contains no ESC byte. This is the preferred API for call-sites that want to avoid allocation on the common “no ANSI codes” path.