annotate lisp/hyperbole/hui-window.el @ 36:c53a95d3c46d r19-15b101

Import from CVS: tag r19-15b101
author cvs
date Mon, 13 Aug 2007 08:53:38 +0200
parents 376386a54a3c
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: hui-window.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Smart Mouse Key window and modeline depress/release actions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library, Load only when mouse is available.
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., PWDG
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: 21-Sep-92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; LAST-MOD: 6-Oct-95 at 12:56:48 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) 1992-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 ;; Must be loaded AFTER hmouse-alist has been defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; "hui-mouse.el".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Handles drags in same window or across windows and modeline depresses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; What drags and modeline presses do.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; ==============================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; Smart Keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Context Action Key Assist Key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; ==============================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Drag horizontally within window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Left to right Scroll to buffer end Split window across
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Right to left Scroll to buffer begin Delete window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Click in modeline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Left window edge Bury buffer Unbury bottom buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Right window edge Info Smart Key Summary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Otherwise Action Key Hook Assist Key Hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Modeline depress & wind release Resize window height <- same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Drag from shared window side Resize window's width <- same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Drag from one window to another Create/modify a link but Swap buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; Drag vertically within window Split window sideways <- same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Drag diagonally within window Save ring frame-config Restore ring config
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; Public variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar action-key-modeline-hook 'hmouse-context-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "A list of functions to call when the Action Mouse Key is clicked in the center portion of a modeline.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defvar assist-key-modeline-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 "A list of functions to call when the Assist Mouse Key is clicked in the center portion of a modeline.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvar hmouse-edge-sensitivity 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 "*Number of characters from window edges within which a click is considered at an edge.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defvar hmouse-side-sensitivity (if hyperb:emacs19-p 2 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "*Characters in either direction from window side within which a click is considered on the side.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar hmouse-x-drag-sensitivity 5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "*Number of chars mouse must move horizontally between depress/release to register a horizontal drag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defvar hmouse-y-drag-sensitivity 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "*Number of lines mouse must move vertically between depress/release to register a vertical drag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defvar hmouse-x-diagonal-sensitivity 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "*Number of chars mouse must move horizontally between depress/release to register a diagonal drag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar hmouse-y-diagonal-sensitivity 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "*Number of lines mouse must move vertically between depress/release to register a diagonal drag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; Add mode line handling to hmouse-alist dispatch table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if (not (boundp 'hmouse-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "\"hui-modeln.el\": hmouse-alist must be defined before loading this.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (or (memq 'hmouse-drag-window-side
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (mapcar (function (lambda (elt) (let ((pred (car elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (if (listp pred) (car pred)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 hmouse-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (setq hmouse-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ((hmouse-drag-window-side) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ((hmouse-resize-window-side) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (hmouse-resize-window-side 'assist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ((setq hkey-value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (and (not (hmouse-drag-between-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (hmouse-drag-horizontally))) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ((hmouse-horizontal) . (hmouse-horizontal-assist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ((hmouse-modeline-depress) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ((action-key-modeline) . (assist-key-modeline)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ((hmouse-drag-between-windows) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ((hui:link-directly) . (hmouse-swap-buffers 'assist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ((hmouse-drag-vertically) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ((sm-split-window-horizontally) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (sm-split-window-horizontally)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ((setq hkey-value (hmouse-drag-diagonally)) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ((wconfig-ring-save) .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (wconfig-yank-pop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (prefix-numeric-value current-prefix-arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 hmouse-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defun hmouse-drag-between-windows ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "Returns non-nil if last Action Key depress and release were in different windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 If free variable 'assist-flag' is non-nil, uses Assist Key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (if assist-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (and assist-key-depress-window assist-key-release-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (not (eq assist-key-depress-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 assist-key-release-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (and action-key-depress-window action-key-release-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (not (eq action-key-depress-window action-key-release-window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun hmouse-drag-diagonally ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 "Returns non-nil iff last Action Key use was a diagonal drag within a single window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 If free variable 'assist-flag' is non-nil, uses Assist Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Value returned is nil if not a diagonal drag, or one of the following symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 depending on the direction of the drag: southeast, southwest, northwest, northeast."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (let ((last-depress-x) (last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (last-depress-y) (last-release-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if assist-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (setq last-depress-x (hmouse-x-coord assist-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 last-release-x (hmouse-x-coord assist-key-release-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 last-depress-y (hmouse-y-coord assist-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 last-release-y (hmouse-y-coord assist-key-release-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq last-depress-x (hmouse-x-coord action-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 last-release-x (hmouse-x-coord action-key-release-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 last-depress-y (hmouse-y-coord action-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 last-release-y (hmouse-y-coord action-key-release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (and last-depress-x last-release-x last-depress-y last-release-y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (>= (- (max last-depress-x last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (min last-depress-x last-release-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 hmouse-x-diagonal-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (>= (- (max last-depress-y last-release-y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (min last-depress-y last-release-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 hmouse-y-diagonal-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ((< last-depress-x last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if (< last-depress-y last-release-y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 'southeast 'northeast))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (t (if (< last-depress-y last-release-y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 'southwest 'northwest))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun hmouse-drag-horizontally ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "Returns non-nil iff last Action Key use was a horizontal drag within a single window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 If free variable 'assist-flag' is non-nil, uses Assist Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Value returned is nil if not a horizontal drag, 'left if drag moved left or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 'right otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (let ((last-depress-x) (last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (last-depress-y) (last-release-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if assist-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq last-depress-x (hmouse-x-coord assist-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 last-release-x (hmouse-x-coord assist-key-release-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 last-depress-y (hmouse-y-coord assist-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 last-release-y (hmouse-y-coord assist-key-release-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq last-depress-x (hmouse-x-coord action-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 last-release-x (hmouse-x-coord action-key-release-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 last-depress-y (hmouse-y-coord action-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 last-release-y (hmouse-y-coord action-key-release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (and last-depress-x last-release-x last-depress-y last-release-y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (>= (- (max last-depress-x last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (min last-depress-x last-release-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 hmouse-x-drag-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; Don't want to register vertical drags here, so ensure any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; vertical movement was less than the vertical drag sensitivity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (< (- (max last-depress-y last-release-y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (min last-depress-y last-release-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 hmouse-y-drag-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (if (< last-depress-x last-release-x) 'right 'left))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defun hmouse-drag-vertically ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "Returns non-nil iff last Action Key use was a vertical drag within a single window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 If free variable 'assist-flag' is non-nil, uses Assist Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 Value returned is nil if not a vertical line drag, 'up if drag moved up or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 'down otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (let ((last-depress-x) (last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (last-depress-y) (last-release-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if assist-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq last-depress-x (hmouse-x-coord assist-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 last-release-x (hmouse-x-coord assist-key-release-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 last-depress-y (hmouse-y-coord assist-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 last-release-y (hmouse-y-coord assist-key-release-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (setq last-depress-x (hmouse-x-coord action-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 last-release-x (hmouse-x-coord action-key-release-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 last-depress-y (hmouse-y-coord action-key-depress-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 last-release-y (hmouse-y-coord action-key-release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (and last-depress-x last-release-x last-depress-y last-release-y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (>= (- (max last-depress-y last-release-y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (min last-depress-y last-release-y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 hmouse-y-drag-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; Don't want to register horizontal drags here, so ensure any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; horizontal movement was less than or equal to the horizontal drag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; sensitivity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (<= (- (max last-depress-x last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (min last-depress-x last-release-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 hmouse-x-drag-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (< last-depress-y last-release-y) 'down 'up))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (or (fboundp 'abs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defun abs (number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "Return the absolute value of NUMBER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ((< number 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (- 0 number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (t number))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun hmouse-drag-window-side ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 "Returns non-nil if Action Key was dragged from a window side divider.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 If free variable 'assist-flag' is non-nil, uses Assist Key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (cond (hyperb:xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; Depress events in scrollbars or in non-text area of buffer are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; not visible or identifiable at the Lisp-level, so always return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (hyperb:window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (let* ((depress-args (if assist-flag assist-key-depress-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 action-key-depress-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (release-args (if assist-flag assist-key-release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 action-key-release-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (w (smart-window-of-coords depress-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (side-ln (and w (1- (nth 2 (window-edges w)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (last-press-x (hmouse-x-coord depress-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (last-release-x (hmouse-x-coord release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (and last-press-x last-release-x side-ln
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (/= last-press-x last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (/= (1+ side-ln) (frame-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (<= (max (- last-press-x side-ln) (- side-ln last-press-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 hmouse-side-sensitivity))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (defun sm-split-window-horizontally ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 "Splits current window in two evenly, side by side.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 Beeps and prints message if can't split window further."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (let ((window-min-width 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (split-window-horizontally nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (error (progn (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 "(sm-split-window-horizontally): Can't split window further."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defun sm-split-window-vertically ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "Splits current window in two evenly, one above the other.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 Beeps and prints message if can't split window further."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (let ((window-min-height 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if (fboundp 'split-window-quietly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (split-window-quietly nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (split-window-vertically nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "(sm-split-window-vertically): Can't split window further."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun smart-coords-in-window-p (coords window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "Tests if COORDS are in WINDOW. Returns WINDOW if they are, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (cond ((and hyperb:emacs19-p (eventp coords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (eq (posn-window (event-start coords)) window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ((if hyperb:xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if (eventp coords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (eq (event-window coords) window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (eq (car coords) window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ((fboundp 'window-edges)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (let* ((edges (window-edges window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (w-xmin (nth 0 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (w-ymin (nth 1 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (w-xmax (nth 2 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (w-ymax (nth 3 edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (x (hmouse-x-coord coords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (y (hmouse-y-coord coords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (and (<= w-xmin x) (<= x w-xmax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (<= w-ymin y) (<= y w-ymax)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defun smart-window-of-coords (coords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "Returns window in which COORDS fall or nil if none.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 Ignores minibuffer window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (cond ((and hyperb:emacs19-p (eventp coords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (posn-window (event-start coords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ((if hyperb:xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if (eventp coords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (event-window coords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (car coords))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (t (let ((window-list (hypb:window-list 'no-minibuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (while (and (not window) window-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq w (car window-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 window-list (cdr window-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 window (smart-coords-in-window-p coords w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;;; ************************************************************************
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 hmouse-context-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "If running under a window system, display or hide the buffer menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 If not running under a window system and Smart Menus are loaded, display the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 appropriate Smart Menu for the context at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (if (and (fboundp 'smart-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (or (null window-system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (not (or hyperb:lemacs-p hyperb:emacs19-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (smart-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (let ((wind (get-buffer-window "*Buffer List*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 owind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (if wind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (progn (setq owind (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (select-window wind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (bury-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (select-window owind))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (buffer-menu nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun hmouse-horizontal ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "Goes to buffer end if drag was to the right, otherwise goes to beginning."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if (eq hkey-value 'right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (end-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (beginning-of-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (defun hmouse-horizontal-assist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "Splits window vertically if drag was to the right, otherwise deletes window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if (eq hkey-value 'right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (sm-split-window-vertically)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (delete-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defun action-key-modeline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "Handles Action Key depresses on a window mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 If key is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (1) clicked on left edge of a window's modeline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 window's buffer is buried (placed at bottom of buffer list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (2) clicked on right edge of a window's modeline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 the Info buffer is displayed, or if already displayed and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 modeline clicked belongs to a window displaying Info, the Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 buffer is hidden;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (3) clicked anywhere in the middle of a window's modeline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 the functions listed in 'action-key-modeline-hook' are called;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (4) dragged vertically from modeline to within a window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 the modeline is moved to point of key release, thereby resizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 its window and potentially its vertical neighbors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (let ((w (smart-window-of-coords action-key-depress-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if w (select-window w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (cond ((hmouse-modeline-click)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (cond ((hmouse-release-left-edge) (bury-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ((hmouse-release-right-edge)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (eq major-mode 'Info-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (Info-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (t (run-hooks 'action-key-modeline-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (t (hmouse-modeline-resize-window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun assist-key-modeline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "Handles Assist Key depresses on a window mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 If secondary key is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (1) clicked on left edge of a window's modeline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 bottom buffer in buffer list is unburied and placed in window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (2) clicked on right edge of a window's modeline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 the summary of Smart Key behavior is displayed, or if already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 displayed and the modeline clicked belongs to a window displaying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 the summary, the summary buffer is hidden;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (3) clicked anywhere in the middle of a window's modeline,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 the functions listed in 'assist-key-modeline-hook' are called;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (4) dragged vertically from modeline to within a window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 the modeline is moved to point of key release, thereby resizing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 its window and potentially its vertical neighbors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (let ((buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (w (smart-window-of-coords assist-key-depress-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if w (select-window w))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (cond ((hmouse-modeline-click 'assist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (cond ((hmouse-release-left-edge 'assist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (if (fboundp 'last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (switch-to-buffer (car (last (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (setq buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (switch-to-buffer (nth (1- (length buffers)) buffers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ((hmouse-release-right-edge 'assist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (if (equal (buffer-name) (hypb:help-buf-name "Smart"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (hkey-help-hide)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (hkey-summarize 'current-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (t (run-hooks 'assist-key-modeline-hook))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (t (hmouse-modeline-resize-window 'assist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun hmouse-modeline-click (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 "Returns non-nil if last Action Key depress and release was at same point in a modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 Optional ASSIST-FLAG non-nil means test for Assist Key click instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 ;; Assume depress was in modeline and that any drag has already been handled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; So just check that release was in modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (hmouse-modeline-release assist-flag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defun hmouse-modeline-depress ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "Returns non-nil if Action Key was depressed on a window mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 If free variable 'assist-flag' is non-nil, uses Assist Key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (let ((args (if assist-flag assist-key-depress-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 action-key-depress-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (and hyperb:window-system args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if (fboundp 'event-over-modeline-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (event-over-modeline-p args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (let* ((w (smart-window-of-coords args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (mode-ln (if w (nth 3 (window-edges w))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (last-press-y (hmouse-y-coord args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; Mode-line is always 1 less than the bottom of the window, unless it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; is a minibuffer window which does not have a modeline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (if (not (eq w (minibuffer-window))) (setq mode-ln (1- mode-ln)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (and last-press-y mode-ln (= last-press-y mode-ln)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defun hmouse-modeline-release (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "Returns non-nil if Action Key was released on a window mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 Optional non-nil ASSIST-FLAG means test release of Assist Key instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (let ((args (if assist-flag assist-key-release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 action-key-release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (if (and hyperb:window-system args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (if (fboundp 'event-over-modeline-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (event-over-modeline-p args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (let* ((w (smart-window-of-coords args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (mode-ln (and w (1- (nth 3 (window-edges w)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (last-press-y (hmouse-y-coord args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (and last-press-y mode-ln (= last-press-y mode-ln)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun hmouse-modeline-resize-window (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 "Resizes window whose mode line was depressed upon by the Action Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Resize amount depends upon the vertical difference between press and release
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 of the Action Key. Optional arg ASSIST-FLAG non-nil means use values from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 Assist Key instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (cond ((not hyperb:window-system) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ((and hyperb:xemacs-p (not (fboundp 'window-edges)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (error "Drag from a mode-line with button1 to resize windows."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (t (let* ((owind (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (window (smart-window-of-coords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if assist-flag assist-key-depress-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 action-key-depress-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (mode-ln (and window (1- (nth 3 (window-edges window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (last-release-y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (hmouse-y-coord
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (if assist-flag assist-key-release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 action-key-release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (shrink-amount (- mode-ln last-release-y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; Restore position of point prior to Action Key release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (if action-key-release-prev-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (marker-buffer action-key-release-prev-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (goto-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (marker-position action-key-release-prev-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ((>= (+ mode-ln 2) (frame-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "(hmouse-modeline-resize-window): Can't move bottom window in frame."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ((< (length (hypb:window-list 'no-minibuf)) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "(hmouse-modeline-resize-window): Can't resize sole window in frame."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (t (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (shrink-window shrink-amount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; Keep redisplay from scrolling other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (select-window (next-window nil 'no-mini))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (scroll-down shrink-amount)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (select-window owind))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (defun hmouse-release-left-edge (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 "Returns non-nil if last Action Key release was at left window edge.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 'hmouse-edge-sensitivity' value determines how near to actual edge the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 release must be."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (let ((args (if assist-flag assist-key-release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 action-key-release-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 window-left last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (if (fboundp 'window-lowest-p) ;; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (setq last-release-x (and args (eq (event-window args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (hmouse-x-coord args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 window-left 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq window-left (car (window-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 last-release-x (and args (hmouse-x-coord args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (and last-release-x (< (- last-release-x window-left)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 hmouse-edge-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (>= (- last-release-x window-left) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (defun hmouse-release-right-edge (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 "Returns non-nil if last Action Key release was at right window edge.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 'hmouse-edge-sensitivity' value determines how near to actual edge the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 release must be."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (let ((args (if assist-flag assist-key-release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 action-key-release-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 window-right last-release-x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (if (fboundp 'window-lowest-p) ;; XEmacs >= 19.12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (setq last-release-x (and args (eq (event-window args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (hmouse-x-coord args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 window-right (window-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (setq window-right (nth 2 (window-edges))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 last-release-x (and args (hmouse-x-coord args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (and last-release-x (>= (+ last-release-x hmouse-edge-sensitivity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 window-right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (>= (- window-right last-release-x) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (defun hmouse-resize-window-side (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 "Resizes window whose side was depressed upon by the Action Key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 Resize amount depends upon the horizontal difference between press and release
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 of the Action Key. Optional arg ASSIST-FLAG non-nil means use values from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 Assist Key instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (cond (hyperb:xemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; Depress events in scrollbars or in non-text area of buffer are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;; not visible or identifiable at the Lisp-level, so always return
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (hyperb:window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (let* ((owind (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (window (smart-window-of-coords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (if assist-flag assist-key-depress-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 action-key-depress-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (side-ln (and window (1- (nth 2 (window-edges window)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (last-release-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (hmouse-x-coord
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (if assist-flag assist-key-release-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 action-key-release-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (shrink-amount (- side-ln last-release-x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; Restore position of point prior to Action Key release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if action-key-release-prev-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (let ((obuf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (set-buffer (marker-buffer action-key-release-prev-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (goto-char (marker-position action-key-release-prev-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (set-buffer obuf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ((>= (+ side-ln 2) (frame-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "(hmouse-resize-window-side): Can't change width of full frame width window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ((< (length (hypb:window-list 'no-minibuf)) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 "(hmouse-resize-window-side): Can't resize sole window in frame."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (t (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (select-window window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (shrink-window-horizontally shrink-amount))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (select-window owind))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (defun hmouse-swap-buffers (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 "Swaps buffers in windows selected with last Action Key depress and release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 If optional arg ASSIST-FLAG is non-nil, uses Assist Key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (let* ((w1 (if assist-flag assist-key-depress-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 action-key-depress-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (w2 (if assist-flag assist-key-release-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 action-key-release-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (w1-buf (and w1 (window-buffer w1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (w2-buf (and w2 (window-buffer w2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (or (and w1 w2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (error "(hmouse-swap-buffers): Last depress or release not within a window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;; Swap window buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (set-window-buffer w1 w2-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (set-window-buffer w2 w1-buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (defun hmouse-swap-windows (&optional assist-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 "Swaps windows selected with last Action Key depress and release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 If optional arg ASSIST-FLAG is non-nil, uses Assist Key."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (let* ((w1 (if assist-flag assist-key-depress-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 action-key-depress-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (w2 (if assist-flag assist-key-release-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 action-key-release-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (w1-width (and w1 (window-width w1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (w1-height (and w1 (window-height w1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (w2-width (and w2 (window-width w2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (w2-height (and w2 (window-height w2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (or (and w1 w2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (error "(hmouse-swap-windows): Last depress or release not within a window."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (select-window w1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (if (not (= w1-height (frame-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (shrink-window (- w1-height w2-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (if (not (= w1-width (frame-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (shrink-window-horizontally (- w1-width w2-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (select-window w2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (setq w2-width (window-width w2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 w2-height (window-height w2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (if (not (= w2-height (frame-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (shrink-window (- w2-height w1-height)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (if (not (= w2-width (frame-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (shrink-window-horizontally (- w2-width w1-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (select-window w2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defun hmouse-x-coord (args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 "Returns x coordinate in chars from window system dependent ARGS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (let ((x (eval (cdr (assoc hyperb:window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 '(("emacs19" . (if (eventp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (+ (car (posn-col-row
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (event-start args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (nth 0 (window-edges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (car (cdr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ("lemacs" . (if (eventp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (event-x args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ("xterm" . (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ("epoch" . (nth 0 args)) ;; Epoch V4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ("sun" . (nth 1 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ("next" . (nth 1 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ("apollo" . (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (if (integerp x) x (error "(hmouse-x-coord): invalid X coord: %s" x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defun hmouse-y-coord (args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 "Returns y coordinate in frame lines from window system dependent ARGS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (let ((y (eval (cdr (assoc hyperb:window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 '(("emacs19" . (if (eventp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (+ (cdr (posn-col-row
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (event-start args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (nth 1 (window-edges
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (car (cdr args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (cdr args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ("lemacs" . (if (eventp args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (event-y args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (cdr args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ("xterm" . (nth 1 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ("epoch" . (nth 1 args)) ;; Epoch V4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ("sun" . (nth 2 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ("next" . (nth 2 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ("apollo" . (nth 1 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (if (integerp y) y (error "(hmouse-y-coord): invalid Y coord: %s" y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;;; Private variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (provide 'hui-window)