ArrTop::Theme
The TUI colour scheme: a bag of ANSI escape codes plus an enabled flag and
one #colorize helper. Everything the renderer draws pulls its colour from a
Theme, so a single place decides "what does an importing row look like" and
whether colour is emitted at all.
FUTURE: the theme is meant to be user-configurable (exposed via Config) so a
user can override any of these codes. For now that wiring does not exist —
the whole app uses Theme.default (a TTY with colour) or Theme.disabled
(piped/NO_COLOR). When config support lands, add a Theme.from_config that
overlays user codes on top of default; nothing else here needs to change.
Colours are 256-colour escapes (\e[38;5;Nm) where a specific light tone is
wanted, and plain SGR codes (\e[3Xm) otherwise. A code may be the empty
string, which means "no colour" (Queued reads in the terminal's default
foreground); #colorize passes such text through untouched.
Constants
The SGR reset that ends every colourised span.
Constructors
The right theme for an output stream: the default palette, enabled only
when tty is true and NO_COLOR is unset in the environment. This is
the single gate that keeps ANSI out of non-terminal output.
The default palette with colour off — for piped/--once/NO_COLOR
output and for pure width-accounting in specs (plain glyphs, no ANSI).
Instance methods
Progress-bar cell glyphs. Both default to █ (U+2588 FULL BLOCK) so the
bar is a solid two-tone run distinguished only by colour — the most
font-portable choice. They are separate fields so the empty cell can later
be switched to a shade glyph (░/▒) in one place; the bar renderer reads
the glyphs from here rather than hardcoding them.
Wraps text in code + RESET when colour is enabled and code is
non-empty; otherwise returns text unchanged. Because it only ever adds
escape sequences around the text, the visible width is never altered —
callers can lay out on plain text and colourise afterward.
Whether colour is emitted at all. When false every #colorize call returns
its text bare, so no ANSI leaks into a pipe, a file, or a NO_COLOR session.
The status-label colour code for row: any warning/error row (or the
Failed state) is red, overriding the per-state colour; otherwise the
colour follows the normalized State. state defaults to row.state but
may be the reclassified display state (e.g. a season-pack row shown pending).