Mercurial > hg > xemacs-beta
comparison lisp/x11/x-win-sun.el @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | ac2d302a0011 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 ;;; x-win-sun.el --- runtime initialization for Sun X servers and keyboards | |
2 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc. | |
3 | |
4 ;; Authors: jwz@netscape.com, wing@666.com, mrb@eng.sun.com | |
5 ;; Keywords: terminals | |
6 | |
7 ;; This file is part of XEmacs. | |
8 | |
9 ;; XEmacs is free software; you can redistribute it and/or modify it | |
10 ;; under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; XEmacs is distributed in the hope that it will be useful, but | |
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 ;; General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
21 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
23 ;;; Commentary: | |
24 | |
25 ;; This file is loaded by x-win.el at run-time when we are sure that XEmacs | |
26 ;; is running on the display of a Sun. | |
27 | |
28 ;; The Sun X server (both the MIT and OpenWindows varieties) have extremely | |
29 ;; stupid names for their keypad and function keys. For example, the key | |
30 ;; labeled 3 / PgDn, with R15 written on the front, is actually called F35. | |
31 | |
32 ;; There are 3 methods of dealing with the Sun key brokenness: | |
33 ;; | |
34 ;; - Use xmodmap to give all keys more sensible names for all apps: | |
35 ;; I use this shell script: | |
36 ;; | |
37 ;; for i in 0 1 2 3 4 5 6 7 8 9 Add Subtract Multiply Divide Decimal ; do | |
38 ;; echo "keysym KP_$i = KP_$i" | |
39 ;; done | |
40 ;; | |
41 ;; Clearly, as a good X11 citizen, we can't do this. | |
42 ;; | |
43 ;; - Use keyboard-translate-table to remap the keybindings at a low level. | |
44 ;; This approach is taken in the function `sun-x11-keyboard-translate'. | |
45 ;; This is like running xmodmap within XEmacs only. | |
46 ;; This is not the default, however, so that legacy keybindings in users' | |
47 ;; .emacs files like (global-set-key [(f35)] 'foo) continue to work | |
48 ;; | |
49 ;; - Use keyboard macros to provide indirection for keybindings. | |
50 ;; If we do (global-set-key [(f35)] [(kp_3)]), then the user's keybindings | |
51 ;; work whether he uses `f35' or `kp_3'. | |
52 ;; This is also compatible with FSF Emacs and other X11 apps. | |
53 ;; Although this has the disadvantage that these remappings | |
54 ;; only work with the global key map, we use this as the default. | |
55 ;; | |
56 ;; - The Right Way to do this remains to be written... | |
57 | |
58 ;; OK, here's another try at doing things the right way. | |
59 | |
60 ;; We use function-key-map, which honors explicit key-bindings for the | |
61 ;; stupid Sun names, but also allows indirection if no explicit | |
62 ;; key-binding exists. | |
63 | |
64 ;;; Code: | |
65 | |
66 (defun x11-remap-keysyms-using-function-key-map (mapping) | |
67 (while mapping | |
68 (let ((k1 (caar mapping)) | |
69 (k2 (cdar mapping))) | |
70 (mapc #'(lambda (prefix) | |
71 (define-key function-key-map | |
72 (append prefix (list k1)) | |
73 (vector (append prefix (list k2))))) | |
74 '(() (shift) (control) (meta) (alt) | |
75 (shift control) (shift alt) (shift meta) | |
76 (control alt) (control meta) (alt meta) | |
77 (shift control alt) (shift control meta) | |
78 (shift alt meta) (control alt meta) | |
79 (shift control alt meta)) | |
80 )) | |
81 (setq mapping (cdr mapping)))) | |
82 | |
83 (x11-remap-keysyms-using-function-key-map | |
84 ;; help is ok | |
85 ;; num_lock is ok | |
86 ;; up is ok | |
87 ;; left is ok | |
88 ;; right is ok | |
89 ;; kp_add is ok | |
90 ;; down is ok | |
91 ;; insert is ok | |
92 ;; delete is ok | |
93 ;; kp_enter is ok | |
94 (append | |
95 ;; Sun Function keys | |
96 (cond ((x-keysym-on-keyboard-p "SunCut") ; X11 R6 mappings | |
97 '((SunProps . props) (Undo . undo) | |
98 (SunFront . front) (SunCopy . copy) | |
99 (SunOpen . open) (SunPaste . paste) | |
100 (SunFind . find) (SunCut . cut) | |
101 (cancel . stop))) | |
102 | |
103 ((x-keysym-on-keyboard-p "F20") | |
104 '((f13 . props) (f14 . undo) | |
105 (f15 . front) (f16 . copy) | |
106 (f17 . open) (f18 . paste) | |
107 (f19 . find) (f20 . cut)))) | |
108 | |
109 (if (x-keysym-on-keyboard-p "F25") ; Sun Sparc keyboards | |
110 (append | |
111 '((f21 . pause) | |
112 (f22 . prsc) | |
113 (f23 . scroll) | |
114 (f25 . kp_divide) | |
115 (f26 . kp_multiply) | |
116 (f31 . kp_5)) | |
117 (if (x-keysym-on-keyboard-p "F36") | |
118 '((f36 . stop) (f37 . again)) ; MIT Type 5 name | |
119 '((f11 . stop) (f12 . again))))) ; Sun name or MIT Type 4 name | |
120 | |
121 ;; Type 4 keyboards have a real kp_subtract and a f24 labelled `=' | |
122 ;; Type 5 keyboards have no key labelled `=' and a f24 labelled `-' | |
123 (if (x-keysym-on-keyboard-p "F24") | |
124 (if (x-keysym-on-keyboard-p "KP_Subtract") | |
125 '((f24 . kp_equal)) | |
126 '((f24 . kp_subtract)))) | |
127 | |
128 ;; Map f33 (Sun name) or r13 (MIT name) to end or kp_end | |
129 (cond ((x-keysym-on-keyboard-p "F33") | |
130 (cond ((not (x-keysym-on-keyboard-p "End")) '((f33 . end))) | |
131 ((not (x-keysym-on-keyboard-p "KP_End")) '((f33 . kp_end))))) | |
132 ((x-keysym-on-keyboard-p "R13") | |
133 (cond ((not (x-keysym-on-keyboard-p "End")) '((r13 . end))) | |
134 ((not (x-keysym-on-keyboard-p "KP_End")) '((r13 . kp_end)))))) | |
135 | |
136 ;; Map f27 to home or kp_home, as appropriate | |
137 (cond ((not (x-keysym-on-keyboard-p "Home")) '((f27 . home))) | |
138 ((not (x-keysym-on-keyboard-p "KP_Home")) '((f27 . kp_home)))) | |
139 | |
140 ;; Map f29 to prior or kp_prior, as appropriate | |
141 (cond ((not (x-keysym-on-keyboard-p "Prior")) '((f29 . prior))) | |
142 ((not (x-keysym-on-keyboard-p "KP_Prior")) '((f29 . kp_prior)))) | |
143 | |
144 ;; Map f35 to next or kp_next, as appropriate | |
145 (cond ((not (x-keysym-on-keyboard-p "Next")) '((f35 . next))) | |
146 ((not (x-keysym-on-keyboard-p "KP_Next")) '((f35 . kp_next)))) | |
147 | |
148 (cond ((x-keysym-on-keyboard-p "apRead") ; SunOS 4.1.1 | |
149 '((apRead . f11) (apEdit . f12))) | |
150 ((x-keysym-on-keyboard-p "SunF36") ; SunOS 5 | |
151 '((SunF36 . f11) (SunF37 . f12)))) | |
152 )) | |
153 | |
154 (fmakunbound 'x11-remap-keysyms-using-function-key-map) | |
155 | |
156 | |
157 ;; for each element in the left column of the above table, alias it | |
158 ;; to the thing in the right column. Then do the same for mamy, but | |
159 ;; not all, modifier combinations. | |
160 ;; | |
161 ;; (Well, we omit hyper and super. #### Handle this some other way!) | |
162 ; (while mapping | |
163 ; (let ((mods '(() (shift) (control) (meta) (alt)))) | |
164 ; (while mods | |
165 ; (let ((k1 (vector (append (car mods) (list (car (car mapping)))))) | |
166 ; (k2 (vector (append (car mods) (list (cdr (car mapping))))))) | |
167 ; (define-key global-map k1 k2)) | |
168 ; (setq mods (cdr mods)))) | |
169 ; (setq mapping (cdr mapping)))) | |
170 | |
171 ;;; I've extended keyboard-translate-table to work over keysyms. | |
172 ;;; [FSF Emacs has something called `system-key-alist' that is | |
173 ;;; supposed to accomplish approximately the same thing. Unfortunately, | |
174 ;;; it's brain-dead in the typically FSF way, and associates *numbers* | |
175 ;;; (who knows where the hell they come from?) with symbols.] --ben | |
176 | |
177 ;;; And I've made it into a function which is not called by default --mrb | |
178 | |
179 (defun sun-x11-keyboard-translate () | |
180 "Remap Sun's X11 keyboard. | |
181 Keys with names like `f35' are remapped, at a low level, | |
182 to more mnemonic ones,like `kp_3'." | |
183 (interactive) | |
184 | |
185 (keyboard-translate | |
186 'f11 'stop ; the type4 keyboard Sun/MIT name | |
187 'f36 'stop ; the type5 keyboard Sun name | |
188 'cancel 'stop ; R6 binding | |
189 'f12 'again ; the type4 keyboard Sun/MIT name | |
190 'f37 'again ; the type5 keyboard Sun name | |
191 'f13 'props ; | |
192 'SunProps 'props ; R6 binding | |
193 'f14 'undo ; | |
194 'f15 'front ; | |
195 'SunFront 'front ; R6 binding | |
196 'f16 'copy ; | |
197 'SunCopy 'copy ; R6 binding | |
198 'f17 'open ; | |
199 'SunOpen 'open ; R6 binding | |
200 'f18 'paste ; | |
201 'SunPaste 'paste ; R6 binding | |
202 'f19 'find ; | |
203 'f20 'cut ; | |
204 'SunCut 'cut ; R6 binding | |
205 ;; help is ok | |
206 'f21 'pause | |
207 'f22 'prsc | |
208 'f23 'scroll | |
209 ;; num_lock is ok | |
210 ;;'f24 'kp_equal) ; type4 only! | |
211 'f25 'kp_divide ; | |
212 'f26 'kp_multiply ; | |
213 'f24 'kp_subtract ; type5 only! | |
214 'f27 'kp_7 ; | |
215 ;; up is ok | |
216 'f29 'kp_9 | |
217 ;; left is ok | |
218 'f31 'kp_5 | |
219 ;; right is ok | |
220 ;; kp_add is ok | |
221 'f33 'kp_1 ; the Sun name | |
222 'r13 'end ; the MIT name | |
223 ;; down is ok | |
224 'f35 'kp_3 | |
225 ;; insert is ok | |
226 ;; delete is ok | |
227 ;; kp_enter is ok | |
228 'SunF36 'f11 ; Type 5 keyboards | |
229 'SunF37 'f12 ; Used to be Stop & Again | |
230 )) | |
231 | |
232 | |
233 ;;; OpenWindows-like "find" processing. | |
234 ;;; As far as I know, the `find' key is a Sunism, so we do that binding | |
235 ;;; here. This is the only Sun-specific keybinding. (The functions | |
236 ;;; themselves are in x-win.el in case someone wants to use them when | |
237 ;;; not running on a Sun display.) | |
238 | |
239 (define-key global-map 'find 'ow-find) | |
240 (define-key global-map '(shift find) 'ow-find-backward) | |
241 | |
242 ;;; x-win-sun.el ends here |