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 terminatorThe 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/BBBBstring.