Xterm 256 colors

From Mudpedia
Jump to: navigation, search
Xterm 256 colors.png

Support for 256 colors was added to xterm in 1999 by its maintainer Thomas Dickey, using a patch created by Todd Larason. It's an extension to the ANSI colors standard using a compatible format and has been adopted by many terminal emulators and MUD clients.

To send an xterm 256 color foreground color one must print "\e[38;5;#m" where # is a number between 0 and 255. For background colors one must print "\e[48;5;#m" where # behaves in the same manner as foreground colors.


System Colors

A value between 0 and 7 is used for the traditional 8 system colors in normal intensity. A value between 8 and 15 is used for the 8 system colors in bright intensity.

RGB Colors

A value between 16 and 231 is used for RGB colors with each color having 6 intensities. Red has a value between 0 and 5 multiplied by 36, Green has a value between 0 and 5 multiplied by 6, and Blue has a value between 0 and 5.

Grayscale Colors

A value between 232 and 255 is used for a 24 value grayscale.

8 to 24 bit color conversion

To display xterm RGB colors as 24 bit RGB colors the following values are suggested for the 6 intensities: 0x00, 0x5F, 0x87, 0xAF, 0xD7, and 0xFF. For the grayscale start out at 0x08 for value 232 and add 10 for each increment, which gives 0xee for value 255. For system colors use 0x00 and 0xC0 for normal intensities, and 0x80 and 0xFF for bright intensities.


There is no universal standard for the detection or negotiation of 256 color support. The following generic methods exist:

  • By using the TTYPE TELNET option and checking for a terminal emulator or mud client known to support 256 colors, such as xterm.
  • By using the TTYPE TELNET option and checking for the -256color suffix, such as screen-256color. Acknowledge the -color suffix means the terminal only supports ANSI colors and not 256 colors, such as xterm-color.
  • By using the TTYPE TELNET option and checking for the MTTS extension to detect 256 color support.
  • By using the MSDP TELNET option and checking if the client set the XTERM_256_COLORS variable to 1.

Client support

The following client versions introduced xterm 256 colors. Earlier versions may display incorrect information or suffer from buggy implementations.

Apple Terminal Mac OS X 10.7 (20th July 2011). Use TTYPE and check for a "-256color" suffix.
Atlantis Version (7th August 2010).[1] There is currently no way to detect the version.
BlowTorch Test version 4.[2] Use TTYPE and check for a "-256color" suffix on the third query.
CMUD Version 3.04 (6th March 2009).[3] Use MXP to query the version.
KildClient Version 2.2.0.(19th September 2005)[4] It's unknown if you can detect the version.
Mudlet Version Beta 15 (29th September 2009).[5] Use TTYPE, and only enable for 1.1 or later.[6]
MUSHclient Version 4.02 (8th April 2007).[7] Use MXP to query the version.
PuTTY Stable version 0.58. (5th April 2005)[8] First identify PuTTY, then use TTYPE, checking for "xterm" on the first query.
TinTin++ TinTin++ 2.00.4 (24th October 2010)[9] Use TTYPE and check for "xterm" or a "-256color" suffix on the second query, or (as of 2.00.7) an MTTS prefix on the third query.


See also

Personal tools