emacs-devel
[Top][All Lists]
Advanced

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

support for rxvt-unicode in rxvt.el


From: Emanuele Giaquinta
Subject: support for rxvt-unicode in rxvt.el
Date: Wed, 21 Sep 2005 15:24:31 +0200
User-agent: Mutt/1.5.9i

The patch that follows modifies rxvt.el and creates a 'rxvt-unicode.el'
file to add support for the rxvt-unicode terminal emulator.  This
terminal has its own terminfo description, and supports 88 colors (the
4x4x4 cube of xterm compiled with --enable-88-color).  The differences
from rxvt, at this level, are in the escape sequences for the cursor
keys (the same ones xterm uses in application mode) and in the number of
supported colors (I've taken the code to generate them from xterm.el).

--- rxvt-unicode.el     1970-01-01 01:00:00.000000000 +0100
+++ rxvt-unicode.el     2005-09-21 14:21:55.000000000 +0200
@@ -0,0 +1,2 @@
+(defun terminal-init-rxvt-unicode ()
+  (load "term/rxvt" nil t))
--- rxvt.el     2005-09-21 13:02:55.000000000 +0200
+++ rxvt.el     2005-09-21 14:47:44.000000000 +0200
@@ -146,13 +146,19 @@
     (define-key map "\e[3$" [S-delete])
     (define-key map "\e[5$" [S-prior])
     (define-key map "\e[6$" [S-next])
-    (define-key map "\e[8$" [S-end])
     (define-key map "\e[7$" [S-home])
+    (define-key map "\e[8$" [S-end])
     (define-key map "\e[d" [S-left])
     (define-key map "\e[c" [S-right])
     (define-key map "\e[a" [S-up])
     (define-key map "\e[b" [S-down])
 
+    ;; rxvt-unicode uses these key definitions for the cursor keys
+    (define-key map "\eOA" [up])
+    (define-key map "\eOB" [down])
+    (define-key map "\eOC" [right])
+    (define-key map "\eOD" [left])
+
     ;; Use inheritance to let the main keymap override those defaults.
     ;; This way we don't override terminfo-derived settings or settings
     ;; made in the .emacs file.
@@ -210,6 +216,36 @@
       (setq colors (cdr colors)
            color (car colors)
            ncolors (1- ncolors)))
+    (when (and (> ncolors 0) (= ncolors 72))  ; rxvt-unicode
+      ;; 64 non-gray colors
+      (let ((levels '(0 139 205 255))
+           (r 0) (g 0) (b 0))
+       (while (> ncolors 8)
+         (tty-color-define (format "color-%d" (- 88 ncolors))
+                           (- 88 ncolors)
+                           (mapcar 'rxvt-rgb-convert-to-16bit
+                                   (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))
+         (setq ncolors (1- ncolors))))
+      ;; Now the 8 gray colors
+      (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))))
     ;; Modifying color mappings means realized faces don't use the
     ;; right colors, so clear them.
     (clear-face-cache)))




reply via email to

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