Skip to main content

Module ansi

Module ansi 

Source
Expand description

Minimal SGR rendering of theme styles for oomtop theme preview (the TUI uses ratatui instead). Colors degrade truecolor → 256 → 16 → none exactly like the TUI (UX §12.1.5); default and missing colors emit nothing, so the terminal’s own foreground/background show through.

Constants§

RESET

Functions§

color_code
SGR parameter(s) for one color, or None (terminal default / unsupported at this depth).
paint
text wrapped in the style (no escape codes at all for a plain style).
rgb_to_16
Nearest of the 16 ANSI colors.
rgb_to_256
Nearest xterm-256 index (6×6×6 cube or the 24-step gray ramp).
sgr
Full SGR start sequence for a style (“” when the style is plain). paint_bg = false drops backgrounds, as the default terminal theme and appearance.background = "terminal" require.