Skip to main content

Module style

Module style 

Source
Expand description

Terminal styling: a tiny, dependency-free ANSI palette.

praxis-source is the workspace’s leaf crate (ADR-003) and must not pull in any external dependency, so the palette is built from raw ANSI escape codes — no colored, nu-ansi-term, or yansi. The output is identical to what those crates produce; it is just spelled out here.

§Design

Palette gates whether styling is emitted at all, and is the set of (foreground, weight) pairs the diagnostic renderer and the crash debugger use. Palette::plain() is a no-op palette — the default for the Renderer and for all snapshot tests, so diagnostics stay byte-stable across test runs; the styled palette matches rustc’s conventions: errors red & bold, warnings yellow &c.

Deciding when to style — the --color auto|always|never tri-state, and the terminal check auto needs — is the CLI’s job; it resolves the flag and hands down a Palette::from_enabled. Keeping that decision out of this crate keeps the leaf free of terminal I/O.

Structs§

Palette
A palette: a function from Style to a sequence of SGR codes. plain produces no codes at all (plain text); styled produces rustc-like colors.

Enums§

Severity
The severity the renderer is formatting (drives the caret/label color).
Style
The semantic styles a diagnostic uses. Each maps to zero or more SGR codes. Keeping these semantic (rather than Red/Bold) lets the whole palette be retuned in one place.