1 ;;; hmouse-sh.el --- System-dependent Smart Mouse Key bindings (using shift key).
3 ;; Copyright (C) 1991-1995, 2006 Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: hypermedia, mouse
10 ;; This file is part of GNU Hyperbole.
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
17 ;; GNU Hyperbole is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; See description in "hmouse-key.el".
38 (defun hmouse-get-bindings ()
39 "Returns list of bindings for mouse keys prior to their use as Smart Keys."
42 ;; Get mouse bindings under Emacs 19 or XEmacs, even if not under a
43 ;; window system since it can have frames on ttys and windowed
44 ;; displays at the same time.
45 (or hyperb:window-system
46 (and (not noninteractive) hyperb:xemacs-p "xemacs")
47 (and (not noninteractive) hyperb:emacs19-p "emacs19"))
50 (lambda (key) (cons key (lookup-key global-map key))))
51 (if (memq window-system '(ns dps))
52 ;; NEXTSTEP offers only 2 shift-mouse buttons which we use
54 '([S-down-mouse-1] [S-mouse-1] [S-down-mouse-2]
55 [S-mouse-2] [S-double-mouse-1] [S-triple-mouse-1]
56 [S-double-mouse-2] [S-triple-mouse-2]
57 [vertical-line S-down-mouse-1]
58 [vertical-line S-mouse-1]
59 [vertical-line S-down-mouse-2]
60 [vertical-line S-mouse-2]
61 [mode-line S-down-mouse-1] [mode-line S-mouse-1]
62 [mode-line S-down-mouse-2] [mode-line S-mouse-2]
65 '([S-down-mouse-2] [S-mouse-2] [S-down-mouse-3]
66 [S-mouse-3] [S-double-mouse-2] [S-triple-mouse-2]
67 [S-double-mouse-3] [S-triple-mouse-3]
68 [vertical-line S-down-mouse-2]
69 [vertical-line S-mouse-2]
70 [vertical-line S-down-mouse-3]
71 [vertical-line S-mouse-3]
72 [mode-line S-down-mouse-2] [mode-line S-mouse-2]
73 [mode-line S-down-mouse-3] [mode-line S-mouse-3]
79 (cons key (lookup-key global-map key))))
80 '([(shift button2)] [(shift button2up)]
81 [(shift button3)] [(shift button3up)]))
82 (if (boundp 'mode-line-map)
85 (cons key (lookup-key mode-line-map key))))
86 '([(shift button3)] [(shift button3up)])))))
89 (lambda (key) (cons key (lookup-key mouse-map key))))
90 (list x-button-s-middle x-button-s-middle-up
91 x-button-s-right x-button-s-right-up)))
94 (lambda (key) (cons key (aref mouse::global-map key))))
95 (list (mouse::index mouse-middle mouse-shift)
96 (mouse::index mouse-middle mouse-shift-up)
97 (mouse::index mouse-right mouse-shift)
98 (mouse::index mouse-right mouse-shift-up)
100 (mouse::index mouse-mode-middle mouse-shift)
101 (mouse::index mouse-mode-middle mouse-shift-up)
102 (mouse::index mouse-mode-right mouse-shift)
103 (mouse::index mouse-mode-right mouse-shift-up)
108 (cons key (mousemap-get
109 (mouse-list-to-mouse-code key)
110 current-global-mousemap))))
117 '((shift left) (shift up left)
121 '(text scrollbar modeline minibuffer)))
127 (setq key (mouse-list-to-mouse-code key))
128 (cons key (mousemap-get
129 key current-global-mousemap))))
141 '(text scrollbar modeline minibuffer)))
145 (lambda (key-str) (apollo-mouse-key-and-binding
147 '("M2S" "M2U" "M3S" "M3U")))
150 (defun hmouse-setup ()
151 "Binds mouse keys for use as Smart Keys."
153 (or hmouse-bindings-flag hmouse-previous-bindings
154 (setq hmouse-previous-bindings (hmouse-get-bindings)))
155 ;; Ensure Gillespie's Info mouse support is off since
156 ;; Hyperbole handles that.
157 (setq Info-mouse-support nil)
159 (cond ;; GNU Emacs 19
160 ((if (not noninteractive) hyperb:emacs19-p)
161 (setq hmouse-set-point-command 'mouse-set-point)
162 (if (memq window-system '(ns dps))
163 ;; NEXTSTEP offers only 2 shift-mouse buttons which we use
164 ;; as the Smart Keys.
166 (global-set-key [S-down-mouse-1] 'action-key-depress-emacs19)
167 (global-set-key [S-mouse-1] 'action-mouse-key-emacs19)
168 (global-set-key [S-double-mouse-1] 'action-mouse-key-emacs19)
169 (global-set-key [S-triple-mouse-1] 'action-mouse-key-emacs19)
170 (global-set-key [S-down-mouse-2] 'assist-key-depress-emacs19)
171 (global-set-key [S-mouse-2] 'assist-mouse-key-emacs19)
172 (global-set-key [S-double-mouse-2] 'assist-mouse-key-emacs19)
173 (global-set-key [S-triple-mouse-2] 'assist-mouse-key-emacs19)
174 (global-set-key [vertical-line S-down-mouse-1] 'action-key-depress-emacs19)
175 (global-set-key [vertical-line S-mouse-1] 'action-mouse-key-emacs19)
176 (global-set-key [vertical-line S-down-mouse-2]
177 'assist-key-depress-emacs19)
178 (global-set-key [vertical-line S-mouse-2]
179 'assist-mouse-key-emacs19)
180 (global-set-key [mode-line S-down-mouse-1] 'action-key-depress-emacs19)
181 (global-set-key [mode-line S-mouse-1] 'action-mouse-key-emacs19)
182 (global-set-key [mode-line S-down-mouse-2] 'assist-key-depress-emacs19)
183 (global-set-key [mode-line S-mouse-2] 'assist-mouse-key-emacs19))
185 (global-set-key [S-down-mouse-2] 'action-key-depress-emacs19)
186 (global-set-key [S-mouse-2] 'action-mouse-key-emacs19)
187 (global-set-key [S-double-mouse-2] 'action-mouse-key-emacs19)
188 (global-set-key [S-triple-mouse-2] 'action-mouse-key-emacs19)
189 (global-set-key [S-down-mouse-3] 'assist-key-depress-emacs19)
190 (global-set-key [S-mouse-3] 'assist-mouse-key-emacs19)
191 (global-set-key [S-double-mouse-3] 'assist-mouse-key-emacs19)
192 (global-set-key [S-triple-mouse-3] 'assist-mouse-key-emacs19)
193 (global-set-key [vertical-line S-down-mouse-2] 'action-key-depress-emacs19)
194 (global-set-key [vertical-line S-mouse-2] 'action-mouse-key-emacs19)
195 (global-set-key [vertical-line S-down-mouse-3]
196 'assist-key-depress-emacs19)
197 (global-set-key [vertical-line S-mouse-3]
198 'assist-mouse-key-emacs19)
199 (global-set-key [mode-line S-down-mouse-2] 'action-key-depress-emacs19)
200 (global-set-key [mode-line S-mouse-2] 'action-mouse-key-emacs19)
201 (global-set-key [mode-line S-down-mouse-3] 'assist-key-depress-emacs19)
202 (global-set-key [mode-line S-mouse-3] 'assist-mouse-key-emacs19)))
205 ((if (not noninteractive) hyperb:xemacs-p)
206 ;; Set mouse bindings under XEmacs, even if not under a window
207 ;; system since it can have frames on ttys and windowed displays at
209 (setq hmouse-set-point-command 'hmouse-move-point-xemacs)
210 (global-set-key '(shift button2) 'action-key-depress)
211 (global-set-key '(shift button2up) 'action-mouse-key)
212 (if (fboundp 'infodock-set-mouse-bindings)
213 (infodock-set-mouse-bindings)
214 (if (boundp 'mode-line-map)
215 (progn (define-key mode-line-map '(shift button3)
217 (define-key mode-line-map '(shift button3up)
220 (global-set-key '(shift button3) 'assist-key-depress)
221 (global-set-key '(shift button3up) 'assist-mouse-key)))
224 ((equal hyperb:window-system "xterm")
225 (setq hmouse-set-point-command 'x-mouse-set-point)
226 (define-key mouse-map x-button-s-middle 'action-key-depress)
227 (define-key mouse-map x-button-s-middle-up 'action-mouse-key)
228 (define-key mouse-map x-button-s-right 'assist-key-depress)
229 (define-key mouse-map x-button-s-right-up 'assist-mouse-key)
230 ;; Use these instead of the above for a true META-BUTTON binding.
231 ;; (define-key mouse-map x-button-m-middle 'assist-key-depress)
232 ;; (define-key mouse-map x-button-m-middle-up 'assist-mouse-key)
236 ((equal hyperb:window-system "epoch")
237 (setq hmouse-set-point-command 'mouse::set-point)
238 (global-set-mouse mouse-middle mouse-shift 'action-key-depress)
239 (global-set-mouse mouse-middle mouse-shift-up 'action-mouse-key)
240 (global-set-mouse mouse-right mouse-shift 'assist-key-depress)
241 (global-set-mouse mouse-right mouse-shift-up 'assist-mouse-key)
242 ;; Modeline mouse map
243 (global-set-mouse mouse-mode-middle mouse-shift 'action-key-depress)
244 (global-set-mouse mouse-mode-middle mouse-shift-up 'action-mouse-key)
245 (global-set-mouse mouse-mode-right mouse-shift 'assist-key-depress)
246 (global-set-mouse mouse-mode-right mouse-shift-up
251 ((equal hyperb:window-system "next")
252 (setq hmouse-set-point-command 'hmouse-move-point-eterm)
253 ;; Use left button to set point.
254 ;; Use shift-left button instead of non-existent middle as Action Key.
258 (global-set-mouse (cons region '(shift left)) 'action-key-depress)
259 (global-set-mouse (cons region '(shift up left)) 'action-mouse-key)
260 (global-set-mouse (cons region '(shift right)) 'assist-key-depress)
261 (global-set-mouse (cons region '(shift up right))
263 ;; Use these instead of the above for a true META-BUTTON binding.
264 ;; (global-set-mouse (cons region '(meta right)) 'assist-key-depress)
265 ;; (global-set-mouse (cons region '(meta up right)) 'assist-mouse-key)
267 '(text scrollbar modeline minibuffer))
271 ((equal hyperb:window-system "sun")
272 (setq hmouse-set-point-command 'hmouse-move-point-eterm)
276 (global-set-mouse (cons region '(shift middle)) 'action-key-depress)
277 (global-set-mouse (cons region '(shift up middle))
279 (global-set-mouse (cons region '(shift right)) 'assist-key-depress)
280 (global-set-mouse (cons region '(shift up right))
282 ;; Use these instead of the above for a true META-BUTTON binding.
283 ;; (global-set-mouse (cons region '(meta middle)) 'assist-key-depress)
284 ;; (global-set-mouse (cons region '(meta up middle)) 'assist-mouse-key)
286 '(text scrollbar modeline minibuffer))
290 ((equal hyperb:window-system "apollo")
291 (setq hmouse-set-point-command 'apollo-mouse-move-point)
292 (bind-apollo-mouse-button "M2S" 'action-key-depress)
293 (bind-apollo-mouse-button "M2U" 'action-mouse-key)
294 (bind-apollo-mouse-button "M3S" 'assist-key-depress)
295 (bind-apollo-mouse-button "M3U" 'assist-mouse-key)
297 (setq hmouse-bindings (hmouse-get-bindings)
298 hmouse-bindings-flag t))
300 ;;; hmouse-sh.el ends here