all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* supporting more faces on 256 colors xterms
@ 2004-02-08  4:13 Dan Nicolaescu
  2004-02-08  6:08 ` Eli Zaretskii
  2004-02-09  9:38 ` Richard Stallman
  0 siblings, 2 replies; 23+ messages in thread
From: Dan Nicolaescu @ 2004-02-08  4:13 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2004-06-05 22:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-08  4:13 supporting more faces on 256 colors xterms Dan Nicolaescu
2004-02-08  6:08 ` Eli Zaretskii
2004-02-08  8:15   ` Dan Nicolaescu
2004-02-08 13:45     ` Andreas Schwab
2004-02-08 18:24       ` Eli Zaretskii
2004-02-08 19:11         ` Andreas Schwab
2004-02-08 23:19           ` Miles Bader
2004-02-08 23:52         ` Dan Nicolaescu
2004-02-09  6:03           ` Eli Zaretskii
2004-02-12 22:13             ` Dan Nicolaescu
2004-02-13  8:57               ` Eli Zaretskii
2004-02-13 20:29                 ` Dan Nicolaescu
2004-02-14 12:15                   ` Eli Zaretskii
2004-02-17 20:30                     ` Dan Nicolaescu
2004-02-13  9:02               ` Eli Zaretskii
2004-06-04 19:42               ` Juri Linkov
2004-06-04 21:14                 ` Dan Nicolaescu
2004-06-04 23:12                   ` Juri Linkov
2004-06-05 22:50                 ` Richard Stallman
2004-02-08 18:35     ` Eli Zaretskii
2004-02-09  9:38 ` Richard Stallman
2004-02-12 18:40   ` small grep.el fix Dan Nicolaescu
2004-02-15 13:13     ` Thien-Thi Nguyen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.