Function: tty-color-gray-shades

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

Signature

(tty-color-gray-shades &optional DISPLAY)

Documentation

Return the number of gray colors supported by DISPLAY's terminal.

A color is considered gray if the 3 components of its RGB value are equal.

Source Code

;; Defined in /usr/src/emacs/lisp/term/tty-colors.el.gz
(defun tty-color-gray-shades (&optional display)
  "Return the number of gray colors supported by DISPLAY's terminal.
A color is considered gray if the 3 components of its RGB value are equal."
  (let* ((frame (if (framep display) display
		  ;; FIXME: this uses an arbitrary frame from DISPLAY!
		  (car (frames-on-display-list display))))
	 (colors (tty-color-alist frame))
	 (count 0)
	 desc r g b)
    (while colors
      (setq desc (cddr (car colors))
	    r (car desc)
	    g (cadr desc)
	    b (car (cddr desc)))
      (and (numberp r)
	   (eq r g) (eq g b)
	   (setq count (1+ count)))
      (setq colors (cdr colors)))
    count))