changeset 27568:fd817cff1000

(tty-color-gray-shades): New function.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 02 Feb 2000 11:33:01 +0000
parents be414098ef2e
children c34a61cbfbf6
files lisp/term/tty-colors.el
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/term/tty-colors.el	Wed Feb 02 07:06:26 2000 +0000
+++ b/lisp/term/tty-colors.el	Wed Feb 02 11:33:01 2000 +0000
@@ -956,3 +956,22 @@
 the latter might need to be approximated if it is not supported directly."
   (let ((idx (tty-color-translate color frame)))
     (tty-color-by-index idx frame)))
+
+(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 (eq r g) (eq g b)
+	   (setq count (1+ count)))
+      (setq colors (cdr colors)))
+    count))