Mercurial > emacs
annotate lisp/term/rxvt.el @ 83215:a9f716fbb9c6
Small tweaks in server.el.
* lisp/server.el: Doc updates.
(server-select-display): Remove (unused).
(server-handle-suspend-tty): Kill the client in case of errors from
process-send-string.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-255
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 10 Oct 2004 16:41:15 +0000 |
parents | 7652900ea029 |
children | 886073e54ccb |
rev | line source |
---|---|
42945 | 1 ;;; rxvt.el --- define function key sequences and standard colors for rxvt |
2 | |
3 ;; Copyright (C) 2002 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Eli Zaretskii | |
6 ;; Keywords: terminals | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
83118
7652900ea029
Fixed environment variable handling during terminal initialization.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
29 (eval-when-compile (require 'server)) |
7652900ea029
Fixed environment variable handling during terminal initialization.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
30 |
42945 | 31 ;; Set up function-key-map entries that termcap and terminfo don't know. |
32 (let ((map (make-sparse-keymap))) | |
33 (define-key map "\e[A" [up]) | |
34 (define-key map "\e[B" [down]) | |
35 (define-key map "\e[C" [right]) | |
36 (define-key map "\e[D" [left]) | |
37 (define-key map "\e[7~" [home]) | |
38 (define-key map "\e[2~" [insert]) | |
39 (define-key map "\e[3~" [delete]) | |
40 (define-key map "\e[4~" [select]) | |
41 (define-key map "\e[5~" [prior]) | |
42 (define-key map "\e[6~" [next]) | |
43 (define-key map "\e[11~" [f1]) | |
44 (define-key map "\e[12~" [f2]) | |
45 (define-key map "\e[13~" [f3]) | |
46 (define-key map "\e[14~" [f4]) | |
47 (define-key map "\e[15~" [f5]) | |
48 (define-key map "\e[17~" [f6]) | |
49 (define-key map "\e[18~" [f7]) | |
50 (define-key map "\e[19~" [f8]) | |
51 (define-key map "\e[20~" [f9]) | |
52 (define-key map "\e[21~" [f10]) | |
53 (define-key map "\e[23~" [f11]) | |
54 (define-key map "\e[24~" [f12]) | |
55 (define-key map "\e[29~" [print]) | |
56 | |
57 (define-key map "\e[11^" [C-f1]) | |
58 (define-key map "\e[12^" [C-f2]) | |
59 (define-key map "\e[13^" [C-f3]) | |
60 (define-key map "\e[14^" [C-f4]) | |
61 (define-key map "\e[15^" [C-f5]) | |
62 (define-key map "\e[17^" [C-f6]) | |
63 (define-key map "\e[18^" [C-f7]) | |
64 (define-key map "\e[19^" [C-f8]) | |
65 (define-key map "\e[20^" [C-f9]) | |
66 (define-key map "\e[21^" [C-f10]) | |
67 (define-key map "\e[23^" [C-f11]) | |
68 (define-key map "\e[24^" [C-f12]) | |
69 | |
70 (define-key map "\e[29~" [print]) | |
71 | |
72 (define-key map "\e[2;2~" [S-insert]) | |
73 (define-key map "\e[3$" [S-delete]) | |
74 | |
75 (define-key map "\e[2^" [C-insert]) | |
76 (define-key map "\e[3^" [C-delete]) | |
77 (define-key map "\e[5^" [C-prior]) | |
78 (define-key map "\e[6^" [C-next]) | |
79 (define-key map "\eOd" [C-left]) | |
80 (define-key map "\eOc" [C-right]) | |
81 (define-key map "\eOa" [C-up]) | |
82 (define-key map "\eOb" [C-down]) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42962
diff
changeset
|
83 |
42945 | 84 (define-key map "\e[5$" [S-prior]) |
85 (define-key map "\e[6$" [S-next]) | |
86 (define-key map "\e[8$" [S-end]) | |
87 (define-key map "\e[7$" [S-home]) | |
88 (define-key map "\e[d" [S-left]) | |
89 (define-key map "\e[c" [S-right]) | |
90 (define-key map "\e[a" [S-up]) | |
91 (define-key map "\e[b" [S-down]) | |
92 | |
93 ;; Use inheritance to let the main keymap override those defaults. | |
94 ;; This way we don't override terminfo-derived settings or settings | |
95 ;; made in the .emacs file. | |
96 (set-keymap-parent map (keymap-parent function-key-map)) | |
97 (set-keymap-parent function-key-map map)) | |
98 | |
99 ;; Set up colors, for those versions of rxvt that support it. | |
100 (defvar rxvt-standard-colors | |
101 ;; The names of the colors in the comments taken from the rxvt.1 man | |
42962 | 102 ;; page; the corresponding RGB values--from rgb.txt. |
42945 | 103 '(("black" 0 ( 0 0 0)) ; black |
104 ("red" 1 (205 0 0)) ; red3 | |
105 ("green" 2 ( 0 205 0)) ; green3 | |
106 ("yellow" 3 (205 205 0)) ; yellow3 | |
107 ("blue" 4 ( 0 0 205)) ; blue3 | |
108 ("magenta" 5 (205 0 205)) ; magenta3 | |
109 ("cyan" 6 ( 0 205 205)) ; cyan3 | |
110 ("white" 7 (250 235 215)) ; AntiqueWhite | |
111 ("brightblack" 8 ( 64 64 64)) ; gray25 | |
112 ("brightred" 9 (255 0 0)) ; red | |
113 ("brightgreen" 10 ( 0 255 0)) ; green | |
114 ("brightyellow" 11 (255 255 0)) ; yellow | |
115 ("brightblue" 12 ( 0 0 255)) ; blue | |
116 ("brightmagenta" 13 (255 0 255)) ; magenta | |
117 ("brightcyan" 14 ( 0 255 255)) ; cyan | |
118 ("brightwhite" 15 (255 255 255))) ; white | |
119 "Names of 16 standard rxvt colors, their numbers, and RGB values.") | |
120 | |
121 (defun rxvt-rgb-convert-to-16bit (prim) | |
122 "Convert an 8-bit primary color value PRIM to a corresponding 16-bit value." | |
123 (min 65535 (round (* (/ prim 255.0) 65535.0)))) | |
124 | |
125 (defun rxvt-register-default-colors () | |
126 "Register the default set of colors for rxvt or compatible emulator. | |
127 | |
128 This function registers the number of colors returned by `display-color-cells' | |
129 for the currently selected frame." | |
130 (let* ((ncolors (display-color-cells)) | |
131 (colors rxvt-standard-colors) | |
132 (color (car colors))) | |
133 (if (> ncolors 0) | |
134 ;; Clear the 8 default tty colors registered by startup.el | |
135 (tty-color-clear)) | |
136 ;; Only register as many colors as are supported by the display. | |
137 (while (and (> ncolors 0) colors) | |
138 (tty-color-define (car color) (cadr color) | |
139 (mapcar 'rxvt-rgb-convert-to-16bit | |
140 (car (cddr color)))) | |
141 (setq colors (cdr colors) | |
142 color (car colors) | |
143 ncolors (1- ncolors))) | |
144 ;; Modifying color mappings means realized faces don't use the | |
145 ;; right colors, so clear them. | |
146 (clear-face-cache))) | |
147 | |
148 ;; rxvt puts the default colors into an environment variable | |
149 ;; COLORFGBG. We use this to set the background mode in a more | |
150 ;; intelligent way than the default guesswork in startup.el. | |
151 (defun rxvt-set-background-mode () | |
152 "Set background mode as appropriate for the default rxvt colors." | |
83118
7652900ea029
Fixed environment variable handling during terminal initialization.
Karoly Lorentey <lorentey@elte.hu>
parents:
52401
diff
changeset
|
153 (let ((fgbg (server-getenv "COLORFGBG")) |
42945 | 154 bg rgb) |
155 (setq frame-background-mode 'light) ; default | |
156 (when (and fgbg | |
157 (string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg)) | |
158 (setq bg (string-to-number (substring fgbg (match-beginning 1)))) | |
159 ;; The next line assumes that rxvt-standard-colors are ordered | |
160 ;; by the color index in the ascending order! | |
161 (setq rgb (car (cddr (nth bg rxvt-standard-colors)))) | |
162 ;; See the commentary in frame-set-background-mode about the | |
163 ;; computation below. | |
164 (if (< (apply '+ rgb) | |
165 ;; The following line assumes that white is the 15th | |
166 ;; color in rxvt-standard-colors. | |
167 (* (apply '+ (car (cddr (nth 15 rxvt-standard-colors)))) 0.6)) | |
168 (setq frame-background-mode 'dark))) | |
169 (frame-set-background-mode (selected-frame)))) | |
170 | |
171 ;; Do it! | |
172 (rxvt-register-default-colors) | |
173 (rxvt-set-background-mode) | |
174 ;; This recomputes all the default faces given the colors we've just set up. | |
175 (tty-set-up-initial-frame-faces) | |
176 | |
52401 | 177 ;;; arch-tag: 20cf2fb6-6318-4bab-9dbf-1d15048f2257 |
42945 | 178 ;;; rxvt.el ends here |