Skip to main content

Module ansi

Module ansi 

Source
Expand description

ANSI SGR (Select Graphic Rendition) + OSC 8 hyperlink parser.

The parser is byte-driven (not char-driven) because ANSI sequences are ASCII-only and we want to operate on raw input from arbitrary sources. Public API: Style, Color, ParseState, step, strip_sgr.

Structs§

Style

Enums§

Color
ParseState
ParseStep
Single-step transition driven by one input byte.

Functions§

step
Apply one input byte to the state machine. style and hyperlink are updated in place when relevant sequences complete.
strip_sgr
Strip SGR / CSI / OSC sequences from a byte slice. Returns a Cow<[u8]> that borrows the input when no sequences are present (common case) and owns a new buffer otherwise.