annotate lisp/hyperbole/hmouse-key.el @ 32:e04119814345 r19-15b99

Import from CVS: tag r19-15b99
author cvs
date Mon, 13 Aug 2007 08:52:56 +0200
parents 4103f0995bd7
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: hmouse-key.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Load "hmouse-sh.el" or "hmouse-reg.el" for Smart Key bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: hypermedia, mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 30-May-94 at 00:11:57
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
12 ;; LAST-MOD: 21-Feb-97 at 18:03:12 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This file is part of Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
17 ;; Copyright (C) 1994-1995, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; Developed with support from Motorola Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Supports Epoch, Lucid Emacs, X, Sunview, NEXTSTEP, and Apollo DM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; window systems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
25 ;; `hmouse-shift-buttons' globally binds the Action and Assist Mouse Keys
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; to either shifted or unshifted mouse buttons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
28 ;; `hmouse-toggle-bindings' may be bound to a key. It switches between
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; the Hyperbole mouse bindings and previous mouse key bindings any time
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
30 ;; after `hmouse-shift-buttons' has been called.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (require 'hversion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (require 'hmouse-drv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (require 'h-skip-bytec "h-skip-bytec.lsp")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
46 (if (or hyperb:xemacs-p hyperb:emacs19-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
47 ;; XEmacs and Emacs 19 pre-load their mouse libraries, so
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
48 ;; we shouldn't have to require them here.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
49 nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
50 (eval (cdr (assoc hyperb:window-system
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
51 '(
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
52 ("xterm" . (require 'x-mouse)) ; X
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
53 ("epoch" . (require 'mouse)) ; UofI Epoch
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
54 ("next" . (load "eterm-fns" t)) ; NeXTstep
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
55 ("sun" . (require 'sun-fns)) ; SunView
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
56 ("apollo" . (require 'apollo)) ; Display Manager
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
57 )))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defun hmouse-set-bindings (key-binding-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Sets mouse keys used as Smart Keys to bindings in KEY-BINDING-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 KEY-BINDING-LIST is the value returned by 'hmouse-get-bindings' prior to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Smart Key setup."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (cond
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
68 ;; Do nothing when running in batch mode.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
69 (noninteractive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; GNU Emacs 19, Lucid Emacs, XEmacs or InfoDock
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
72 ((or hyperb:xemacs-p hyperb:emacs19-p (equal hyperb:window-system "lemacs"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (lambda (key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (global-set-key (car key-and-binding) (cdr key-and-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 key-binding-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ((equal hyperb:window-system "xterm")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (lambda (key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (define-key mouse-map (car key-and-binding) (cdr key-and-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 key-binding-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; Epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ((equal hyperb:window-system "epoch")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (lambda (key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (aset mouse::global-map (car key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (cdr key-and-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 key-binding-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; SunView or NeXT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ((or (equal hyperb:window-system "next")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (equal hyperb:window-system "sun"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (lambda (key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (global-set-mouse (car key-and-binding) (cdr key-and-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 key-binding-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; Apollo Display Manager
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ((equal hyperb:window-system "apollo")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (string< emacs-version "18.58")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (lambda (key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (global-set-key (car key-and-binding) (cdr key-and-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 key-binding-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (lambda (key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (define-key 'apollo-prefix (car key-and-binding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (cdr key-and-binding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 key-binding-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defun hmouse-shift-buttons (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Selects between shifted and unshifted Action and Assist mouse buttons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 With optional prefix ARG, use shifted buttons if ARG is positive or use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 unshifted buttons otherwise. If ARG is nil, shifted buttons are used and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 under InfoDock the middle button also acts as an Action Key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (setq hmouse-shift-flag (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (> (prefix-numeric-value arg) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (not (and (boundp 'infodock-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 infodock-version))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if hmouse-shift-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; Action Key = shift-middle mouse key. Assist Key = shift-right mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; key. Standard Hyperbole configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (load "hmouse-sh")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; Action Key = middle mouse key; Assist Key = right mouse key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; InfoDock actually moves the Assist Key to the shift-right mouse key so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; that the right key can be used for popup menus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (load "hmouse-reg"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; Replace any original mouse bindings before moving Hyperbole bindings and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; then force reinitialization of hmouse-previous-bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if (and hmouse-bindings-flag hmouse-previous-bindings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (hmouse-set-bindings hmouse-previous-bindings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (setq hmouse-bindings-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 hmouse-previous-bindings nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; Initialize Hyperbole mouse bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (hmouse-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (message "%s Action and Assist mouse buttons in use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if hmouse-shift-flag "Shifted" "Unshifted"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (defun hmouse-toggle-bindings ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 "Toggles between Smart Key mouse settings and their prior bindings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (let ((key-binding-list (if hmouse-bindings-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 hmouse-previous-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 hmouse-bindings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (other-list-var (if hmouse-bindings-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 'hmouse-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 'hmouse-previous-bindings)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (if key-binding-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (set other-list-var (hmouse-get-bindings))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (hmouse-set-bindings key-binding-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (message "%s mouse bindings in use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if (setq hmouse-bindings-flag (not hmouse-bindings-flag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "Smart Key" "Personal")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (error "(hmouse-toggle-bindings): Null %s." other-list-var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defun hmouse-set-point-at (set-point-arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "Sets point to cursor position using SET-POINT-ARG-LIST and returns t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 If 'hmouse-set-point-command' is not bound to a function, this does nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 and returns nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (if (fboundp hmouse-set-point-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if (and (boundp 'drag-zone) drag-zone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (progn (delete-zone drag-zone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (setq drag-zone nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (and (boundp 'drag-button) drag-button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (progn (delete-button drag-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq drag-button nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (or (if set-point-arg-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (funcall hmouse-set-point-command set-point-arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (funcall hmouse-set-point-command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if (fboundp 'bind-apollo-mouse-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (if (string< emacs-version "18.58")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defun apollo-mouse-key-and-binding (mouse-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "Returns binding for an Apollo MOUSE-BUTTON (a string) or nil if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (interactive "sMouse Button: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let ((numeric-code (cdr (assoc mouse-button *apollo-mouse-buttons*))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (null numeric-code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (error "(hmouse-key): %s is not a valid Apollo mouse key name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 mouse-button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if (stringp numeric-code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq numeric-code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (cdr (assoc numeric-code *apollo-mouse-buttons*))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (let ((key-sequence (concat "\M-*" (char-to-string numeric-code))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (cons key-sequence (global-key-binding key-sequence)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun apollo-mouse-key-and-binding (mouse-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "Returns binding for an Apollo MOUSE-BUTTON (a string) or nil if none."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (interactive "sMouse Button: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (let ((numeric-code (cdr (assoc mouse-button *apollo-mouse-buttons*))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (if (null numeric-code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (error "(hmouse-key): %s is not a valid Apollo mouse key name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 mouse-button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (stringp numeric-code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq numeric-code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (cdr (assoc numeric-code *apollo-mouse-buttons*))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((key-sequence (char-to-string numeric-code)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (cons key-sequence (lookup-key 'apollo-prefix key-sequence)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defun apollo-mouse-move-point (&optional no-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Used so that pressing the left mouse button, moving the cursor, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 releasing the left mouse button leaves the mark set to the initial position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 and the point set to the final position. Useful for easily marking regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 of text. If the left mouse button is pressed and released at the same place,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 the mark is left at the original position of the character cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 Returns (x y) frame coordinates of point in columns and lines."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (let* ((opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (owindow (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (x (- (read-char) 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (y (- (read-char) 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (edges (window-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (window nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (while (and (not (eq window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (or (< y (nth 1 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (>= y (nth 3 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (< x (nth 0 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (>= x (nth 2 edges))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (setq window (next-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq edges (window-edges window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (and window (not (eq window (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if (and (not *apollo-mouse-move-point-allow-minibuffer-exit*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (eq (selected-window) (minibuffer-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (error "Cannot use mouse to leave minibuffer!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (if (eq window (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (error "Cannot use mouse to enter minibuffer!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (if window (select-window window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (move-to-window-line (- y (nth 1 edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (let* ((width-1 (1- (window-width window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (wraps (/ (current-column) width-1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (prompt-length (if (eq (selected-window) (minibuffer-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (minibuffer-prompt-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (move-to-column (+ (- x (nth 0 edges) prompt-length)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (* wraps width-1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (if no-mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (progn (setq window (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if (eq owindow window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (if (equal opoint (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (pop-mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (select-window owindow)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (pop-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (select-window window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (set-mark-command nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; Return (x y) coords of point in column and frame line numbers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (list x y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun action-key-depress (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq action-key-depress-prev-point (point-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 action-key-depressed-flag t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 action-key-depress-args (hmouse-set-point args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 action-key-depress-window (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 action-key-release-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 action-key-release-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 action-key-release-prev-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if assist-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (or action-key-help-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setq assist-key-help-flag t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defun assist-key-depress (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq assist-key-depress-prev-point (point-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 assist-key-depressed-flag t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 assist-key-depress-args (hmouse-set-point args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 assist-key-depress-window (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 assist-key-release-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 assist-key-release-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 assist-key-release-prev-point nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if action-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (or assist-key-help-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (setq action-key-help-flag t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun action-key-depress-emacs19 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (action-key-depress event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun assist-key-depress-emacs19 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (assist-key-depress event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defun action-mouse-key-emacs19 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Set point to the current mouse cursor position and execute 'action-key'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 EVENT will be passed to 'hmouse-function'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (action-mouse-key (hmouse-key-release-args-emacs19 event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (defun assist-mouse-key-emacs19 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "Set point to the current mouse cursor position and execute 'action-key'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 EVENT will be passed to 'hmouse-function'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (assist-mouse-key (hmouse-key-release-args-emacs19 event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun hmouse-key-release-args-emacs19 (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (let ((ev-type-str (and (listp event) (symbol-name (car event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (if (or (and ev-type-str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (string-match "\\(double\\|triple\\)-mouse" ev-type-str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (not (= (length event) 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; Remove depress coordinates and send only release coordinates.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (list (car event) (nth 2 event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defun hmouse-move-point-xemacs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (mouse-set-point current-mouse-event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; Catch "not in a window" errors, e.g. on modeline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defun hmouse-move-point-eterm (arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (apply 'mouse-move-point arg-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defvar hmouse-bindings nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "List of (key . binding) pairs for Smart Mouse Keys.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (defvar hmouse-bindings-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "True if Smart Key mouse bindings are in use, else nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defvar hmouse-previous-bindings nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "List of previous (key . binding) pairs for mouse keys used as Smart Keys.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (provide 'hmouse-key)