Skip to main content

Module color

Module color 

Source
Expand description

Default foreground, background, cursor, and indexed palette colors.

§Category

This module emits OSC color-control sequences: OSC 10/11/12 for the default text and cursor colors, OSC 4 for indexed palette entries, and OSC 104/110 through 112 for resets.

§OSC framing

All writers and byte constants in this module use the 7-bit OSC introducer and BEL terminator:

ESC ]  10 ; rgb:ffff/0000/8080  BEL
──┬──  ┬─   ─────────┬─────────  ─┬─
 OSC  code        payload       terminator

The color payload is passed through unchanged. Use xparse_rgb when a caller needs the rgb:RRRR/GGGG/BBBB form accepted by these controls.

§Mode interaction

These sequences do not require a DEC or ANSI mode to be enabled. Requests cause compatible terminals to report colors asynchronously as OSC replies.

Constants§

REQUEST_BACKGROUND_COLOR
Request the default background color: exact bytes ESC ] 11 ; ? BEL (b"\x1b]11;?\x07").
REQUEST_CURSOR_COLOR
Request the cursor color: exact bytes ESC ] 12 ; ? BEL (b"\x1b]12;?\x07").
REQUEST_FOREGROUND_COLOR
Request the default foreground color: exact bytes ESC ] 10 ; ? BEL (b"\x1b]10;?\x07").
RESET_BACKGROUND_COLOR
Reset the default background color: exact bytes ESC ] 111 BEL (b"\x1b]111\x07").
RESET_CURSOR_COLOR
Reset the cursor color: exact bytes ESC ] 112 BEL (b"\x1b]112\x07").
RESET_FOREGROUND_COLOR
Reset the default foreground color: exact bytes ESC ] 110 BEL (b"\x1b]110\x07").
RESET_PALETTE_COLORS
Reset all indexed palette colors: exact bytes ESC ] 104 BEL (b"\x1b]104\x07").

Functions§

write_request_palette_color
Request one indexed palette entry with ESC ] 4 ; <index> ; ? BEL.
write_reset_palette_color
Reset one indexed palette entry with ESC ] 104 ; <index> BEL.
write_set_background_color
Set the default text background color with ESC ] 11 ; <color> BEL.
write_set_cursor_color
Set the cursor color with ESC ] 12 ; <color> BEL.
write_set_foreground_color
Set the default text foreground color with ESC ] 10 ; <color> BEL.
write_set_palette_color
Set one indexed palette entry with ESC ] 4 ; <index> ; <color> BEL.
xparse_rgb
Format 8-bit RGB channels as an XParseColor rgb:RRRR/GGGG/BBBB string.