aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2005-09-24 23:20:46 +0000
committerDan Nicolaescu2005-09-24 23:20:46 +0000
commit08c583dbd17a8cf8db889402a57f4aef8803ff17 (patch)
tree67d2be1b92195bf3e415042c364a4031f94933f1
parent836c8f066c86d0511a25f4bf926d5cfed1e3a3ef (diff)
downloademacs-08c583dbd17a8cf8db889402a57f4aef8803ff17.tar.gz
emacs-08c583dbd17a8cf8db889402a57f4aef8803ff17.zip
(rxvt-register-default-colors): Add support for 255
color rxvt terminals by using the code xterm.el used to use before 2005-04-09 in order to match the colors used by rxvt.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/term/rxvt.el85
2 files changed, 64 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 96091669512..54b224c232d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12005-09-24 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * term/rxvt.el (rxvt-register-default-colors): Add support for 255
4 color rxvt terminals by using the code xterm.el used to use before
5 2005-04-09 in order to match the colors used by rxvt.
6
12005-09-24 Emanuele Giaquinta <emanuele.giaquinta@gmail.com> (tiny change) 72005-09-24 Emanuele Giaquinta <emanuele.giaquinta@gmail.com> (tiny change)
2 8
3 * term/rxvt.el (rxvt-register-default-colors): Add support for 88 9 * term/rxvt.el (rxvt-register-default-colors): Add support for 88
diff --git a/lisp/term/rxvt.el b/lisp/term/rxvt.el
index 05cd854f224..8337d8ddb4a 100644
--- a/lisp/term/rxvt.el
+++ b/lisp/term/rxvt.el
@@ -210,36 +210,67 @@ for the currently selected frame."
210 (setq colors (cdr colors) 210 (setq colors (cdr colors)
211 color (car colors) 211 color (car colors)
212 ncolors (1- ncolors))) 212 ncolors (1- ncolors)))
213 (when (and (> ncolors 0) (= ncolors 72)) ; rxvt-unicode 213 (when (> ncolors 0)
214 ;; 64 non-gray colors 214 (cond
215 (let ((levels '(0 139 205 255)) 215 ((= ncolors 240) ; 256-color rxvt
216 (r 0) (g 0) (b 0)) 216 ;; 216 non-gray colors first
217 (while (> ncolors 8) 217 (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)))))
218 (tty-color-define (format "color-%d" (- 88 ncolors)) 269 (tty-color-define (format "color-%d" (- 88 ncolors))
219 (- 88 ncolors) 270 (- 88 ncolors)
220 (mapcar 'rxvt-rgb-convert-to-16bit 271 (list color color color))
221 (list (nth r levels)
222 (nth g levels)
223 (nth b levels))))
224 (setq b (1+ b))
225 (if (> b 3)
226 (setq g (1+ g)
227 b 0))
228 (if (> g 3)
229 (setq r (1+ r)
230 g 0))
231 (setq ncolors (1- ncolors)))) 272 (setq ncolors (1- ncolors))))
232 ;; Now the 8 gray colors 273 (t (error "Unsupported number of rxvt colors (%d)" (+ 16 ncolors)))))
233 (while (> ncolors 0)
234 (setq color (rxvt-rgb-convert-to-16bit
235 (floor
236 (if (= ncolors 8)
237 46.36363636
238 (+ (* (- 8 ncolors) 23.18181818) 69.54545454)))))
239 (tty-color-define (format "color-%d" (- 88 ncolors))
240 (- 88 ncolors)
241 (list color color color))
242 (setq ncolors (1- ncolors))))
243 ;; Modifying color mappings means realized faces don't use the 274 ;; Modifying color mappings means realized faces don't use the
244 ;; right colors, so clear them. 275 ;; right colors, so clear them.
245 (clear-face-cache))) 276 (clear-face-cache)))