aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/term/tty-colors.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el
index 8291ac111be..03fef2a3421 100644
--- a/lisp/term/tty-colors.el
+++ b/lisp/term/tty-colors.el
@@ -956,3 +956,22 @@ NAME is not necessarily the same string as the argument COLOR, because
956the latter might need to be approximated if it is not supported directly." 956the latter might need to be approximated if it is not supported directly."
957 (let ((idx (tty-color-translate color frame))) 957 (let ((idx (tty-color-translate color frame)))
958 (tty-color-by-index idx frame))) 958 (tty-color-by-index idx frame)))
959
960(defun tty-color-gray-shades (&optional display)
961 "Return the number of gray colors supported by DISPLAY's terminal.
962A color is considered gray if the 3 components of its RGB value are equal."
963 (let* ((frame (if (framep display) display
964 ;; FIXME: this uses an arbitrary frame from DISPLAY!
965 (car (frames-on-display-list display))))
966 (colors (tty-color-alist frame))
967 (count 0)
968 desc r g b)
969 (while colors
970 (setq desc (cddr (car colors))
971 r (car desc)
972 g (cadr desc)
973 b (car (cddr desc)))
974 (and (eq r g) (eq g b)
975 (setq count (1+ count)))
976 (setq colors (cdr colors)))
977 count))