Guide API
Skip to main content

Module color

Module color 

Source
Expand description

Typed colour and style.

Color is a desired foreground or background colour — terminal default, a 4-bit BIOS index, an xterm-256 index, or 24-bit RGB. Style pairs a foreground and background Color with a Modifiers struct-of-bools (bold, italic, underline, …). These types describe colour in the abstract; converting an arbitrary colour to whatever a given terminal can actually display (the RGB→256→16→BIOS quantization ladder) happens in the Backend, since it only matters when colours are flushed to a real terminal.

Guide: Theming & colors.

§Turbo Vision heritage

magiblot packs fg/bg/style into a 64-bit TColorAttr whose fg/bg are each a tagged-union TColorDesired (colors.h). tvision-rs keeps that four-variant design but drops the bit-packing: a plain enum plus a struct-of-bools (deviation D5). The quantization ladder (mapcolor.cpp) moves to the Backend (deviation D6).

Structs§

Modifiers
Text-style modifiers — bold, italic, underline, and so on — as a struct-of-bools.
Style
The colour attributes of a screen cell: a foreground colour, a background colour, and a set of style modifiers.

Enums§

Color
A desired foreground or background colour.