Skip to main content

Module vt_parser

Module vt_parser 

Source
Expand description

VT100 SGR parser for task output streams.

Converts raw byte chunks into StyledLine values — structured, styled representations of individual terminal output lines.

§Parsing scope (MVP)

Handles what is needed for build-tool output:

  • \n — emit current line
  • \r — move cursor to column 0 (overwrite mode; does not clear the line — correct POSIX terminal behaviour, which also handles CRLF correctly)
  • SGR sequences (\x1b[...m):
    • reset (0)
    • bold (1), italic (3), underline (4)
    • standard foreground (30–37), bright foreground (90–97), default fg (39)
    • standard background (40–47), bright background (100–107), default bg (49)
    • 256-colour fg/bg (38;5;n / 48;5;n)
    • truecolour fg/bg (38;2;r;g;b / 48;2;r;g;b)
  • Unknown / malformed sequences — silently skipped, never panics
  • Invalid UTF-8 — lossy replacement

Structs§

Style
Text rendering style at a given position.
StyleSpan
A styled region within a StyledLine.
StyledLine
A single completed terminal output line with optional styling.
TerminalParser
Stateful, incremental VT100 SGR parser.

Enums§

Color
A terminal colour value.