0
|
1 ;;!emacs
|
|
2 ;;
|
|
3 ;; FILE: hmouse-sh.el
|
|
4 ;; SUMMARY: System-dependent Smart Mouse Key bindings (using shift key).
|
|
5 ;; USAGE: GNU Emacs Lisp Library
|
|
6 ;; KEYWORDS: hypermedia, mouse
|
|
7 ;;
|
|
8 ;; AUTHOR: Bob Weiner
|
24
|
9 ;; ORG: InfoDock Associates
|
0
|
10 ;;
|
|
11 ;; ORIG-DATE: 3-Sep-91 at 21:40:58
|
24
|
12 ;; LAST-MOD: 21-Feb-97 at 18:02:48 by Bob Weiner
|
0
|
13 ;;
|
|
14 ;; This file is part of Hyperbole.
|
|
15 ;; Available for use and distribution under the same terms as GNU Emacs.
|
|
16 ;;
|
24
|
17 ;; Copyright (C) 1991-1997, Free Software Foundation, Inc.
|
0
|
18 ;; Developed with support from Motorola Inc.
|
|
19 ;;
|
|
20 ;; DESCRIPTION:
|
|
21 ;;
|
|
22 ;; See description in "hmouse-key.el".
|
|
23 ;;
|
|
24 ;; DESCRIP-END.
|
|
25
|
|
26 ;;; ************************************************************************
|
|
27 ;;; Public functions
|
|
28 ;;; ************************************************************************
|
|
29
|
|
30 (defun hmouse-get-bindings ()
|
|
31 "Returns list of bindings for mouse keys prior to their use as Smart Keys."
|
24
|
32 ;; Do nothing when running in batch mode.
|
|
33 (if noninteractive
|
|
34 nil
|
|
35 (eval
|
|
36 (cdr (assoc
|
|
37 ;; Get mouse bindings under Emacs 19 or XEmacs, even if not under a
|
|
38 ;; window system since it can have frames on ttys and windowed
|
|
39 ;; displays at the same time.
|
|
40 (or (and hyperb:xemacs-p "lemacs")
|
|
41 (and hyperb:emacs19-p "emacs19")
|
|
42 hyperb:window-system)
|
|
43 '(("emacs19" .
|
|
44 (mapcar (function
|
|
45 (lambda (key) (cons key (lookup-key global-map key))))
|
|
46 (if (memq window-system '(ns dps))
|
|
47 ;; NEXTSTEP offers only 2 shift-mouse buttons which we use
|
|
48 ;; as the Smart Keys.
|
|
49 '([S-down-mouse-1] [S-mouse-1] [S-down-mouse-2]
|
|
50 [S-mouse-2] [S-double-mouse-1] [S-triple-mouse-1]
|
|
51 [S-double-mouse-2] [S-triple-mouse-2]
|
|
52 [vertical-line S-down-mouse-1]
|
|
53 [vertical-line S-mouse-1]
|
|
54 [vertical-line S-down-mouse-2]
|
|
55 [vertical-line S-mouse-2]
|
|
56 [mode-line S-down-mouse-1] [mode-line S-mouse-1]
|
|
57 [mode-line S-down-mouse-2] [mode-line S-mouse-2]
|
|
58 )
|
|
59 ;; X
|
|
60 '([S-down-mouse-2] [S-mouse-2] [S-down-mouse-3]
|
|
61 [S-mouse-3] [S-double-mouse-2] [S-triple-mouse-2]
|
|
62 [S-double-mouse-3] [S-triple-mouse-3]
|
0
|
63 [vertical-line S-down-mouse-2]
|
|
64 [vertical-line S-mouse-2]
|
24
|
65 [vertical-line S-down-mouse-3]
|
|
66 [vertical-line S-mouse-3]
|
0
|
67 [mode-line S-down-mouse-2] [mode-line S-mouse-2]
|
24
|
68 [mode-line S-down-mouse-3] [mode-line S-mouse-3]
|
|
69 ))))
|
|
70 ("lemacs" .
|
|
71 (nconc
|
|
72 (mapcar (function
|
|
73 (lambda (key)
|
|
74 (cons key (lookup-key global-map key))))
|
|
75 '([(shift button2)] [(shift button2up)]
|
|
76 [(shift button3)] [(shift button3up)]))
|
|
77 (if (boundp 'mode-line-map)
|
|
78 (mapcar (function
|
|
79 (lambda (key)
|
|
80 (cons key (lookup-key mode-line-map key))))
|
|
81 '([(shift button3)] [(shift button3up)])))))
|
|
82 ("xterm" .
|
|
83 (mapcar (function
|
|
84 (lambda (key) (cons key (lookup-key mouse-map key))))
|
|
85 (list x-button-s-middle x-button-s-middle-up
|
|
86 x-button-s-right x-button-s-right-up)))
|
|
87 ("epoch" .
|
|
88 (mapcar (function
|
|
89 (lambda (key) (cons key (aref mouse::global-map key))))
|
|
90 (list (mouse::index mouse-middle mouse-shift)
|
|
91 (mouse::index mouse-middle mouse-shift-up)
|
|
92 (mouse::index mouse-right mouse-shift)
|
|
93 (mouse::index mouse-right mouse-shift-up)
|
|
94 ;; Modeline mouse map
|
|
95 (mouse::index mouse-mode-middle mouse-shift)
|
|
96 (mouse::index mouse-mode-middle mouse-shift-up)
|
|
97 (mouse::index mouse-mode-right mouse-shift)
|
|
98 (mouse::index mouse-mode-right mouse-shift-up)
|
|
99 )))
|
|
100 ("next" .
|
|
101 (mapcar (function
|
|
102 (lambda (key)
|
|
103 (cons key (mousemap-get
|
|
104 (mouse-list-to-mouse-code key)
|
|
105 current-global-mousemap))))
|
|
106 (apply 'nconc
|
|
107 (mapcar (function
|
|
108 (lambda (region)
|
|
109 (mapcar (function
|
|
110 (lambda (key)
|
|
111 (cons region key)))
|
|
112 '((shift left) (shift up left)
|
|
113 (shift right)
|
|
114 (shift up right)
|
|
115 ))))
|
|
116 '(text scrollbar modeline minibuffer)))
|
|
117 ))
|
|
118 ;; SunView
|
|
119 ("sun" .
|
|
120 (mapcar (function
|
|
121 (lambda (key)
|
|
122 (setq key (mouse-list-to-mouse-code key))
|
|
123 (cons key (mousemap-get
|
|
124 key current-global-mousemap))))
|
|
125 (apply 'nconc
|
|
126 (mapcar (function
|
|
127 (lambda (region)
|
|
128 (mapcar (function
|
|
129 (lambda (key)
|
|
130 (cons region key)))
|
|
131 '((shift middle)
|
|
132 (shift up middle)
|
|
133 (shift right)
|
|
134 (shift up right)
|
|
135 ))))
|
|
136 '(text scrollbar modeline minibuffer)))
|
|
137 ))
|
|
138 ("apollo" .
|
|
139 (mapcar (function
|
|
140 (lambda (key-str) (apollo-mouse-key-and-binding
|
|
141 key-str)))
|
|
142 '("M2S" "M2U" "M3S" "M3U")))
|
|
143 ))))))
|
0
|
144
|
|
145 (defun hmouse-setup ()
|
|
146 "Binds mouse keys for use as Smart Keys."
|
|
147 (interactive)
|
24
|
148 ;; Do nothing when running in batch mode.
|
|
149 (if noninteractive
|
|
150 nil
|
|
151 (or hmouse-bindings-flag hmouse-previous-bindings
|
|
152 (setq hmouse-previous-bindings (hmouse-get-bindings)))
|
|
153 ;; Ensure Gillespie's Info mouse support is off since
|
|
154 ;; Hyperbole handles that.
|
|
155 (setq Info-mouse-support nil)
|
|
156 ;;
|
|
157 (cond;; GNU Emacs 19
|
|
158 (hyperb:emacs19-p
|
|
159 (setq hmouse-set-point-command 'mouse-set-point)
|
|
160 (if (memq window-system '(ns dps))
|
|
161 ;; NEXTSTEP offers only 2 shift-mouse buttons which we use
|
|
162 ;; as the Smart Keys.
|
|
163 (progn
|
|
164 (global-set-key [S-down-mouse-1] 'action-key-depress-emacs19)
|
|
165 (global-set-key [S-mouse-1] 'action-mouse-key-emacs19)
|
|
166 (global-set-key [S-double-mouse-1] 'action-mouse-key-emacs19)
|
|
167 (global-set-key [S-triple-mouse-1] 'action-mouse-key-emacs19)
|
|
168 (global-set-key [S-down-mouse-2] 'assist-key-depress-emacs19)
|
|
169 (global-set-key [S-mouse-2] 'assist-mouse-key-emacs19)
|
|
170 (global-set-key [S-double-mouse-2] 'assist-mouse-key-emacs19)
|
|
171 (global-set-key [S-triple-mouse-2] 'assist-mouse-key-emacs19)
|
|
172 (global-set-key [vertical-line S-down-mouse-1] 'action-key-depress-emacs19)
|
|
173 (global-set-key [vertical-line S-mouse-1] 'action-mouse-key-emacs19)
|
|
174 (global-set-key [vertical-line S-down-mouse-2]
|
|
175 'assist-key-depress-emacs19)
|
|
176 (global-set-key [vertical-line S-mouse-2]
|
|
177 'assist-mouse-key-emacs19)
|
|
178 (global-set-key [mode-line S-down-mouse-1] 'action-key-depress-emacs19)
|
|
179 (global-set-key [mode-line S-mouse-1] 'action-mouse-key-emacs19)
|
|
180 (global-set-key [mode-line S-down-mouse-2] 'assist-key-depress-emacs19)
|
|
181 (global-set-key [mode-line S-mouse-2] 'assist-mouse-key-emacs19))
|
|
182 ;; X
|
|
183 (global-set-key [S-down-mouse-2] 'action-key-depress-emacs19)
|
|
184 (global-set-key [S-mouse-2] 'action-mouse-key-emacs19)
|
|
185 (global-set-key [S-double-mouse-2] 'action-mouse-key-emacs19)
|
|
186 (global-set-key [S-triple-mouse-2] 'action-mouse-key-emacs19)
|
|
187 (global-set-key [S-down-mouse-3] 'assist-key-depress-emacs19)
|
|
188 (global-set-key [S-mouse-3] 'assist-mouse-key-emacs19)
|
|
189 (global-set-key [S-double-mouse-3] 'assist-mouse-key-emacs19)
|
|
190 (global-set-key [S-triple-mouse-3] 'assist-mouse-key-emacs19)
|
|
191 (global-set-key [vertical-line S-down-mouse-2] 'action-key-depress-emacs19)
|
|
192 (global-set-key [vertical-line S-mouse-2] 'action-mouse-key-emacs19)
|
|
193 (global-set-key [vertical-line S-down-mouse-3]
|
|
194 'assist-key-depress-emacs19)
|
|
195 (global-set-key [vertical-line S-mouse-3]
|
|
196 'assist-mouse-key-emacs19)
|
|
197 (global-set-key [mode-line S-down-mouse-2] 'action-key-depress-emacs19)
|
|
198 (global-set-key [mode-line S-mouse-2] 'action-mouse-key-emacs19)
|
|
199 (global-set-key [mode-line S-down-mouse-3] 'assist-key-depress-emacs19)
|
|
200 (global-set-key [mode-line S-mouse-3] 'assist-mouse-key-emacs19)))
|
|
201 ;;
|
|
202 ;; XEmacs
|
|
203 (hyperb:xemacs-p
|
|
204 ;; Set mouse bindings under XEmacs, even if not under a window
|
|
205 ;; system since it can have frames on ttys and windowed displays at
|
|
206 ;; the same time.
|
|
207 (setq hmouse-set-point-command 'hmouse-move-point-xemacs)
|
|
208 (global-set-key '(shift button2) 'action-key-depress)
|
|
209 (global-set-key '(shift button2up) 'action-mouse-key)
|
|
210 (if (fboundp 'infodock-set-mouse-bindings)
|
|
211 (infodock-set-mouse-bindings)
|
|
212 (if (boundp 'mode-line-map)
|
|
213 (progn (define-key mode-line-map '(shift button3)
|
|
214 'assist-key-depress)
|
|
215 (define-key mode-line-map '(shift button3up)
|
|
216 'assist-mouse-key)
|
|
217 ))
|
|
218 (global-set-key '(shift button3) 'assist-key-depress)
|
|
219 (global-set-key '(shift button3up) 'assist-mouse-key)))
|
|
220 ;;
|
|
221 ;; X
|
|
222 ((equal hyperb:window-system "xterm")
|
|
223 (setq hmouse-set-point-command 'x-mouse-set-point)
|
|
224 (define-key mouse-map x-button-s-middle 'action-key-depress)
|
|
225 (define-key mouse-map x-button-s-middle-up 'action-mouse-key)
|
|
226 (define-key mouse-map x-button-s-right 'assist-key-depress)
|
|
227 (define-key mouse-map x-button-s-right-up 'assist-mouse-key)
|
|
228 ;; Use these instead of the above for a true META-BUTTON binding.
|
|
229 ;; (define-key mouse-map x-button-m-middle 'assist-key-depress)
|
|
230 ;; (define-key mouse-map x-button-m-middle-up 'assist-mouse-key)
|
|
231 )
|
|
232 ;;
|
|
233 ;; Epoch
|
|
234 ((equal hyperb:window-system "epoch")
|
|
235 (setq hmouse-set-point-command 'mouse::set-point)
|
|
236 (global-set-mouse mouse-middle mouse-shift 'action-key-depress)
|
|
237 (global-set-mouse mouse-middle mouse-shift-up 'action-mouse-key)
|
|
238 (global-set-mouse mouse-right mouse-shift 'assist-key-depress)
|
|
239 (global-set-mouse mouse-right mouse-shift-up 'assist-mouse-key)
|
|
240 ;; Modeline mouse map
|
|
241 (global-set-mouse mouse-mode-middle mouse-shift 'action-key-depress)
|
|
242 (global-set-mouse mouse-mode-middle mouse-shift-up 'action-mouse-key)
|
|
243 (global-set-mouse mouse-mode-right mouse-shift 'assist-key-depress)
|
|
244 (global-set-mouse mouse-mode-right mouse-shift-up
|
|
245 'assist-mouse-key)
|
|
246 )
|
|
247 ;;
|
|
248 ;; NeXT
|
|
249 ((equal hyperb:window-system "next")
|
|
250 (setq hmouse-set-point-command 'hmouse-move-point-eterm)
|
|
251 ;; Use left button to set point.
|
|
252 ;; Use shift-left button instead of non-existent middle as Action Key.
|
|
253 (mapcar
|
|
254 (function
|
|
255 (lambda (region)
|
|
256 (global-set-mouse (cons region '(shift left)) 'action-key-depress)
|
|
257 (global-set-mouse (cons region '(shift up left)) 'action-mouse-key)
|
|
258 (global-set-mouse (cons region '(shift right)) 'assist-key-depress)
|
|
259 (global-set-mouse (cons region '(shift up right))
|
|
260 'assist-mouse-key)
|
|
261 ;; Use these instead of the above for a true META-BUTTON binding.
|
|
262 ;; (global-set-mouse (cons region '(meta right)) 'assist-key-depress)
|
|
263 ;; (global-set-mouse (cons region '(meta up right)) 'assist-mouse-key)
|
|
264 ))
|
|
265 '(text scrollbar modeline minibuffer))
|
|
266 )
|
|
267 ;;
|
|
268 ;; SunView
|
|
269 ((equal hyperb:window-system "sun")
|
|
270 (setq hmouse-set-point-command 'hmouse-move-point-eterm)
|
|
271 (mapcar
|
|
272 (function
|
|
273 (lambda (region)
|
|
274 (global-set-mouse (cons region '(shift middle)) 'action-key-depress)
|
|
275 (global-set-mouse (cons region '(shift up middle))
|
|
276 'action-mouse-key)
|
|
277 (global-set-mouse (cons region '(shift right)) 'assist-key-depress)
|
|
278 (global-set-mouse (cons region '(shift up right))
|
|
279 'assist-mouse-key)
|
|
280 ;; Use these instead of the above for a true META-BUTTON binding.
|
|
281 ;; (global-set-mouse (cons region '(meta middle)) 'assist-key-depress)
|
|
282 ;; (global-set-mouse (cons region '(meta up middle)) 'assist-mouse-key)
|
|
283 ))
|
|
284 '(text scrollbar modeline minibuffer))
|
|
285 )
|
|
286 ;;
|
|
287 ;; Apollo DM
|
|
288 ((equal hyperb:window-system "apollo")
|
|
289 (setq hmouse-set-point-command 'apollo-mouse-move-point)
|
|
290 (bind-apollo-mouse-button "M2S" 'action-key-depress)
|
|
291 (bind-apollo-mouse-button "M2U" 'action-mouse-key)
|
|
292 (bind-apollo-mouse-button "M3S" 'assist-key-depress)
|
|
293 (bind-apollo-mouse-button "M3U" 'assist-mouse-key)
|
|
294 ))
|
|
295 (setq hmouse-bindings (hmouse-get-bindings)
|
|
296 hmouse-bindings-flag t)))
|