Mercurial > emacs
annotate lisp/term/xterm.el @ 88257:b6d2078cce14
(rmail-header-attribute-header)
(rmail-header-keyword-header, rmail-header-get-limit): Doc.
(rmail-header-add-header): Add inhibit-point-motion-hooks and
buffer-undo-list bindings from rmail-header-set-header. I don't
know whether they are necessary, however.
(rmail-header-persist-attributes, rmail-header-set-header):
Deleted. rmail-header-add-header does what
rmail-header-set-header did, except throw an error if the header
was not found.
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Sat, 21 Jan 2006 15:27:34 +0000 |
parents | d7ddb3e565de |
children |
rev | line source |
---|---|
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
1 ;;; xterm.el --- define function key sequences and standard colors for xterm |
12159 | 2 |
88155 | 3 ;; Copyright (C) 1995, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
14170
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
4 |
12159 | 5 ;; Author: FSF |
6 ;; Keywords: terminals | |
7 | |
14170
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
9 |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
13 ;; any later version. |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
14 |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
18 ;; GNU General Public License for more details. |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
19 |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
23cc3f54e536
Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents:
12159
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
88155 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
12159 | 24 |
38431
853c3674f20a
Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14170
diff
changeset
|
25 ;;; Commentary: |
853c3674f20a
Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14170
diff
changeset
|
26 |
853c3674f20a
Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14170
diff
changeset
|
27 ;;; Code: |
12159 | 28 |
88155 | 29 (defun terminal-init-xterm () |
30 "Terminal initialization function for xterm." | |
31 ;; rxvt terminals sometimes set the TERM variable to "xterm", but | |
32 ;; rxvt's keybindings that are incompatible with xterm's. It is | |
33 ;; better in that case to use rxvt's initializion function. | |
34 (if (and (getenv "COLORTERM") | |
35 (string-match "\\`rxvt" (getenv "COLORTERM"))) | |
36 (progn | |
37 (eval-and-compile (load "term/rxvt")) | |
38 (terminal-init-rxvt)) | |
39 | |
40 ;; The terminal intialization C code file might have initialized | |
41 ;; function keys F13->F60 from the termcap/terminfo information. On | |
42 ;; a PC-style keyboard these keys correspond to | |
43 ;; MODIFIER-FUNCTION_KEY, where modifier is S-, C, A-, C-S-. The | |
44 ;; code here subsitutes the corresponding defintions in | |
45 ;; function-key-map. This substitution is needed because if a key | |
46 ;; definition if found in function-key-map, there are no further | |
47 ;; lookups in other keymaps. | |
48 (substitute-key-definition [f13] [S-f1] function-key-map) | |
49 (substitute-key-definition [f14] [S-f2] function-key-map) | |
50 (substitute-key-definition [f15] [S-f3] function-key-map) | |
51 (substitute-key-definition [f16] [S-f4] function-key-map) | |
52 (substitute-key-definition [f17] [S-f5] function-key-map) | |
53 (substitute-key-definition [f18] [S-f6] function-key-map) | |
54 (substitute-key-definition [f19] [S-f7] function-key-map) | |
55 (substitute-key-definition [f20] [S-f8] function-key-map) | |
56 (substitute-key-definition [f21] [S-f9] function-key-map) | |
57 (substitute-key-definition [f22] [S-f10] function-key-map) | |
58 (substitute-key-definition [f23] [S-f11] function-key-map) | |
59 (substitute-key-definition [f24] [S-f12] function-key-map) | |
60 | |
61 (substitute-key-definition [f25] [C-f1] function-key-map) | |
62 (substitute-key-definition [f26] [C-f2] function-key-map) | |
63 (substitute-key-definition [f27] [C-f3] function-key-map) | |
64 (substitute-key-definition [f28] [C-f4] function-key-map) | |
65 (substitute-key-definition [f29] [C-f5] function-key-map) | |
66 (substitute-key-definition [f30] [C-f6] function-key-map) | |
67 (substitute-key-definition [f31] [C-f7] function-key-map) | |
68 (substitute-key-definition [f32] [C-f8] function-key-map) | |
69 (substitute-key-definition [f33] [C-f9] function-key-map) | |
70 (substitute-key-definition [f34] [C-f10] function-key-map) | |
71 (substitute-key-definition [f35] [C-f11] function-key-map) | |
72 (substitute-key-definition [f36] [C-f12] function-key-map) | |
40694
41fcf9864c4d
(function-key-map): Add entry for `ESC [ 3 ~' -> <delete>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38431
diff
changeset
|
73 |
88155 | 74 (substitute-key-definition [f37] [C-S-f1] function-key-map) |
75 (substitute-key-definition [f38] [C-S-f2] function-key-map) | |
76 (substitute-key-definition [f39] [C-S-f3] function-key-map) | |
77 (substitute-key-definition [f40] [C-S-f4] function-key-map) | |
78 (substitute-key-definition [f41] [C-S-f5] function-key-map) | |
79 (substitute-key-definition [f42] [C-S-f6] function-key-map) | |
80 (substitute-key-definition [f43] [C-S-f7] function-key-map) | |
81 (substitute-key-definition [f44] [C-S-f8] function-key-map) | |
82 (substitute-key-definition [f45] [C-S-f9] function-key-map) | |
83 (substitute-key-definition [f46] [C-S-f10] function-key-map) | |
84 (substitute-key-definition [f47] [C-S-f11] function-key-map) | |
85 (substitute-key-definition [f48] [C-S-f12] function-key-map) | |
86 | |
87 (substitute-key-definition [f49] [A-f1] function-key-map) | |
88 (substitute-key-definition [f50] [A-f2] function-key-map) | |
89 (substitute-key-definition [f51] [A-f3] function-key-map) | |
90 (substitute-key-definition [f52] [A-f4] function-key-map) | |
91 (substitute-key-definition [f53] [A-f5] function-key-map) | |
92 (substitute-key-definition [f54] [A-f6] function-key-map) | |
93 (substitute-key-definition [f55] [A-f7] function-key-map) | |
94 (substitute-key-definition [f56] [A-f8] function-key-map) | |
95 (substitute-key-definition [f57] [A-f9] function-key-map) | |
96 (substitute-key-definition [f58] [A-f10] function-key-map) | |
97 (substitute-key-definition [f59] [A-f11] function-key-map) | |
98 (substitute-key-definition [f60] [A-f12] function-key-map) | |
99 | |
100 (let ((map (make-sparse-keymap))) | |
101 ;; xterm from X.org 6.8.2 uses these key definitions. | |
102 (define-key map "\eOP" [f1]) | |
103 (define-key map "\eOQ" [f2]) | |
104 (define-key map "\eOR" [f3]) | |
105 (define-key map "\eOS" [f4]) | |
106 (define-key map "\e[15~" [f5]) | |
107 (define-key map "\e[17~" [f6]) | |
108 (define-key map "\e[18~" [f7]) | |
109 (define-key map "\e[19~" [f8]) | |
110 (define-key map "\e[20~" [f9]) | |
111 (define-key map "\e[21~" [f10]) | |
112 (define-key map "\e[23~" [f11]) | |
113 (define-key map "\e[24~" [f12]) | |
114 | |
115 (define-key map "\eO2P" [S-f1]) | |
116 (define-key map "\eO2Q" [S-f2]) | |
117 (define-key map "\eO2R" [S-f3]) | |
118 (define-key map "\eO2S" [S-f4]) | |
119 (define-key map "\e[15;2~" [S-f5]) | |
120 (define-key map "\e[17;2~" [S-f6]) | |
121 (define-key map "\e[18;2~" [S-f7]) | |
122 (define-key map "\e[19;2~" [S-f8]) | |
123 (define-key map "\e[20;2~" [S-f9]) | |
124 (define-key map "\e[21;2~" [S-f10]) | |
125 (define-key map "\e[23;2~" [S-f11]) | |
126 (define-key map "\e[24;2~" [S-f12]) | |
127 | |
128 (define-key map "\eO5P" [C-f1]) | |
129 (define-key map "\eO5Q" [C-f2]) | |
130 (define-key map "\eO5R" [C-f3]) | |
131 (define-key map "\eO5S" [C-f4]) | |
132 (define-key map "\e[15;5~" [C-f5]) | |
133 (define-key map "\e[17;5~" [C-f6]) | |
134 (define-key map "\e[18;5~" [C-f7]) | |
135 (define-key map "\e[19;5~" [C-f8]) | |
136 (define-key map "\e[20;5~" [C-f9]) | |
137 (define-key map "\e[21;5~" [C-f10]) | |
138 (define-key map "\e[23;5~" [C-f11]) | |
139 (define-key map "\e[24;5~" [C-f12]) | |
46065
3f4640971880
(function-key-map): Add some bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42947
diff
changeset
|
140 |
88155 | 141 (define-key map "\eO6P" [C-S-f1]) |
142 (define-key map "\eO6Q" [C-S-f2]) | |
143 (define-key map "\eO6R" [C-S-f3]) | |
144 (define-key map "\eO6S" [C-S-f4]) | |
145 (define-key map "\e[15;6~" [C-S-f5]) | |
146 (define-key map "\e[17;6~" [C-S-f6]) | |
147 (define-key map "\e[18;6~" [C-S-f7]) | |
148 (define-key map "\e[19;6~" [C-S-f8]) | |
149 (define-key map "\e[20;6~" [C-S-f9]) | |
150 (define-key map "\e[21;6~" [C-S-f10]) | |
151 (define-key map "\e[23;6~" [C-S-f11]) | |
152 (define-key map "\e[24;6~" [C-S-f12]) | |
153 | |
154 (define-key map "\eO3P" [A-f1]) | |
155 (define-key map "\eO3Q" [A-f2]) | |
156 (define-key map "\eO3R" [A-f3]) | |
157 (define-key map "\eO3S" [A-f4]) | |
158 (define-key map "\e[15;3~" [A-f5]) | |
159 (define-key map "\e[17;3~" [A-f6]) | |
160 (define-key map "\e[18;3~" [A-f7]) | |
161 (define-key map "\e[19;3~" [A-f8]) | |
162 (define-key map "\e[20;3~" [A-f9]) | |
163 (define-key map "\e[21;3~" [A-f10]) | |
164 (define-key map "\e[23;3~" [A-f11]) | |
165 (define-key map "\e[24;3~" [A-f12]) | |
46065
3f4640971880
(function-key-map): Add some bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42947
diff
changeset
|
166 |
88155 | 167 (define-key map "\eOA" [up]) |
168 (define-key map "\eOB" [down]) | |
169 (define-key map "\eOC" [right]) | |
170 (define-key map "\eOD" [left]) | |
171 (define-key map "\eOF" [end]) | |
172 (define-key map "\eOH" [home]) | |
173 | |
174 (define-key map "\e[1;2A" [S-up]) | |
175 (define-key map "\e[1;2B" [S-down]) | |
176 (define-key map "\e[1;2C" [S-right]) | |
177 (define-key map "\e[1;2D" [S-left]) | |
178 (define-key map "\e[1;2F" [S-end]) | |
179 (define-key map "\e[1;2H" [S-home]) | |
180 | |
181 (define-key map "\e[1;5A" [C-up]) | |
182 (define-key map "\e[1;5B" [C-down]) | |
183 (define-key map "\e[1;5C" [C-right]) | |
184 (define-key map "\e[1;5D" [C-left]) | |
185 (define-key map "\e[1;5F" [C-end]) | |
186 (define-key map "\e[1;5H" [C-home]) | |
187 | |
188 (define-key map "\e[1;6A" [C-S-up]) | |
189 (define-key map "\e[1;6B" [C-S-down]) | |
190 (define-key map "\e[1;6C" [C-S-right]) | |
191 (define-key map "\e[1;6D" [C-S-left]) | |
192 (define-key map "\e[1;6F" [C-S-end]) | |
193 (define-key map "\e[1;6H" [C-S-home]) | |
194 | |
195 (define-key map "\e[1;3A" [A-up]) | |
196 (define-key map "\e[1;3B" [A-down]) | |
197 (define-key map "\e[1;3C" [A-right]) | |
198 (define-key map "\e[1;3D" [A-left]) | |
199 (define-key map "\e[1;3F" [A-end]) | |
200 (define-key map "\e[1;3H" [A-home]) | |
46065
3f4640971880
(function-key-map): Add some bindings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42947
diff
changeset
|
201 |
88155 | 202 (define-key map "\e[2~" [insert]) |
203 (define-key map "\e[3~" [delete]) | |
204 (define-key map "\e[5~" [prior]) | |
205 (define-key map "\e[6~" [next]) | |
206 | |
207 (define-key map "\e[2;2~" [S-insert]) | |
208 (define-key map "\e[3;2~" [S-delete]) | |
209 (define-key map "\e[5;2~" [S-prior]) | |
210 (define-key map "\e[6;2~" [S-next]) | |
211 | |
212 (define-key map "\e[2;5~" [C-insert]) | |
213 (define-key map "\e[3;5~" [C-delete]) | |
214 (define-key map "\e[5;5~" [C-prior]) | |
215 (define-key map "\e[6;5~" [C-next]) | |
216 | |
217 (define-key map "\e[2;6~" [C-S-insert]) | |
218 (define-key map "\e[3;6~" [C-S-delete]) | |
219 (define-key map "\e[5;6~" [C-S-prior]) | |
220 (define-key map "\e[6;6~" [C-S-next]) | |
221 | |
222 (define-key map "\e[2;3~" [A-insert]) | |
223 (define-key map "\e[3;3~" [A-delete]) | |
224 (define-key map "\e[5;3~" [A-prior]) | |
225 (define-key map "\e[6;3~" [A-next]) | |
226 | |
227 (define-key map "\e[4~" [select]) | |
228 (define-key map "\e[29~" [print]) | |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
229 |
88155 | 230 ;; Other versions of xterm might emit these. |
231 (define-key map "\e[A" [up]) | |
232 (define-key map "\e[B" [down]) | |
233 (define-key map "\e[C" [right]) | |
234 (define-key map "\e[D" [left]) | |
235 (define-key map "\e[1~" [home]) | |
236 | |
237 (define-key map "\eO2A" [S-up]) | |
238 (define-key map "\eO2B" [S-down]) | |
239 (define-key map "\eO2C" [S-right]) | |
240 (define-key map "\eO2D" [S-left]) | |
241 (define-key map "\eO2F" [S-end]) | |
242 (define-key map "\eO2H" [S-home]) | |
40694
41fcf9864c4d
(function-key-map): Add entry for `ESC [ 3 ~' -> <delete>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38431
diff
changeset
|
243 |
88155 | 244 (define-key map "\eO5A" [C-up]) |
245 (define-key map "\eO5B" [C-down]) | |
246 (define-key map "\eO5C" [C-right]) | |
247 (define-key map "\eO5D" [C-left]) | |
248 (define-key map "\eO5F" [C-end]) | |
249 (define-key map "\eO5H" [C-home]) | |
250 | |
251 (define-key map "\e[11~" [f1]) | |
252 (define-key map "\e[12~" [f2]) | |
253 (define-key map "\e[13~" [f3]) | |
254 (define-key map "\e[14~" [f4]) | |
255 | |
256 ;; Use inheritance to let the main keymap override those defaults. | |
257 ;; This way we don't override terminfo-derived settings or settings | |
258 ;; made in the .emacs file. | |
259 (set-keymap-parent map (keymap-parent function-key-map)) | |
260 (set-keymap-parent function-key-map map)) | |
261 | |
262 ;; Do it! | |
263 (xterm-register-default-colors) | |
264 ;; This recomputes all the default faces given the colors we've just set up. | |
265 (tty-set-up-initial-frame-faces))) | |
38431
853c3674f20a
Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14170
diff
changeset
|
266 |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
267 ;; Set up colors, for those versions of xterm that support it. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
268 (defvar xterm-standard-colors |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
269 ;; The names in the comments taken from XTerm-col.ad in the xterm |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
270 ;; distribution, see ftp://dickey.his.com/xterm/. RGB values are |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
271 ;; from rgb.txt. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
272 '(("black" 0 ( 0 0 0)) ; black |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
273 ("red" 1 (205 0 0)) ; red3 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
274 ("green" 2 ( 0 205 0)) ; green3 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
275 ("yellow" 3 (205 205 0)) ; yellow3 |
88155 | 276 ("blue" 4 ( 0 0 238)) ; blue2 |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
277 ("magenta" 5 (205 0 205)) ; magenta3 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
278 ("cyan" 6 ( 0 205 205)) ; cyan3 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
279 ("white" 7 (229 229 229)) ; gray90 |
88155 | 280 ("brightblack" 8 (127 127 127)) ; gray50 |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
281 ("brightred" 9 (255 0 0)) ; red |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
282 ("brightgreen" 10 ( 0 255 0)) ; green |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
283 ("brightyellow" 11 (255 255 0)) ; yellow |
88155 | 284 ("brightblue" 12 (92 92 255)) ; rgb:5c/5c/ff |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
285 ("brightmagenta" 13 (255 0 255)) ; magenta |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
286 ("brightcyan" 14 ( 0 255 255)) ; cyan |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
287 ("brightwhite" 15 (255 255 255))) ; white |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
288 "Names of 16 standard xterm/aixterm colors, their numbers, and RGB values.") |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
289 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
290 (defun xterm-rgb-convert-to-16bit (prim) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
291 "Convert an 8-bit primary color value PRIM to a corresponding 16-bit value." |
88155 | 292 (logior prim (lsh prim 8))) |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
293 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
294 (defun xterm-register-default-colors () |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
295 "Register the default set of colors for xterm or compatible emulator. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
296 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
297 This function registers the number of colors returned by `display-color-cells' |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
298 for the currently selected frame. The first 16 colors are taken from |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
299 `xterm-standard-colors', which see, while the rest are computed assuming |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
300 either the 88- or 256-color standard color scheme supported by latest |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
301 versions of xterm." |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
302 (let* ((ncolors (display-color-cells)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
303 (colors xterm-standard-colors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
304 (color (car colors))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
305 (if (> ncolors 0) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
306 ;; Clear the 8 default tty colors registered by startup.el |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
307 (tty-color-clear)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
308 ;; Only register as many colors as are supported by the display. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
309 (while (and (> ncolors 0) colors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
310 (tty-color-define (car color) (cadr color) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
311 (mapcar 'xterm-rgb-convert-to-16bit |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
312 (car (cddr color)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
313 (setq colors (cdr colors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
314 color (car colors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
315 ncolors (1- ncolors))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
316 ;; We've exhausted the colors from `xterm-standard-colors'. If there |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
317 ;; are more colors to support, compute them now. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
318 (when (> ncolors 0) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
319 (cond |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
320 ((= ncolors 240) ; 256-color xterm |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
321 ;; 216 non-gray colors first |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
322 (let ((r 0) (g 0) (b 0)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
323 (while (> ncolors 24) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
324 ;; This and other formulae taken from 256colres.pl and |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
325 ;; 88colres.pl in the xterm distribution. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
326 (tty-color-define (format "color-%d" (- 256 ncolors)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
327 (- 256 ncolors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
328 (mapcar 'xterm-rgb-convert-to-16bit |
88155 | 329 (list (if (zerop r) 0 (+ (* r 40) 55)) |
330 (if (zerop g) 0 (+ (* g 40) 55)) | |
331 (if (zerop b) 0 (+ (* b 40) 55))))) | |
332 | |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
333 (setq b (1+ b)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
334 (if (> b 5) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
335 (setq g (1+ g) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
336 b 0)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
337 (if (> g 5) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
338 (setq r (1+ r) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
339 g 0)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
340 (setq ncolors (1- ncolors)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
341 ;; Now the 24 gray colors |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
342 (while (> ncolors 0) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
343 (setq color (xterm-rgb-convert-to-16bit (+ 8 (* (- 24 ncolors) 10)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
344 (tty-color-define (format "color-%d" (- 256 ncolors)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
345 (- 256 ncolors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
346 (list color color color)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
347 (setq ncolors (1- ncolors)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
348 ((= ncolors 72) ; 88-color xterm |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
349 ;; 64 non-gray colors |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
350 (let ((levels '(0 139 205 255)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
351 (r 0) (g 0) (b 0)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
352 (while (> ncolors 8) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
353 (tty-color-define (format "color-%d" (- 88 ncolors)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
354 (- 88 ncolors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
355 (mapcar 'xterm-rgb-convert-to-16bit |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
356 (list (nth r levels) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
357 (nth g levels) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
358 (nth b levels)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
359 (setq b (1+ b)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
360 (if (> b 3) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
361 (setq g (1+ g) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
362 b 0)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
363 (if (> g 3) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
364 (setq r (1+ r) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
365 g 0)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
366 (setq ncolors (1- ncolors)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
367 ;; Now the 8 gray colors |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
368 (while (> ncolors 0) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
369 (setq color (xterm-rgb-convert-to-16bit |
88155 | 370 (floor |
42947
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
371 (if (= ncolors 8) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
372 46.36363636 |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
373 (+ (* (- 8 ncolors) 23.18181818) 69.54545454))))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
374 (tty-color-define (format "color-%d" (- 88 ncolors)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
375 (- 88 ncolors) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
376 (list color color color)) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
377 (setq ncolors (1- ncolors)))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
378 (t (error "Unsupported number of xterm colors (%d)" (+ 16 ncolors))))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
379 ;; Modifying color mappings means realized faces don't use the |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
380 ;; right colors, so clear them. |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
381 (clear-face-cache))) |
76e795715361
(xterm-standard-colors): New variable.
Eli Zaretskii <eliz@gnu.org>
parents:
40694
diff
changeset
|
382 |
88155 | 383 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a |
38431
853c3674f20a
Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
14170
diff
changeset
|
384 ;;; xterm.el ends here |