annotate lisp/hyperbole/hmouse-key.el @ 7:c153ca296910

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