ANSI Colors |
ANSI • About • Codes • Palette • Support • Detection • Links ANSI 256COLOR TRUECOLOR VT100 XTERM |
![]() |
ANSI escape codes are a standard for in-band signaling to control the cursor location, color, and other options on text terminals. The ANSI x3.64 standard was released in 1979 and later updated by the 5th edition ECMA-48 standard in 1991, ISO/IEC 6429 in 1992, and ISO-8613-3 in 1995. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ANSI escape codes are started using \e[ and contain numeric codes separated by semicolons. The escape code is terminated with an 'm'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ANSI Color Codes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ANSI Color Escape Sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ANSI Color Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ANSI Color RGB Values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The 24 bit RGB values used for the 16 ANSI colors differ greatly for each terminal implementation. Below is a system that is both consistent and 12 bit compatible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OSC Color Palette | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The OSC color palette is an extension to the ANSI color standard using a modification of the Operating System Command sequence, 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 using a 24 bit RGB 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. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The default 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". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ANSI color support in MUD clients is generally weak. Universally supported codes are 0 and 1, as well as code 30-37. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Terminal emulators generally support background colors as well as code 4, 5, 7, 9, and 22. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Detection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There is no universal standard for the detection or negotiation of ANSI color support. The following methods exist: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If you want a link added, you can email me at mudclient@gmail.com. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Clients supporting ANSI color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Virtually all MUD clients and terminal emulators support ANSI color. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Codebases | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comparison of MUD codebases - Mudpedia contains a list of MUD servers with ANSI color support. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Snippets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
256 color parser - Handles ANSI 16 colors and xterm 256 colors. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||