annotate lisp/hyperbole/hmouse-drv.el @ 123:c77884c6318d

Added tag r20-1b14 for changeset d2f30a177268
author cvs
date Mon, 13 Aug 2007 09:26:04 +0200
parents cf808b4c4290
children
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-drv.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Smart Key/Mouse driver functions.
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 ;; ORIG-DATE: 04-Feb-90
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 100
diff changeset
10 ;; LAST-MOD: 22-Feb-97 at 14:16:55 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; This file is part of Hyperbole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; Available for use and distribution under the same terms as GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; Copyright (C) 1989-1995, Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; Developed with support from Motorola Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (require 'hypb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar action-key-depress-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 "The last window in which the Action Key was depressed or nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defvar assist-key-depress-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 "The last window in which the Assist Key was depressed or nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar action-key-release-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "The last window in which the Action Key was released or nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar assist-key-release-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "The last window in which the Assist Key was released or nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defvar action-key-depress-prev-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "Marker at point prior to last Action Key depress.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 Note that this may be a buffer different than where the depress occurs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar assist-key-depress-prev-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "Marker at point prior to last Assist Key depress.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Note that this may be a buffer different than where the depress occurs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defvar action-key-release-prev-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Marker at point prior to last Action Key release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 Note that this may be a buffer different than where the release occurs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar assist-key-release-prev-point nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "Marker at point prior to last Assist Key release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 Note that this may be a buffer different than where the release occurs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (defvar action-key-cancelled nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 "When non-nil, cancels last Action Key depress.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvar assist-key-cancelled nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "When non-nil, cancels last Assist Key depress.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar action-key-help-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "When non-nil, forces display of help for next Action Key release.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defvar assist-key-help-flag nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "When non-nil, forces display of help for next Assist Key release.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; Hyperbole context-sensitive key driver functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defun action-mouse-key (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "Set point to the current mouse cursor position and execute 'action-key'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Any ARGS will be passed to 'hmouse-function'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; Make this a no-op if some local mouse key binding overrode the global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; action-key-depress command invocation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (if action-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (let ((hkey-alist hmouse-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (setq action-key-depressed-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (cond (action-key-cancelled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (setq action-key-cancelled nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 assist-key-depressed-flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (assist-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (hmouse-function nil nil args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ((action-mouse-key-help nil args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (t (hmouse-function 'action-key nil args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defun assist-mouse-key (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 "Set point to the current mouse cursor position and execute 'assist-key'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Any ARGS will be passed to 'hmouse-function'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; Make this a no-op if some local mouse key binding overrode the global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; assist-key-depress command invocation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (if assist-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (let ((hkey-alist hmouse-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (setq assist-key-depressed-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (cond (assist-key-cancelled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (setq assist-key-cancelled nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 action-key-depressed-flag nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (action-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (hmouse-function nil t args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ((action-mouse-key-help t args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (t (hmouse-function 'assist-key t args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun hmouse-function (func assist-flag set-point-arg-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 "Executes FUNC for Action Key (Assist Key with ASSIST-FLAG non-nil) and sets point from SET-POINT-ARG-LIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 FUNC may be nil in which case no function is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 SET-POINT-ARG-LIST is passed to the call of the command bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 'hmouse-set-point-command'. Returns nil if 'hmouse-set-point-command' variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 is not bound to a valid function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (if (fboundp hmouse-set-point-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (let ((release-args (hmouse-set-point set-point-arg-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if assist-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (setq assist-key-release-window (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 assist-key-release-args release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 assist-key-release-prev-point (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq action-key-release-window (selected-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 action-key-release-args release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 action-key-release-prev-point (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (and (eq major-mode 'br-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (setq action-mouse-key-prev-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (if (br-in-view-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (br-next-listing-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq action-mouse-key-prefix-arg current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (if (null func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (funcall func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq action-mouse-key-prev-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 action-mouse-key-prefix-arg nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun action-mouse-key-help (assist-flag args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "If a Smart Key help flag is set and the other Smart Key is not down, shows help.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Takes two args: ASSIST-FLAG should be non-nil iff command applies to the Assist Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ARGS is a list of arguments passed to 'hmouse-function'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Returns t if help is displayed, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (let ((help-shown)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (other-key-released (not (if assist-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 action-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 assist-key-depressed-flag))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (setq help-shown
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (cond ((and action-key-help-flag other-key-released)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (setq action-key-help-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (hmouse-function 'hkey-help assist-flag args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ((and assist-key-help-flag other-key-released)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (setq assist-key-help-flag nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (hmouse-function 'assist-key-help assist-flag args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if help-shown
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; Then both Smart Keys have been released.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (progn (setq action-key-cancelled nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 assist-key-cancelled nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defun action-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "Use one key to perform functions that vary by buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 Default function is given by 'action-key-default-function' variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 Returns t unless 'action-key-default-function' variable is not bound to a valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (or (hkey-execute nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (fboundp action-key-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (progn (funcall action-key-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defun assist-key ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "Use one assist-key to perform functions that vary by buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 Default function is given by 'assist-key-default-function' variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 Returns non-nil unless 'assist-key-default-function' variable is not bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 to a valid function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (or (hkey-execute t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (if (fboundp assist-key-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (progn (funcall assist-key-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (defun hkey-execute (assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 "Evaluate Action Key form (or Assist Key form with ASSIST-FLAG non-nil) for first non-nil predicate from 'hkey-alist'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 Non-nil ASSIST-FLAG means evaluate second form, otherwise evaluate first form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 Returns non-nil iff a non-nil predicate is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (let ((pred-forms hkey-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (pred-form) (pred-t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (while (and (null pred-t) (setq pred-form (car pred-forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if (setq pred-t (eval (car pred-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (eval (if assist-flag (cdr (cdr pred-form)) (car (cdr pred-form))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (setq pred-forms (cdr pred-forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 pred-t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defun hkey-help (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 "Display help for the Action Key command in current context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 With optional ASSIST-FLAG non-nil, display help for the Assist Key command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 Returns non-nil iff associated help documentation is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (require 'hsite)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (let ((pred-forms hkey-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (pred-form) (pred-t) (call) (cmd-sym) (doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (while (and (null pred-t) (setq pred-form (car pred-forms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (or (setq pred-t (eval (car pred-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (setq pred-forms (cdr pred-forms))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (if pred-t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (setq call (if assist-flag (cdr (cdr pred-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (car (cdr pred-form)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 cmd-sym (car call))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setq cmd-sym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if assist-flag assist-key-default-function action-key-default-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 call cmd-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq hkey-help-msg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (if (and cmd-sym (symbolp cmd-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (setq doc (documentation cmd-sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (let* ((condition (car pred-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (temp-buffer-show-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (lambda (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (if (br-in-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (let ((owind (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (br-to-view-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (select-window (previous-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (display-buffer buf 'other-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (select-window owind)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (display-buffer buf 'other-win)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (temp-buffer-show-function temp-buffer-show-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (with-output-to-temp-buffer (hypb:help-buf-name "Smart")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (princ (format "A click of the %s Key"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (if assist-flag "Assist" "Action")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (princ "WHEN ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (princ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (or condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "there is no matching context"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (princ "CALLS ") (princ call)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if doc (progn (princ " WHICH:") (terpri) (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (princ doc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (if (memq cmd-sym '(hui:hbut-act hui:hbut-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (princ (format "\n\nBUTTON SPECIFICS:\n\n%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (actype:doc 'hbut:current t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (hattr:report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (nthcdr 2 (hattr:list 'hbut:current)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (message "No %s Key command for current context."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if assist-flag "Assist" "Action"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 doc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defun assist-key-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Display doc associated with Assist Key command in current context.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 Returns non-nil iff associated documentation is found."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (hkey-help 'assist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defun hkey-help-hide ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "Restores frame to configuration prior to help buffer display.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 Point must be in the help buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (let ((buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if *hkey-wconfig*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (set-window-configuration *hkey-wconfig*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (switch-to-buffer (other-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (bury-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq *hkey-wconfig* nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
272 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defun hkey-help-show (buffer &optional current-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "Saves prior frame configuration if BUFFER displays help. Displays BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 Optional second arg CURRENT-WINDOW non-nil forces display of buffer within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 the current window. By default, it is displayed in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if (bufferp buffer) (setq buffer (buffer-name buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (and (stringp buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (string-match "Help\\*$" buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (not (memq t (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (lambda (wind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "Help\\*$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (buffer-name (window-buffer wind)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (hypb:window-list 'no-mini))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq *hkey-wconfig* (current-window-configuration)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (let* ((buf (get-buffer-create buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (wind (if current-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (progn (switch-to-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (display-buffer buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (setq minibuffer-scroll-window wind)))
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 hkey-operate (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "Uses the keyboard to emulate Smart Mouse Key drag actions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 Each invocation alternates between starting a drag and ending it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 Prefix ARG non-nil means emulate Assist Key rather than the Action Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 Only works when running under a window system, not from a dumb terminal."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (or hyperb:window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (hypb:error "(hkey-operate): Drag actions require mouse support"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (if assist-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (progn (assist-mouse-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (message "Assist Key released."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (assist-key-depress)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "Assist Key depressed; go to release point and hit {%s %s}."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (substitute-command-keys "\\[universal-argument]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (substitute-command-keys "\\[hkey-operate]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if action-key-depressed-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (progn (action-mouse-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (message "Action Key released."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (action-key-depress)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (message "Action Key depressed; go to release point and hit {%s}."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (substitute-command-keys "\\[hkey-operate]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun hkey-summarize (&optional current-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "Displays smart key operation summary in help buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 Optional arg CURRENT-WINDOW non-nil forces display of buffer within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 the current window. By default, it is displayed in another window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (let* ((doc-file (hypb:mouse-help-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (buf-name (hypb:help-buf-name "Smart"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (wind (get-buffer-window buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 owind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (if (file-readable-p doc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (if (br-in-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (br-to-view-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq owind (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (if wind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (select-window wind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (hkey-help-show buf-name current-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (select-window (get-buffer-window buf-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (setq buffer-read-only nil) (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (insert-file-contents doc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (select-window owind))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defvar action-key-depress-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "List of mouse event args from most recent depress of the Action Key.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defvar assist-key-depress-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "List of mouse event args from most recent depress of the Assist Key.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defvar action-key-release-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "List of mouse event args from most recent release of the Action Key.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defvar assist-key-release-args nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "List of mouse event args from most recent release of the Assist Key.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (defvar action-mouse-key-prev-window nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 "Window point was in prior to current invocation of 'action/assist-mouse-key'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defvar action-mouse-key-prefix-arg nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "Prefix argument to pass to 'smart-br-cmd-select'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defvar action-key-depressed-flag nil "t while Action Key is depressed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defvar assist-key-depressed-flag nil "t while Assist Key is depressed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (defvar hkey-help-msg "" "Holds last Smart Key help message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defvar *hkey-wconfig* nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "Screen configuration prior to display of a help buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 ;;; public support functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; "hsite.el" contains documentation for this variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (or (boundp 'smart-scroll-proportional) (setq smart-scroll-proportional nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; The smart keys scroll buffers when pressed at the ends of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; These next two functions do the scrolling and keep point at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; of line to simplify repeated scrolls when using keyboard smart keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; These functions may also be used to test whether the scroll action would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; be successful, no action is taken if it would fail (because the beginning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;; or end of a buffer is already showing) and nil is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; t is returned whenever scrolling is performed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (defun smart-scroll-down ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "Scrolls down according to value of smart-scroll-proportional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 If smart-scroll-proportional is nil or if point is on the bottom window line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 scrolls down (backward) a windowful. Otherwise, tries to bring current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 to bottom of window. Leaves point at end of line and returns t if scrolled,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 nil if not."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (let ((rtn t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (if smart-scroll-proportional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; If selected line is already last in window, then scroll backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;; a windowful, otherwise make it last in window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (if (>= (point) (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (goto-char (1- (window-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (if (pos-visible-in-window-p (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (setq rtn nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (scroll-down))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (recenter -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (if (pos-visible-in-window-p (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (setq rtn nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (scroll-down)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (or rtn (progn (beep) (message "Beginning of buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 rtn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defun smart-scroll-up ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 "Scrolls up according to value of smart-scroll-proportional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 If smart-scroll-proportional is nil or if point is on the top window line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 scrolls up (forward) a windowful. Otherwise, tries to bring current line to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 top of window. Leaves point at end of line and returns t if scrolled, nil if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 not."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (let ((rtn t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if smart-scroll-proportional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; If selected line is already first in window, then scroll forward a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; windowful, otherwise make it first in window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (<= (point) (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (goto-char (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if (pos-visible-in-window-p (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (setq rtn nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (scroll-up))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (recenter 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (if (pos-visible-in-window-p (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (setq rtn nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (scroll-up)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (or rtn (progn (beep) (message "End of buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 rtn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (provide 'hmouse-drv)