aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/term
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2000-02-02 11:33:01 +0000
committerEli Zaretskii <[email protected]>2000-02-02 11:33:01 +0000
commitc527e60052301753343e2d3d697c2675ab8df5d2 (patch)
treef721673f4626a9037062e63db5b8b1c7a695e425 /lisp/term
parent25660570bea4aa8fb85084e91c870e3467e87038 (diff)
(tty-color-gray-shades): New function.
Diffstat (limited to 'lisp/term')
-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 8291ac111b..03fef2a342 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
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))