File: tty-colors.el.html

Emacs support for colors evolved from the X Window System; color support for character-based terminals came later. Many Lisp packages use color names defined by X and assume the availability of certain functions that look up colors, convert them to pixel values, etc.

This file provides a more or less useful emulation of the X color functionality for character-based terminals, and thus relieves the rest of Emacs from including special code for this case.

Here's how it works. The support for terminal and MSDOS frames maintains an alist, called tty-defined-color-alist, which associates colors supported by the terminal driver with small integers. (These small integers are passed to the library functions which set the color, and are effectively indices of the
colors in the supported color palette.) When Emacs needs to send a
color command to the terminal, the color name is first looked up in tty-defined-color-alist. If not found, functions from this file can be used to map the color to one of the supported colors. Specifically, the X RGB values of the requested color are extracted from color-name-rgb-alist and then the supported color is found with the minimal distance in the RGB space from the requested color.

tty-defined-color-alist is created at startup by calling the function tty-register-default-colors, defined below, which in turn calls tty-color-define, passing it each supported color, its index, and its RGB values. The standard list of colors supported by many Unix color terminals, including xterm, FreeBSD, and GNU/Linux, is supplied below in tty-standard-colors. Some terminal-specific files in lisp/term define their own standard colors. If your terminal supports different or additional colors, call tty-color-define from your .emacs or site-start.el. For more-or-less standard definitions of VGA text-mode colors, see lisp/term/pc-win.el.

Defined variables (3)

color-name-rgb-alistAn alist of X color names and associated 16-bit RGB values.
tty-color-mode-alistAn alist of supported standard tty color modes and their aliases.
tty-standard-colorsAn alist of 8 standard tty colors, their indices and RGB values.

Defined functions (15)

tty-color-24bit(RGB &optional DISPLAY)
tty-color-alist(&optional FRAME)
tty-color-approximate(RGB &optional FRAME)
tty-color-by-index(IDX &optional FRAME)
tty-color-canonicalize(COLOR)
tty-color-clear(&optional FRAME)
tty-color-define(NAME INDEX &optional RGB FRAME)
tty-color-desc(COLOR &optional FRAME)
tty-color-gray-shades(&optional DISPLAY)
tty-color-off-gray-diag(R G B)
tty-color-standard-values(COLOR)
tty-color-translate(COLOR &optional FRAME)
tty-color-values(COLOR &optional FRAME)
tty-modify-color-alist(ELT &optional FRAME)
tty-register-default-colors()

Defined faces (0)