Skip to main content

Colours and attributes

All of these are lt_attr values or produce one. See Colors and attributes for the bit layout.

Named colours​

Meaningful in LT_OUTPUT_NORMAL. LT_DEFAULT means the terminal's own colour in every mode.

ConstantValue
LT_DEFAULT0x0000
LT_BLACK0x0001
LT_RED0x0002
LT_GREEN0x0003
LT_YELLOW0x0004
LT_BLUE0x0005
LT_MAGENTA0x0006
LT_CYAN0x0007
LT_WHITE0x0008

Attribute flags​

OR these into the foreground. Attribute bits in the background are ignored.

ConstantValueEffect
LT_BOLD0x01000000bold
LT_UNDERLINE0x02000000underline
LT_REVERSE0x04000000swap foreground and background
LT_ITALIC0x08000000italic
LT_BLINK0x10000000blink
LT_DIM0x20000000faint
LT_STRIKE0x40000000strikethrough

LT_HI_BLACK​

#define LT_HI_BLACK 0x80000000u

Bit 31. Colour bits of 0 mean "terminal default". OR in LT_HI_BLACK to select real black instead: palette index 0 in palette modes, RGB 0,0,0 in truecolor. Mirrors termbox2's TB_HI_BLACK.

LT_RGB​

#define LT_RGB(r, g, b)

Packs 24-bit RGB, each channel 0 to 255, into bits 0 to 23 for LT_OUTPUT_TRUECOLOR. Each argument is masked to 8 bits.

LT_HEX​

#define LT_HEX(rgb)

Packs a 0xRRGGBB value into bits 0 to 23 for LT_OUTPUT_TRUECOLOR. The high byte is masked off, so attribute flags and the sentinel can never be set by accident. LT_HEX(0xRRGGBB) packs the same bits as LT_RGB(0xRR, 0xGG, 0xBB), and the 0x00RRGGBB value written by lt_query_color feeds straight into it.

Colour query selectors​

Arguments to lt_query_color, alongside plain palette indexes 0 to 255.

ConstantValueSelects
LT_COLOR_DEFAULT_FG-1the terminal's default foreground
LT_COLOR_DEFAULT_BG-2the terminal's default background