]> code.delx.au - gnu-emacs/blobdiff - lisp/term/tty-colors.el
Update copyright year to 2015
[gnu-emacs] / lisp / term / tty-colors.el
index aae02bec1c4cd5ada126fd1451cbff6586cb54e4..98108ce63568821e3b80b6961475521c2d078357 100644 (file)
@@ -1,10 +1,9 @@
 ;;; tty-colors.el --- color support for character terminals
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: terminals, faces
 
 ;; This file is part of GNU Emacs.
 ;; color.
 
 ;; `tty-defined-color-alist' is created at startup by calling the
-;; function `tty-color-define', defined below, 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'.
-;; 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 the
-;; beginning of lisp/term/pc-win.el.
+;; 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.
 
 ;;; Code:
 
-(defvar msdos-color-values)
-
 ;; The following list is taken from rgb.txt distributed with X.
 ;;
 ;; WARNING: Some colors, such as "lightred", do not appear in this
@@ -77,7 +76,7 @@
 ;; defined for the MS-DOS and MS-Windows consoles, because the users
 ;; on those systems expect these colors to be available.
 ;;
-;; For these reasons, package maintaners are advised NOT to use color
+;; For these reasons, package maintainers are advised NOT to use color
 ;; names such as "lightred" or "lightblue", because they will have
 ;; different effect on different displays.  Instead, use "red1" and
 ;; "blue1", respectively.
@@ -86,7 +85,7 @@
 ;; from the standard 8-bit X definitions (so the upper and lower bytes
 ;; of each value are actually identical).
 ;;
-(defvar color-name-rgb-alist
+(defconst color-name-rgb-alist
   '(("snow"            65535 64250 64250)
     ("ghostwhite"      63736 63736 65535)
     ("whitesmoke"      62965 62965 62965)
     ("lightgreen"      37008 61166 37008))
   "An alist of X color names and associated 16-bit RGB values.")
 
-(defvar tty-standard-colors
+(defconst tty-standard-colors
   '(("black"   0     0     0     0)
     ("red"     1 65535     0     0)
     ("green"   2     0 65535     0)
   "An alist of 8 standard tty colors, their indices and RGB values.")
 
 ;; This is used by term.c
-(defvar tty-color-mode-alist
+(defconst tty-color-mode-alist
   '((never . -1)
     (no . -1)
     (default . 0)
     (yes . 8))
   "An alist of supported standard tty color modes and their aliases.")
 
-(defvar tty-defined-color-alist nil
-  "An alist of defined terminal colors and their RGB values.
-
-See the docstring of `tty-color-alist' for the details.")
-
-(defun tty-color-alist (&optional frame)
+(defun tty-color-alist (&optional _frame)
   "Return an alist of colors supported by FRAME's terminal.
 FRAME defaults to the selected frame.
 Each element of the returned alist is of the form:
\(NAME INDEX R G B\)
(NAME INDEX R G B)
 where NAME is the name of the color, a string;
 INDEX is the index of this color to be sent to the terminal driver
 when the color should be displayed; it is typically a small integer;
@@ -791,10 +785,10 @@ color."
 
 (defun tty-modify-color-alist (elt &optional frame)
   "Put the association ELT into the alist of terminal colors for FRAME.
-ELT should be of the form  \(NAME INDEX R G B\) (see `tty-color-alist'
+ELT should be of the form  (NAME INDEX R G B) (see `tty-color-alist'
 for details).
 If the association for NAME already exists in the color alist, it is
-modified to specify \(INDEX R G B\) as its cdr.  Otherwise, ELT is
+modified to specify (INDEX R G B) as its cdr.  Otherwise, ELT is
 appended to the end of the color alist.
 If FRAME is unspecified or nil, it defaults to the selected frame.
 Value is the modified color alist for FRAME."
@@ -811,9 +805,7 @@ Value is the modified color alist for FRAME."
 
 (defun tty-register-default-colors ()
   "Register the default set of colors for a character terminal."
-  (let* ((colors (cond ((eq window-system 'pc)
-                       msdos-color-values)
-                      (t tty-standard-colors)))
+  (let* ((colors tty-standard-colors)
         (color (car colors)))
     (while colors
       (tty-color-define (car color) (cadr color) (cddr color))
@@ -848,7 +840,7 @@ If FRAME is not specified or is nil, it defaults to the selected frame."
   (tty-modify-color-alist
    (append (list (tty-color-canonicalize name) index) rgb) frame))
 
-(defun tty-color-clear (&optional frame)
+(defun tty-color-clear (&optional _frame)
   "Clear the list of supported tty colors for frame FRAME.
 If FRAME is unspecified or nil, it defaults to the selected frame."
   (setq tty-defined-color-alist nil))
@@ -864,7 +856,7 @@ of gray, thus the name."
 
 (defun tty-color-approximate (rgb &optional frame)
   "Find the color in `tty-color-alist' that best approximates RGB.
-Value is a list of the form \(NAME INDEX R G B\).
+Value is a list of the form (NAME INDEX R G B).
 The argument RGB should be an rgb value, that is, a list of three
 integers in the 0..65535 range.
 FRAME defaults to the selected frame."
@@ -989,7 +981,7 @@ If FRAME is unspecified or nil, it defaults to the selected frame."
   "Given a numeric index of a tty color, return its description.
 
 FRAME, if unspecified or nil, defaults to the selected frame.
-Value is a list of the form \(NAME INDEX R G B\)."
+Value is a list of the form (NAME INDEX R G B)."
   (and idx
        (let ((colors (tty-color-alist frame))
             desc found)
@@ -1005,14 +997,14 @@ Value is a list of the form \(NAME INDEX R G B\)."
 
 If COLOR is not directly supported by the display, return the RGB
 values for a supported color that is its best approximation.
-The value is a list of integer RGB values--\(RED GREEN BLUE\).
+The value is a list of integer RGB values--(RED GREEN BLUE).
 These values range from 0 to 65535; white is (65535 65535 65535).
 If FRAME is omitted or nil, use the selected frame."
   (cddr (tty-color-desc color frame)))
 
 (defun tty-color-desc (color &optional frame)
   "Return the description of the color COLOR for a character terminal.
-Value is a list of the form \(NAME INDEX R G B\).  The returned NAME or
+Value is a list of the form (NAME INDEX R G B).  The returned NAME or
 RGB value may not be the same as the argument COLOR, because the latter
 might need to be approximated if it is not supported directly."
   (and (stringp color)
@@ -1041,5 +1033,4 @@ A color is considered gray if the 3 components of its RGB value are equal."
       (setq colors (cdr colors)))
     count))
 
-;; arch-tag: 84d5c3ef-ae22-4754-99ac-e6350c0967ae
 ;;; tty-colors.el ends here