Mercurial > emacs
annotate lisp/term/rxvt.el @ 89547:73bdeb6f6968
(adjust_frame_glyphs_for_frame_redisplay)
(adjust_frame_glyphs_for_window_redisplay): Remove unused ch_dim.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 29 Sep 2003 18:01:37 +0000 |
parents | 375f2633d815 |
children | 68c22ea6027c |
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 | |
29 ;; Set up function-key-map entries that termcap and terminfo don't know. | |
30 (let ((map (make-sparse-keymap))) | |
31 (define-key map "\e[A" [up]) | |
32 (define-key map "\e[B" [down]) | |
33 (define-key map "\e[C" [right]) | |
34 (define-key map "\e[D" [left]) | |
35 (define-key map "\e[7~" [home]) | |
36 (define-key map "\e[2~" [insert]) | |
37 (define-key map "\e[3~" [delete]) | |
38 (define-key map "\e[4~" [select]) | |
39 (define-key map "\e[5~" [prior]) | |
40 (define-key map "\e[6~" [next]) | |
41 (define-key map "\e[11~" [f1]) | |
42 (define-key map "\e[12~" [f2]) | |
43 (define-key map "\e[13~" [f3]) | |
44 (define-key map "\e[14~" [f4]) | |
45 (define-key map "\e[15~" [f5]) | |
46 (define-key map "\e[17~" [f6]) | |
47 (define-key map "\e[18~" [f7]) | |
48 (define-key map "\e[19~" [f8]) | |
49 (define-key map "\e[20~" [f9]) | |
50 (define-key map "\e[21~" [f10]) | |
51 (define-key map "\e[23~" [f11]) | |
52 (define-key map "\e[24~" [f12]) | |
53 (define-key map "\e[29~" [print]) | |
54 | |
55 (define-key map "\e[11^" [C-f1]) | |
56 (define-key map "\e[12^" [C-f2]) | |
57 (define-key map "\e[13^" [C-f3]) | |
58 (define-key map "\e[14^" [C-f4]) | |
59 (define-key map "\e[15^" [C-f5]) | |
60 (define-key map "\e[17^" [C-f6]) | |
61 (define-key map "\e[18^" [C-f7]) | |
62 (define-key map "\e[19^" [C-f8]) | |
63 (define-key map "\e[20^" [C-f9]) | |
64 (define-key map "\e[21^" [C-f10]) | |
65 (define-key map "\e[23^" [C-f11]) | |
66 (define-key map "\e[24^" [C-f12]) | |
67 | |
68 (define-key map "\e[29~" [print]) | |
69 | |
70 (define-key map "\e[2;2~" [S-insert]) | |
71 (define-key map "\e[3$" [S-delete]) | |
72 | |
73 (define-key map "\e[2^" [C-insert]) | |
74 (define-key map "\e[3^" [C-delete]) | |
75 (define-key map "\e[5^" [C-prior]) | |
76 (define-key map "\e[6^" [C-next]) | |
77 (define-key map "\eOd" [C-left]) | |
78 (define-key map "\eOc" [C-right]) | |
79 (define-key map "\eOa" [C-up]) | |
80 (define-key map "\eOb" [C-down]) | |
49599
5ade352e8d1c
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42962
diff
changeset
|
81 |
42945 | 82 (define-key map "\e[5$" [S-prior]) |
83 (define-key map "\e[6$" [S-next]) | |
84 (define-key map "\e[8$" [S-end]) | |
85 (define-key map "\e[7$" [S-home]) | |
86 (define-key map "\e[d" [S-left]) | |
87 (define-key map "\e[c" [S-right]) | |
88 (define-key map "\e[a" [S-up]) | |
89 (define-key map "\e[b" [S-down]) | |
90 | |
91 ;; Use inheritance to let the main keymap override those defaults. | |
92 ;; This way we don't override terminfo-derived settings or settings | |
93 ;; made in the .emacs file. | |
94 (set-keymap-parent map (keymap-parent function-key-map)) | |
95 (set-keymap-parent function-key-map map)) | |
96 | |
97 ;; Set up colors, for those versions of rxvt that support it. | |
98 (defvar rxvt-standard-colors | |
99 ;; The names of the colors in the comments taken from the rxvt.1 man | |
42962 | 100 ;; page; the corresponding RGB values--from rgb.txt. |
42945 | 101 '(("black" 0 ( 0 0 0)) ; black |
102 ("red" 1 (205 0 0)) ; red3 | |
103 ("green" 2 ( 0 205 0)) ; green3 | |
104 ("yellow" 3 (205 205 0)) ; yellow3 | |
105 ("blue" 4 ( 0 0 205)) ; blue3 | |
106 ("magenta" 5 (205 0 205)) ; magenta3 | |
107 ("cyan" 6 ( 0 205 205)) ; cyan3 | |
108 ("white" 7 (250 235 215)) ; AntiqueWhite | |
109 ("brightblack" 8 ( 64 64 64)) ; gray25 | |
110 ("brightred" 9 (255 0 0)) ; red | |
111 ("brightgreen" 10 ( 0 255 0)) ; green | |
112 ("brightyellow" 11 (255 255 0)) ; yellow | |
113 ("brightblue" 12 ( 0 0 255)) ; blue | |
114 ("brightmagenta" 13 (255 0 255)) ; magenta | |
115 ("brightcyan" 14 ( 0 255 255)) ; cyan | |
116 ("brightwhite" 15 (255 255 255))) ; white | |
117 "Names of 16 standard rxvt colors, their numbers, and RGB values.") | |
118 | |
119 (defun rxvt-rgb-convert-to-16bit (prim) | |
120 "Convert an 8-bit primary color value PRIM to a corresponding 16-bit value." | |
121 (min 65535 (round (* (/ prim 255.0) 65535.0)))) | |
122 | |
123 (defun rxvt-register-default-colors () | |
124 "Register the default set of colors for rxvt or compatible emulator. | |
125 | |
126 This function registers the number of colors returned by `display-color-cells' | |
127 for the currently selected frame." | |
128 (let* ((ncolors (display-color-cells)) | |
129 (colors rxvt-standard-colors) | |
130 (color (car colors))) | |
131 (if (> ncolors 0) | |
132 ;; Clear the 8 default tty colors registered by startup.el | |
133 (tty-color-clear)) | |
134 ;; Only register as many colors as are supported by the display. | |
135 (while (and (> ncolors 0) colors) | |
136 (tty-color-define (car color) (cadr color) | |
137 (mapcar 'rxvt-rgb-convert-to-16bit | |
138 (car (cddr color)))) | |
139 (setq colors (cdr colors) | |
140 color (car colors) | |
141 ncolors (1- ncolors))) | |
142 ;; Modifying color mappings means realized faces don't use the | |
143 ;; right colors, so clear them. | |
144 (clear-face-cache))) | |
145 | |
146 ;; rxvt puts the default colors into an environment variable | |
147 ;; COLORFGBG. We use this to set the background mode in a more | |
148 ;; intelligent way than the default guesswork in startup.el. | |
149 (defun rxvt-set-background-mode () | |
150 "Set background mode as appropriate for the default rxvt colors." | |
151 (let ((fgbg (getenv "COLORFGBG")) | |
152 bg rgb) | |
153 (setq frame-background-mode 'light) ; default | |
154 (when (and fgbg | |
155 (string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg)) | |
156 (setq bg (string-to-number (substring fgbg (match-beginning 1)))) | |
157 ;; The next line assumes that rxvt-standard-colors are ordered | |
158 ;; by the color index in the ascending order! | |
159 (setq rgb (car (cddr (nth bg rxvt-standard-colors)))) | |
160 ;; See the commentary in frame-set-background-mode about the | |
161 ;; computation below. | |
162 (if (< (apply '+ rgb) | |
163 ;; The following line assumes that white is the 15th | |
164 ;; color in rxvt-standard-colors. | |
165 (* (apply '+ (car (cddr (nth 15 rxvt-standard-colors)))) 0.6)) | |
166 (setq frame-background-mode 'dark))) | |
167 (frame-set-background-mode (selected-frame)))) | |
168 | |
169 ;; Do it! | |
170 (rxvt-register-default-colors) | |
171 (rxvt-set-background-mode) | |
172 ;; This recomputes all the default faces given the colors we've just set up. | |
173 (tty-set-up-initial-frame-faces) | |
174 | |
175 ;;; rxvt.el ends here |