unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* support for rxvt-unicode in rxvt.el
@ 2005-09-21 13:24 Emanuele Giaquinta
  2005-09-21 13:52 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Emanuele Giaquinta @ 2005-09-21 13:24 UTC (permalink / raw)


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)))

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

end of thread, other threads:[~2005-09-25  0:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-21 13:24 support for rxvt-unicode in rxvt.el Emanuele Giaquinta
2005-09-21 13:52 ` Stefan Monnier
2005-09-21 14:03   ` Emanuele Giaquinta
2005-09-21 14:26 ` Dan Nicolaescu
2005-09-21 14:35   ` Emanuele Giaquinta
2005-09-21 14:50     ` Dan Nicolaescu
2005-09-21 14:58       ` Emanuele Giaquinta
2005-09-21 16:30         ` Dan Nicolaescu
2005-09-21 16:29 ` Dan Nicolaescu
2005-09-21 16:43   ` Emanuele Giaquinta
2005-09-21 17:25     ` Stefan Monnier
2005-09-21 19:54       ` Emanuele Giaquinta
2005-09-21 21:02         ` Dan Nicolaescu
2005-09-22  8:01           ` Emanuele Giaquinta
2005-09-24 23:28             ` Dan Nicolaescu
2005-09-25  0:23               ` Emanuele Giaquinta
2005-09-21 21:38         ` Andreas Schwab

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).