OSC color palette

From Mudpedia
Jump to: navigation, search

The OSC color palette is an extension to the ANSI color standard, documented in the Linux console manual as early as 1996. Support has been added by a handful of terminal emulators, most notably xterm. The extension allows changing the default 16 ANSI colors with a 24 bit color value in hexadecimal notation.

To send an OSC color palette code one must print \e]P followed by 1 hexadecimal number indicating one of the 16 ANSI colors, followed by 6 hexadecimal numbers to set a corresponding RGB value. Colors can be reset to their default by printing \e]R. The terminal's default foreground and background color cannot be changed.

Default Ansi Colors
Value 0 1 2 3 4 5 6 7 8 9 A B C D E F
Default Black Red Green Yellow Blue Magenta Cyan White Black Red Green Yellow Blue Magenta Cyan White

Emulation

The default dim blue ANSI color is hard to read on a black background. To set it to a lighter shade of blue one would print "\e]P43333BB", and to display the updated color one would print "\e[22;34m".

When changing one of the 16 ANSI colors on an xterm terminal emulator, all previous instances of that color will be updated as well. If one were to print "\e[22;34m \e]P40000FF hello \e\P4FF0000 world" the phrase "hello world" would be printed in all red, rather than "hello" in blue, and "world" in red.

The OSC color palette remains useful to change the brightness of colors for people who are visually impaired or reading at night.

See Also

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox