emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

supporting more faces on 256 colors xterms


From: Dan Nicolaescu
Subject: supporting more faces on 256 colors xterms
Date: Sat, 07 Feb 2004 20:13:19 -0800

Hi!

I am looking for a way to add support for faces on 256 colors xterms. 
Specifically, it would be nice to be able to have the save colors for
the standard emacs predefined faces when running on X11 or using -nw
on a 256 colors xterm. 

Eli Zaretskii suggested adding another face specifier `nrcolors>='. 
`nrcolors>=' can be used in `defface' to have common face specifications
for 256 colors xterms and color X11.

For example `font-lock-comment-face' could be changed to look like
this: 

(defface font-lock-comment-face
  '((((class color) (colornr>= 256) (background light))
     (:foreground "Firebrick"))
    (((class color) (colornr>= 256) (background dark))
     (:foreground "chocolate1"))
    (((class color) (colornr>= 8) (background light)) (:foreground "red"))
    (((class color) (colornr>= 8) (background dark)) (:foreground "red1"))
    (((class grayscale) (background light))
     (:foreground "DimGray" :weight bold :slant italic))
    (((class grayscale) (background dark))
     (:foreground "LightGray" :weight bold :slant italic))
    (t (:weight bold :slant italic)))
  "Font Lock mode face used to highlight comments."
  :group 'font-lock-highlighting-faces)


Implementing the nrcolors>= specifier needs just the following 2 line patch:
(+ some docs)

*** faces.el~   Tue Oct 14 13:20:17 2003
--- faces.el    Sat Feb  7 19:59:00 2004
*************** If FRAME is nil, the current FRAME is us
*** 1314,1319 ****
--- 1314,1321 ----
                                  (not (featurep 'motif)))
                             (and (memq 'x-toolkit options)
                                  (featurep 'x-toolkit))))
+                       ((eq req 'colornr>=)
+                        (>= (display-color-cells) (car options)))
                        ((eq req 'class)
                         (memq (frame-parameter frame 'display-type) options))
                        ((eq req 'background)

Next step would be to make xterm.el understand color names, currently
xterm.el generates color names that look like "color-XXX".

I tried to use the color names from `color-name-rgb-alist' using the
following patch:


*** xterm.el~   Tue Oct 14 13:21:55 2003
--- xterm.el    Sat Feb  7 19:27:40 2004
*************** versions of xterm."
*** 143,158 ****
        (cond
         ((= ncolors 240)       ; 256-color xterm
        ;; 216 non-gray colors first
!       (let ((r 0) (g 0) (b 0))
          (while (> ncolors 24)
            ;; This and other formulae taken from 256colres.pl and
            ;; 88colres.pl in the xterm distribution.
!           (tty-color-define (format "color-%d" (- 256 ncolors))
!                             (- 256 ncolors)
!                             (mapcar 'xterm-rgb-convert-to-16bit
!                                     (list (round (* r 42.5))
!                                           (round (* g 42.5))
!                                           (round (* b 42.5)))))
            (setq b (1+ b))
            (if (> b 5)
                (setq g (1+ g)
--- 143,164 ----
        (cond
         ((= ncolors 240)       ; 256-color xterm
        ;; 216 non-gray colors first
!       (let ((r 0) (g 0) (b 0) colortriplet colorname)
          (while (> ncolors 24)
            ;; This and other formulae taken from 256colres.pl and
            ;; 88colres.pl in the xterm distribution.
!           (setq colortriplet 
!                 (mapcar 'xterm-rgb-convert-to-16bit
!                         (list (round (* r 42.5))
!                               (round (* g 42.5))
!                               (round (* b 42.5))))
!                 colorname (car (rassoc colortriplet color-name-rgb-alist)))
!           (message "%s %s" colortriplet colorname)
!           (tty-color-define 
!            (if colorname
!                colorname 
!              (format "color-%d" (- 256 ncolors)))
!              (- 256 ncolors) colortriplet)
            (setq b (1+ b))
            (if (> b 5)
                (setq g (1+ g)

but this does not seem to work,  only "navy"  and "gray83" are found
by rassoc... 

Any advice on how to proceed with all these would be appreciated. 

I know there is another xterm mutant that supports 88 colors, that
one can be probably treated the same way as a 256 colors one. 

Thanks.

        --dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]