unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
Subject: supporting more faces on 256 colors xterms
Date: Sat, 07 Feb 2004 20:13:19 -0800	[thread overview]
Message-ID: <200402080413.i184DH6M015994@gremlin.ics.uci.edu> (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

             reply	other threads:[~2004-02-08  4:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-08  4:13 Dan Nicolaescu [this message]
2004-02-08  6:08 ` supporting more faces on 256 colors xterms 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200402080413.i184DH6M015994@gremlin.ics.uci.edu \
    --to=dann@ics.uci.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).