Function: tty-color-translate

tty-color-translate is a byte-compiled function defined in tty-colors.el.gz.

Signature

(tty-color-translate COLOR &optional FRAME)

Documentation

Given a color COLOR, return the index of the corresponding TTY color.

COLOR must be a string that is either the color's name, or its color triplet specification like "#RRGGBB" or "rgb:RR/GG/BB", where each primary color can be given with 1 to 4 hex digits.

If COLOR is a color name that is found among supported colors in tty-color-alist, the associated index is returned. Otherwise, the RGB values of the color, either as given by the argument or from looking up the name in color-name-rgb-alist, are used to find the supported color that is the best approximation for COLOR in the RGB space. If COLOR is neither a valid RGB specification of the color, nor a name of a color in color-name-rgb-alist, the returned value is nil.

If FRAME is unspecified or nil, it defaults to the selected frame.

Source Code

;; Defined in /usr/src/emacs/lisp/term/tty-colors.el.gz
(defun tty-color-translate (color &optional frame)
  "Given a color COLOR, return the index of the corresponding TTY color.

COLOR must be a string that is either the color's name, or its
color triplet specification like \"#RRGGBB\" or \"rgb:RR/GG/BB\",
where each primary color can be given with 1 to 4 hex digits.

If COLOR is a color name that is found among supported colors in
`tty-color-alist', the associated index is returned.  Otherwise, the
RGB values of the color, either as given by the argument or from
looking up the name in `color-name-rgb-alist', are used to find the
supported color that is the best approximation for COLOR in the RGB
space.
If COLOR is neither a valid RGB specification of the color, nor a
name of a color in `color-name-rgb-alist', the returned value is nil.

If FRAME is unspecified or nil, it defaults to the selected frame."
  (cadr (tty-color-desc color frame)))