/[emacs]/emacs/lisp/term/rxvt.el
ViewVC logotype

Diff of /emacs/lisp/term/rxvt.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by dann, Sat Sep 24 23:10:01 2005 UTC revision 1.14 by dann, Sat Sep 24 23:20:45 2005 UTC
# Line 210  for the currently selected frame." Line 210  for the currently selected frame."
210        (setq colors (cdr colors)        (setq colors (cdr colors)
211              color (car colors)              color (car colors)
212              ncolors (1- ncolors)))              ncolors (1- ncolors)))
213      (when (and (> ncolors 0) (= ncolors 72))  ; rxvt-unicode      (when (> ncolors 0)
214        ;; 64 non-gray colors        (cond
215        (let ((levels '(0 139 205 255))         ((= ncolors 240)                 ; 256-color rxvt
216              (r 0) (g 0) (b 0))          ;; 216 non-gray colors first
217          (while (> ncolors 8)          (let ((r 0) (g 0) (b 0))
218              (while (> ncolors 24)
219                ;; This and other formulae taken from 256colres.pl and
220                ;; 88colres.pl in the xterm distribution.
221                (tty-color-define (format "color-%d" (- 256 ncolors))
222                                  (- 256 ncolors)
223                                  (mapcar 'rxvt-rgb-convert-to-16bit
224                                          (list (round (* r 42.5))
225                                                (round (* g 42.5))
226                                                (round (* b 42.5)))))
227                (setq b (1+ b))
228                (if (> b 5)
229                    (setq g (1+ g)
230                          b 0))
231                (if (> g 5)
232                    (setq r (1+ r)
233                          g 0))
234                (setq ncolors (1- ncolors))))
235            ;; Now the 24 gray colors
236            (while (> ncolors 0)
237              (setq color (rxvt-rgb-convert-to-16bit (+ 8 (* (- 24 ncolors) 10))))
238              (tty-color-define (format "color-%d" (- 256 ncolors))
239                                (- 256 ncolors)
240                                (list color color color))
241              (setq ncolors (1- ncolors))))
242          
243           ((and (> ncolors 0) (= ncolors 72)) ; rxvt-unicode
244            ;; 64 non-gray colors
245            (let ((levels '(0 139 205 255))
246                  (r 0) (g 0) (b 0))
247              (while (> ncolors 8)
248                (tty-color-define (format "color-%d" (- 88 ncolors))
249                                  (- 88 ncolors)
250                                  (mapcar 'rxvt-rgb-convert-to-16bit
251                                          (list (nth r levels)
252                                                (nth g levels)
253                                                (nth b levels))))
254                (setq b (1+ b))
255                (if (> b 3)
256                    (setq g (1+ g)
257                          b 0))
258                (if (> g 3)
259                    (setq r (1+ r)
260                          g 0))
261                (setq ncolors (1- ncolors))))
262            ;; Now the 8 gray colors
263            (while (> ncolors 0)
264              (setq color (rxvt-rgb-convert-to-16bit
265                           (floor
266                            (if (= ncolors 8)
267                                46.36363636
268                              (+ (* (- 8 ncolors) 23.18181818) 69.54545454)))))
269            (tty-color-define (format "color-%d" (- 88 ncolors))            (tty-color-define (format "color-%d" (- 88 ncolors))
270                              (- 88 ncolors)                              (- 88 ncolors)
271                              (mapcar 'rxvt-rgb-convert-to-16bit                              (list color color color))
                                     (list (nth r levels)  
                                           (nth g levels)  
                                           (nth b levels))))  
           (setq b (1+ b))  
           (if (> b 3)  
               (setq g (1+ g)  
                     b 0))  
           (if (> g 3)  
               (setq r (1+ r)  
                     g 0))  
272            (setq ncolors (1- ncolors))))            (setq ncolors (1- ncolors))))
273        ;; Now the 8 gray colors         (t (error "Unsupported number of rxvt colors (%d)" (+ 16 ncolors)))))
       (while (> ncolors 0)  
         (setq color (rxvt-rgb-convert-to-16bit  
                      (floor  
                       (if (= ncolors 8)  
                           46.36363636  
                         (+ (* (- 8 ncolors) 23.18181818) 69.54545454)))))  
         (tty-color-define (format "color-%d" (- 88 ncolors))  
                           (- 88 ncolors)  
                           (list color color color))  
         (setq ncolors (1- ncolors))))  
274      ;; Modifying color mappings means realized faces don't use the      ;; Modifying color mappings means realized faces don't use the
275      ;; right colors, so clear them.      ;; right colors, so clear them.
276      (clear-face-cache)))      (clear-face-cache)))

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26