annotate lisp/mouse.el @ 367:a4f53d9b3154 r21-1-13

Import from CVS: tag r21-1-13
author cvs
date Mon, 13 Aug 2007 11:01:07 +0200
parents 70ad99077275
children cc15677e0335
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; mouse.el --- window system-independent mouse support.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1988, 1992-4, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Copyright (C) 1995, 1996 Ben Wing.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; Keywords: mouse, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27 ;;; Synched up with: Not synched with FSF. Almost completely divergent.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31 ;; This file is dumped with XEmacs (when window system support is compiled in).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 (provide 'mouse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37 (global-set-key 'button1 'mouse-track)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 (global-set-key '(shift button1) 'mouse-track-adjust)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 (global-set-key '(control button1) 'mouse-track-insert)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 (global-set-key '(control shift button1) 'mouse-track-delete-and-insert)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 (global-set-key '(meta button1) 'mouse-track-do-rectangle)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
43 ;; drops are now handled in dragdrop.el (ograf@fga.de)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
44
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 ;; enable drag regions (ograf@fga.de)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 ;; if button2 is dragged from within a region, this becomes a drop
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
47 ;;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
48 ;; this must be changed to the new api
249
83b3d10dcba9 Import from CVS: tag r20-5b23
cvs
parents: 243
diff changeset
49 (if (featurep '(or offix cde mswindows))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50 (global-set-key 'button2 'mouse-drag-or-yank)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 (global-set-key 'button2 'mouse-yank))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
53 (defgroup mouse nil
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
54 "Window system-independent mouse support."
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
55 :group 'editing)
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
56
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 (defcustom mouse-track-rectangle-p nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 "*If true, then dragging out a region with the mouse selects rectangles
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 instead of simple start/end regions."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 :group 'mouse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 (defcustom mouse-yank-at-point nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 "*If non-nil, the function `mouse-yank' will yank text at the cursor location.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 Otherwise, the cursor will be moved to the location of the pointer click before
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 text is inserted."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 :type 'boolean
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 :group 'mouse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 (defcustom mouse-highlight-text 'context
367
a4f53d9b3154 Import from CVS: tag r21-1-13
cvs
parents: 298
diff changeset
71 "*Choose the default double-click highlighting behavior.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 If set to `context', double-click will highlight words when the mouse
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 is at a word character, or a symbol if the mouse is at a symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 character.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75 If set to `word', double-click will always attempt to highlight a word.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 If set to `symbol', double-click will always attempt to highlight a
367
a4f53d9b3154 Import from CVS: tag r21-1-13
cvs
parents: 298
diff changeset
77 symbol (the default behavior in previous XEmacs versions)."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78 :type '(choice (const context)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79 (const word)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 (const symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 :group 'mouse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83 (defvar mouse-yank-function 'mouse-consolidated-yank
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
84 "Function that is called upon by `mouse-yank' to actually insert text.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
85
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86 (defun mouse-consolidated-yank ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 (interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 (case (device-type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 (x (x-yank-function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 (tty (yank))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 (otherwise (yank))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 (defun mouse-select ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 "Select Emacs window the mouse is on."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (interactive "@"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 (defun mouse-delete-window ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 "Delete the Emacs window the mouse is on."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 (interactive "@")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 (delete-window))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 (defun mouse-keep-one-window ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 "Select Emacs window mouse is on, then kill all other Emacs windows."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (interactive "@")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 (delete-other-windows))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108 (defun mouse-select-and-split ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 "Select Emacs window mouse is on, then split it vertically in half."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 (interactive "@")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 (split-window-vertically nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 (defun mouse-set-point (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114 "Select Emacs window mouse is on, and move point to mouse position."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 (let ((window (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117 (pos (event-point event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118 (close-pos (event-closest-point event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 (or window (error "not in a window"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 (select-window window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121 (if (and pos (> pos 0))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 ;; If the event was over a text char, it's easy.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 (goto-char (max (min pos (point-max)) (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 (if (and close-pos (> close-pos 0))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 (goto-char (max (min close-pos (point-max)) (point-min)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 ;; When the event occurs outside of the frame directly to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 ;; left or right of a modeline, close-point is nil, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 ;; event-over-modeline is also nil. That will drop us to this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 ;; point. So instead of erroring, just return nil.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 nil))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 (defun mouse-yank (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 "Paste text with the mouse.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 If the variable `mouse-yank-at-point' is nil, then pasting occurs at the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 location of the click; otherwise, pasting occurs at the current cursor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 location."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 (and (not mouse-yank-at-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 (mouse-set-point event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 (funcall mouse-yank-function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 (defun click-inside-extent-p (click extent)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
143 "Return non-nil if the button event is within the primary selection-extent.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
144 Return nil otherwise."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 ;; stig@hackvan.com
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (let ((ewin (event-window click))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 (epnt (event-point click)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 (and ewin
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 epnt
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 (eq (window-buffer ewin)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 (extent-object extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 (extent-start-position extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 (> epnt (extent-start-position extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 (> (extent-end-position extent) epnt))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 (defun click-inside-selection-p (click)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 (or (click-inside-extent-p click primary-selection-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 (click-inside-extent-p click zmacs-region-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160 ))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162 (defun point-inside-extent-p (extent)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
163 "Return t if point is within the bounds of the primary selection extent.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
164 Return t is point is at the end position of the extent.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
165 Return nil otherwise."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 ;; stig@hackvan.com
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 (and extent
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
168 (eq (current-buffer)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 (extent-object extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 (> (point) (extent-start-position extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 (>= (extent-end-position extent) (point))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 (defun point-inside-selection-p ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174 ;; by Stig@hackvan.com
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175 (or (point-inside-extent-p primary-selection-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176 (point-inside-extent-p zmacs-region-extent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 (defun mouse-drag-or-yank (event)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
179 "Either drag or paste the current selection.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
180 If the variable `mouse-yank-at-point' is non-nil,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
181 move the cursor to the location of the click before pasting.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
182 This functions has to be improved. Currently it is just a (working) test."
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 ;; by Oliver Graf <ograf@fga.de>
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 (if (click-inside-extent-p event zmacs-region-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 ;; okay, this is a drag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 (cond ((featurep 'offix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188 (offix-start-drag-region event
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 (extent-start-position zmacs-region-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190 (extent-end-position zmacs-region-extent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 ((featurep 'cde)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192 ;; should also work with CDE
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
193 (cde-start-drag-region event
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
194 (extent-start-position zmacs-region-extent)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
195 (extent-end-position zmacs-region-extent)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196 (t (error "No offix or CDE support compiled in")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 ;; no drag, call region-funct
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 (and (not mouse-yank-at-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 (mouse-set-point event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200 (funcall mouse-yank-function))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 (defun mouse-eval-sexp (click force-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204 "Evaluate the sexp under the mouse. Usually, this is the last sexp before
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 the click, but if you click on a left paren, then it is the sexp beginning
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206 with the paren that is evaluated. Also, since strings evaluate to themselves,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 they're fed to re-search-forward and the matched region is highlighted until
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 the mouse button is released.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 Perhaps the most useful thing about this function is that the evaluation of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211 the expression which is clicked upon is relative not to the window where you
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 click, but to the current window and the current position of point. Thus,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 you can use `mouse-eval-sexp' to interactively test code that acts upon a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214 buffer...something you cannot do with the standard `eval-last-sexp' function.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 It's also fantastic for debugging regular expressions."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 ;; by Stig@hackvan.com
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217 (interactive "e\nP")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 (let (exp val result-str)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219 (setq exp (save-window-excursion
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
220 (save-excursion
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
221 (mouse-set-point click)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
223 (or (looking-at "(") (forward-sexp -1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224 (read (point-marker))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225 (cond ((stringp exp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 (if (setq val (re-search-forward exp nil t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227 (let* ((oo (make-extent (match-beginning 0) (match-end 0))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228 (set-extent-face oo 'highlight)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229 (set-extent-priority oo 1000)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230 ;; wait for button release...
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231 (setq unread-command-event (next-command-event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232 (delete-extent oo))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 (message "Regex \"%s\" not found" exp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 (ding nil 'quiet)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235 (t (setq val (if (fboundp 'eval-interactive)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
236 (eval-interactive exp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237 (eval exp)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 (setq result-str (prin1-to-string val))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 ;; #### -- need better test
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 (if (and (not force-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 (<= (length result-str) (window-width (selected-window))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (message "%s" result-str)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 (with-output-to-temp-buffer "*Mouse-Eval*"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 (condition-case nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 (pprint val)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 (error (prin1 val))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247 )))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
249 (defun mouse-line-length (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 "Print the length of the line indicated by the pointer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
253 (mouse-set-point event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 (message "Line length: %d" (- (point-at-eol) (point-at-bol))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 (sleep-for 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257 (defun mouse-set-mark (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 "Select Emacs window mouse is on, and set mark at mouse position.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
259 Display cursor at that position for a second."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261 (let ((point-save (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262 (unwind-protect
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
263 (progn (mouse-set-point event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 (push-mark nil t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265 (sit-for 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266 (goto-char point-save))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268 (defun mouse-scroll (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 "Scroll point to the mouse position."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 (mouse-set-point event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273 (recenter 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 (scroll-right (event-x event))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276 (defun mouse-del-char (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277 "Delete the char pointed to by the mouse."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 (mouse-set-point event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281 (delete-char 1 nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 (defun mouse-kill-line (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 "Kill the line pointed to by the mouse."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 (mouse-set-point event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 (kill-line nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290 (defun mouse-bury-buffer (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 "Bury the buffer pointed to by the mouse, thus selecting the next one."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 (save-selected-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 (select-window (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 (bury-buffer)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
296
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 (defun mouse-unbury-buffer (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 "Unbury and select the most recently buried buffer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300 (save-selected-window
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301 (select-window (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302 (let* ((bufs (buffer-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 (entry (1- (length bufs)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 val)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 (while (not (setq val (nth entry bufs)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 val (and (/= (aref (buffer-name val) 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307 ? )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 val)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
309 (setq entry (1- entry)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 (switch-to-buffer val))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 (defun narrow-window-to-region (m n)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
313 "Narrow window to region between point and last mark"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 (interactive "r")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316 (save-restriction
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 (if (eq (selected-window) (next-window))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 (split-window))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319 (goto-char m)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 (recenter 0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321 (if (eq (selected-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
322 (if (zerop (minibuffer-depth))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
323 (next-window)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 (shrink-window (- (- (window-height) (count-lines m n)) 1))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 (defun mouse-window-to-region (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 "Narrow window to region between cursor and mouse pointer."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 (interactive "@e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 (let ((point-save (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
331 (unwind-protect
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332 (progn (mouse-set-point event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 (push-mark nil t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 (sit-for 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335 (goto-char point-save)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 (narrow-window-to-region (region-beginning) (region-end)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
338 (defun mouse-ignore ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339 "Don't do anything."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340 (interactive))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 ;;; mouse/selection tracking
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344 ;;; generalized mouse-track
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 (defvar default-mouse-track-normalize-point-function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347 'default-mouse-track-normalize-point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
348 "Function called to normalize position of point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
349 Called with two arguments: TYPE depends on the number of times that the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
350 mouse has been clicked and is a member of `default-mouse-track-type-list',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
351 FORWARDP determines the direction in which the point should be moved.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
352
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
353 (defvar mouse-track-down-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
354 "Function or functions called when the user presses the mouse.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
355 This hook is invoked by `mouse-track'; thus, it will not be called
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356 for any buttons with a different binding. The functions will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357 called with two arguments: the button-press event and a click
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 count (see `mouse-track-click-hook').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 If any function returns non-nil, the remaining functions will not be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361 called.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 Note that most applications should take action when the mouse is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364 released, not when it is pressed.'")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366 (defvar mouse-track-drag-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 "Function or functions called when the user drags the mouse.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368 This hook is invoked by `mouse-track'; thus, it will not be called
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 for any buttons with a different binding. The functions will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 called with three arguments: the mouse-motion event, a click
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 count (see `mouse-track-click-hook'), and whether the call to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 this hook occurred as a result of a drag timeout (see
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373 `mouse-track-scroll-delay').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375 If any function returns non-nil, the remaining functions will not be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 called.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 Note that no calls to this function will be made until the user
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 initiates a drag (i.e. moves the mouse more than a certain
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 threshold in either the X or the Y direction, as defined by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 `mouse-track-x-threshold' and `mouse-track-y-threshold').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 See also `mouse-track-drag-up-hook'.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 (defvar mouse-track-drag-up-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 "Function or functions called when the user finishes a drag.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 This hook is invoked by `mouse-track'; thus, it will not be called
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 for any buttons with a different binding. The functions will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 called with two arguments: the button-press event and a click
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 count (see `mouse-track-click-hook').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 If any function returns non-nil, the remaining functions will not be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 called.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 Note that this hook will not be invoked unless the user has
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 initiated a drag, i.e. moved the mouse more than a certain threshold
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 (see `mouse-track-drag-hook'). When this function is invoked,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 `mouse-track-drag-hook' will have been invoked at least once.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400 See also `mouse-track-click-hook'.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402 (defvar mouse-track-click-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 "Function or functions called when the user clicks the mouse.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404 `Clicking' means pressing and releasing the mouse without having
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 initiated a drag (i.e. without having moved more than a certain
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
406 threshold -- see `mouse-track-drag-hook').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
407
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
408 This hook is invoked by `mouse-track'; thus, it will not be called
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
409 for any buttons with a different binding. The functions will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
410 called with two arguments: the button-release event and a click
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
411 count, which specifies the number of times that the mouse has been
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
412 clicked in a series of clicks, each of which is separated by at most
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
413 `mouse-track-multi-click-time'. This can be used to implement actions
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
414 that are called on double clicks, triple clicks, etc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
415
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
416 If any function returns non-nil, the remaining functions will not be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
417 called.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
418
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
419 See also `mouse-track-drag-up-hook.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
420
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
421 (defvar mouse-track-up-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
422 "Function or functions called when the user releases the mouse.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
423 This hook is invoked by `mouse-track'; thus, it will not be called
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
424 for any buttons with a different binding. The functions will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
425 called with two arguments: the button-release event and a click
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
426 count (see `mouse-track-click-hook').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
427
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
428 For many applications, it is more appropriate to use one or both
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
429 of `mouse-track-click-hook' and `mouse-track-drag-up-hook'.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
430
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
431 (defvar mouse-track-cleanup-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
432 "Function or functions called when `mouse-track' terminates.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
433 This hook will be called in all circumstances, even upon a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
434 non-local exit out of `mouse-track', and so is useful for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
435 doing cleanup work such as removing extents that may have
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
436 been created during the operation of `mouse-track'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
437
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
438 Unlike all of the other mouse-track hooks, this is a \"normal\"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
439 hook: the hook functions are called with no arguments, and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
440 all hook functions are called regardless of their return
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
441 values.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
442
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
443 (defcustom mouse-track-multi-click-time 400
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
444 "*Maximum number of milliseconds allowed between clicks for a multi-click.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
445 See `mouse-track-click-hook'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
446 :type 'integer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
447 :group 'mouse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
448
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
449 (defcustom mouse-track-scroll-delay 100
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
450 "Maximum of milliseconds between calls to `mouse-track-drag-hook'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
451 If the user is dragging the mouse (i.e. the button is held down and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
452 a drag has been initiated) and does not move the mouse for this many
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
453 milliseconds, the hook will be called with t as the value of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
454 WAS-TIMEOUT parameter. This can be used to implement scrolling
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
455 in a selection when the user drags the mouse out the window it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
456 was in.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
457
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
458 A value of nil disables the timeout feature."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
459 :type '(choice integer (const :tag "Disabled" nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
460 :group 'mouse)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
461
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
462 (defvar mouse-track-x-threshold '(face-width 'default)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
463 "Minimum number of pixels in the X direction for a drag to be initiated.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
464 If the mouse is moved more than either the X or Y threshold while the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
465 button is held down (see also `mouse-track-y-threshold'), then a drag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
466 is initiated; otherwise the gesture is considered to be a click.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
467 See `mouse-track'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
468
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
469 The value should be either a number of a form to be evaluated to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
470 produce a number.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
471
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
472 (defvar mouse-track-y-threshold '(face-height 'default)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
473 "Minimum number of pixels in the Y direction for a drag to be initiated.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
474 If the mouse is moved more than either the X or Y threshold while the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
475 button is held down (see also `mouse-track-x-threshold'), then a drag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
476 is initiated; otherwise the gesture is considered to be a click.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
477 See `mouse-track'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
478
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
479 The value should be either a number of a form to be evaluated to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
480 produce a number.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
481
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
482 ;; these variables are private to mouse-track.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
483 (defvar mouse-track-up-time nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
484 (defvar mouse-track-up-x nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
485 (defvar mouse-track-up-y nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
486 (defvar mouse-track-timeout-id nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
487 (defvar mouse-track-click-count nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
488
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
489 (defun mouse-track-set-timeout (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
490 (if mouse-track-timeout-id
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
491 (disable-timeout mouse-track-timeout-id))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
492 (if mouse-track-scroll-delay
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
493 (setq mouse-track-timeout-id
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
494 (add-timeout (/ mouse-track-scroll-delay 1000.0)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
495 'mouse-track-scroll-undefined
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
496 (copy-event event)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
497
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
498 (defun mouse-track-run-hook (hook event &rest args)
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
499 ;; ugh, can't use run-hook-with-args-until-success because we have
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
500 ;; to get the value using symbol-value-in-buffer. Doing a
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
501 ;; save-excursion/set-buffer is wrong because the hook might want to
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
502 ;; change the buffer, but just doing a set-buffer is wrong because
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
503 ;; the hook might not want to change the buffer.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
504 ;; #### What we need here is a Lisp interface to
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
505 ;; run_hook_with_args_in_buffer. Here is a poor man's version.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
506 (let ((buffer (event-buffer event)))
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
507 (and mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
508 (when buffer
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
509 (let ((value (symbol-value-in-buffer hook buffer nil)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
510 (if (and (listp value) (not (eq (car value) 'lambda)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
511 ;; List of functions.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
512 (let (retval)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
513 (while (and value (null retval))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
514 ;; Found `t': should process default value. We could
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
515 ;; splice it into the buffer-local value, but that
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
516 ;; would cons, which is not a good thing for
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
517 ;; mouse-track hooks.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
518 (if (eq (car value) t)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
519 (let ((global (default-value hook)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
520 (if (and (listp global) (not (eq (car global) 'lambda)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
521 ;; List of functions.
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
522 (while (and global
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
523 (null (setq retval
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
524 (apply (car global) event args))))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
525 (pop global))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
526 ;; lambda
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
527 (setq retval (apply (car global) event args))))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
528 (setq retval (apply (car value) event args)))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
529 (pop value))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
530 retval)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
531 ;; lambda
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 209
diff changeset
532 (apply value event args))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
533
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
534 (defun mouse-track-scroll-undefined (random)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
535 ;; the old implementation didn't actually define this function,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
536 ;; and in normal use it won't ever be called because the timeout
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
537 ;; will either be removed before it fires or will be picked off
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
538 ;; with next-event and not dispatched. However, if you're
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
539 ;; attempting to debug a click-hook (which is pretty damn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
540 ;; difficult to do), this function may get called.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
541 )
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
542
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
543 (defun mouse-track (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
544 "Make a selection with the mouse. This should be bound to a mouse button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
545 The behavior of XEmacs during mouse selection is customizable using various
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
546 hooks and variables: see `mouse-track-click-hook', `mouse-track-drag-hook',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
547 `mouse-track-drag-up-hook', `mouse-track-down-hook', `mouse-track-up-hook',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
548 `mouse-track-cleanup-hook', `mouse-track-multi-click-time',
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
549 `mouse-track-scroll-delay', `mouse-track-x-threshold', and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
550 `mouse-track-y-threshold'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
551
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
552 Default handlers are provided to implement standard selecting/positioning
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
553 behavior. You can explicitly request this default behavior, and override
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
554 any custom-supplied handlers, by using the function `mouse-track-default'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
555 instead of `mouse-track'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
556
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
557 Default behavior is as follows:
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
558
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
559 If you click-and-drag, the selection will be set to the region between the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
560 point of the initial click and the point at which you release the button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
561 These positions need not be ordered.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
562
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
563 If you click-and-release without moving the mouse, then the point is moved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
564 and the selection is disowned (there will be no selection owner). The mark
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
565 will be set to the previous position of point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
566
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
567 If you double-click, the selection will extend by symbols instead of by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
568 characters. If you triple-click, the selection will extend by lines.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
569
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
570 If you drag the mouse off the top or bottom of the window, you can select
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
571 pieces of text which are larger than the visible part of the buffer; the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
572 buffer will scroll as necessary.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
573
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
574 The selected text becomes the current X Selection. The point will be left
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
575 at the position at which you released the button, and the mark will be left
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
576 at the initial click position."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
577 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
578 (let ((mouse-down t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
579 (xthresh (eval mouse-track-x-threshold))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
580 (ythresh (eval mouse-track-y-threshold))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
581 (orig-x (event-x-pixel event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
582 (orig-y (event-y-pixel event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
583 (buffer (event-buffer event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
584 (mouse-grabbed-buffer (event-buffer event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
585 mouse-moved)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
586 (if (or (not mouse-track-up-x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
587 (not mouse-track-up-y)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
588 (not mouse-track-up-time)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
589 (> (- (event-timestamp event) mouse-track-up-time)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
590 mouse-track-multi-click-time)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
591 (> (abs (- mouse-track-up-x orig-x)) xthresh)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
592 (> (abs (- mouse-track-up-y orig-y)) ythresh))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
593 (setq mouse-track-click-count 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
594 (setq mouse-track-click-count (1+ mouse-track-click-count)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
595 (if (not (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
596 (error "Not over a window."))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
597 (mouse-track-run-hook 'mouse-track-down-hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
598 event mouse-track-click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
599 (unwind-protect
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
600 (while mouse-down
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
601 (setq event (next-event event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
602 (cond ((motion-event-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
603 (if (and (not mouse-moved)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
604 (or (> (abs (- (event-x-pixel event) orig-x))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
605 xthresh)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
606 (> (abs (- (event-y-pixel event) orig-y))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
607 ythresh)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
608 (setq mouse-moved t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
609 (if mouse-moved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
610 (mouse-track-run-hook 'mouse-track-drag-hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
611 event mouse-track-click-count nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
612 (mouse-track-set-timeout event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
613 ((and (timeout-event-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
614 (eq (event-function event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
615 'mouse-track-scroll-undefined))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
616 (if mouse-moved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
617 (mouse-track-run-hook 'mouse-track-drag-hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
618 (event-object event) mouse-track-click-count t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
619 (mouse-track-set-timeout (event-object event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
620 ((button-release-event-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
621 (setq mouse-track-up-time (event-timestamp event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
622 (setq mouse-track-up-x (event-x-pixel event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
623 (setq mouse-track-up-y (event-y-pixel event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
624 (setq mouse-down nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
625 (mouse-track-run-hook 'mouse-track-up-hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
626 event mouse-track-click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
627 (if mouse-moved
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
628 (mouse-track-run-hook 'mouse-track-drag-up-hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
629 event mouse-track-click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
630 (mouse-track-run-hook 'mouse-track-click-hook
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
631 event mouse-track-click-count)))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
632 ((or (key-press-event-p event)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
633 (and (misc-user-event-p event)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
634 (eq (event-function event) 'cancel-mode-internal)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
635 (error "Selection aborted"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
636 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
637 (dispatch-event event))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
638 ;; protected
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
639 (if mouse-track-timeout-id
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
640 (disable-timeout mouse-track-timeout-id))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
641 (setq mouse-track-timeout-id nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
642 (and buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
643 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
644 (set-buffer buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
645 (run-hooks 'mouse-track-cleanup-hook))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
646
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
647
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
648 ;;;;;;;;;;;; default handlers: new version of mouse-track
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
649
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
650 (defvar default-mouse-track-type nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
651 (defvar default-mouse-track-type-list '(char word line))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
652 (defvar default-mouse-track-window nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
653 (defvar default-mouse-track-extent nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
654 (defvar default-mouse-track-adjust nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
655 (defvar default-mouse-track-min-anchor nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
656 (defvar default-mouse-track-max-anchor nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
657 (defvar default-mouse-track-result nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
658 (defvar default-mouse-track-down-event nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
659
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
660 ;; D. Verna Feb. 17 1998
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
661 ;; This function used to assume that when (event-window event) differs from
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
662 ;; window, we have to scroll. This is WRONG, for instance when there are
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
663 ;; toolbars on the side, in which case window-event returns nil.
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
664 (defun default-mouse-track-set-point-in-window (event window)
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
665 (if (event-over-modeline-p event)
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
666 nil ;; Scroll
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
667 ;; Not over a modeline
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
668 (if (eq (event-window event) window)
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
669 (let ((p (event-closest-point event)))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
670 (if (or (not p) (not (pos-visible-in-window-p p window)))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
671 nil ;; Scroll
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
672 (mouse-set-point event)
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
673 t))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
674 ;; Not over a modeline, not the same window. Check if the Y position
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
675 ;; is still overlapping the original window.
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
676 (let* ((edges (window-pixel-edges window))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
677 (row (event-y-pixel event))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
678 (text-start (nth 1 edges))
367
a4f53d9b3154 Import from CVS: tag r21-1-13
cvs
parents: 298
diff changeset
679 (text-end (nth 3 edges)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
680 (if (or (< row text-start)
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
681 (> row text-end))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
682 nil ;; Scroll
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
683 ;; The Y pos in overlapping the original window. Check however if
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
684 ;; the position is really visible, because there could be a
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
685 ;; scrollbar or a modeline at this place.
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
686 ;; Find the mean line height (height / lines nb), and approximate
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
687 ;; the line number for Y pos.
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
688 (select-window window)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
689 (let ((line (/ (* (- row text-start) (window-height))
255
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
690 (- text-end text-start))))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
691 (if (not (save-excursion
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
692 (goto-char (window-start))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
693 (pos-visible-in-window-p
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
694 (point-at-bol (+ 1 line)))))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
695 nil ;; Scroll
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
696 ;; OK, we can go to that position
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
697 (goto-char (window-start))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
698 (forward-line line)
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
699 ;; On the right side: go to end-of-line.
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
700 (when (>= (event-x-pixel event) (nth 2 edges))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
701 (goto-char (point-at-eol)))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
702 t))))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
703 )))
084402c475ba Import from CVS: tag r20-5b26
cvs
parents: 249
diff changeset
704
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
705
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
706 (defun default-mouse-track-scroll-and-set-point (event window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
707 (select-window window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
708 (let ((edges (window-pixel-edges window))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
709 (row (event-y-pixel event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
710 (height (face-height 'default)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
711 (cond ((< (abs (- row (nth 1 edges))) (abs (- row (nth 3 edges))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
712 ;; closer to window's top than to bottom, so move up
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
713 (let ((delta (max 1 (/ (- (nth 1 edges) row) height))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
714 (condition-case () (scroll-down delta) (error))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
715 (goto-char (window-start))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
716 ((>= (point) (point-max)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
717 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
718 ;; scroll by one line if over the modeline or a clipped line
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
719 (let ((delta (if (or (event-over-modeline-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
720 (< row (nth 3 edges)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
721 1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
722 (+ (/ (- row (nth 3 edges)) height) 1)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
723 (close-pos (event-closest-point event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
724 (condition-case () (scroll-up delta) (error))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
725 (if (and close-pos (pos-visible-in-window-p close-pos))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
726 (goto-char close-pos)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
727 (goto-char (window-end))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
728 (vertical-motion delta)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
729 ;; window-end reports the end of the clipped line, even if
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
730 ;; scroll-on-clipped-lines is t. compensate.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
731 ;; (If window-end gets fixed this can be removed.)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
732 (if (not (pos-visible-in-window-p (max (1- (point))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
733 (point-min))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
734 (vertical-motion -1))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
735 (condition-case () (backward-char 1)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
736 (error (end-of-line)))))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
737
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
738
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
739 ;; This remembers the last position at which the user clicked, for the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
740 ;; benefit of mouse-track-adjust (for example, button1; scroll until the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
741 ;; position of the click is off the frame; then Sh-button1 to select the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
742 ;; new region.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
743 (defvar default-mouse-track-previous-point nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
744
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
745 (defun default-mouse-track-set-point (event window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
746 (if (default-mouse-track-set-point-in-window event window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
747 nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
748 (default-mouse-track-scroll-and-set-point event window)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
749
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
750 (defsubst default-mouse-track-beginning-of-word (symbolp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
751 (let ((word-constituent (cond ((eq symbolp t) "\\w\\|\\s_\\|\\s'")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
752 ((null symbolp) "\\w")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
753 (t "[^ \t\n]")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
754 (white-space "[ \t]"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
755 (cond ((bobp) nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
756 ((looking-at word-constituent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
757 (backward-char)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
758 (while (and (not (bobp)) (looking-at word-constituent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
759 (backward-char))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
760 (if (or (not (bobp)) (not (looking-at word-constituent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
761 (forward-char)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
762 ((looking-at white-space)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
763 (backward-char)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
764 (while (looking-at white-space)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
765 (backward-char))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
766 (forward-char)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
767
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
768 (defun default-mouse-track-end-of-word (symbolp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
769 (let ((word-constituent (cond ((eq symbolp t) "\\w\\|\\s_\\|\\s'")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
770 ((null symbolp) "\\w")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
771 (t "[^ \t\n]")))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
772 (white-space "[ \t]"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
773 (cond ((looking-at word-constituent) ; word or symbol constituent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
774 (while (looking-at word-constituent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
775 (forward-char)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
776 ((looking-at white-space) ; word or symbol constituent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
777 (while (looking-at white-space)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
778 (forward-char))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
779
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
780 ;; Decide what will be the SYMBOLP argument to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
781 ;; default-mouse-track-{beginning,end}-of-word, according to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
782 ;; syntax of the current character and value of mouse-highlight-text.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
783 (defsubst default-mouse-symbolp (syntax)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
784 (cond ((eq mouse-highlight-text 'context)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
785 (eq syntax ?_))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
786 ((eq mouse-highlight-text 'symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
787 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
788 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
789 nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
790
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
791 (defun default-mouse-track-normalize-point (type forwardp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
792 (cond ((eq type 'word)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
793 ;; trap the beginning and end of buffer errors
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
794 (ignore-errors
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
795 (setq type (char-syntax (char-after (point))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
796 (if forwardp
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
797 (if (= type ?\()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
798 (goto-char (scan-sexps (point) 1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
799 (if (= type ?\))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
800 (forward-char 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
801 (default-mouse-track-end-of-word
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
802 (default-mouse-symbolp type))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
803 (if (= type ?\))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
804 (goto-char (scan-sexps (1+ (point)) -1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
805 (default-mouse-track-beginning-of-word
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
806 (default-mouse-symbolp type))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
807 ((eq type 'line)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
808 (if forwardp (end-of-line) (beginning-of-line)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
809 ((eq type 'buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
810 (if forwardp (end-of-buffer) (beginning-of-buffer)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
811
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
812 (defun default-mouse-track-next-move (min-anchor max-anchor extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
813 (let ((anchor (if (<= (point) min-anchor) max-anchor min-anchor)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
814 (funcall default-mouse-track-normalize-point-function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
815 default-mouse-track-type (> (point) anchor))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
816 (if (consp extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
817 (default-mouse-track-next-move-rect anchor (point) extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
818 (if extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
819 (if (<= anchor (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
820 (set-extent-endpoints extent anchor (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
821 (set-extent-endpoints extent (point) anchor))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
822
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
823 (defun default-mouse-track-next-move-rect (start end extents &optional pad-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
824 (if (< end start)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
825 (let ((tmp start)) (setq start end end tmp)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
826 (cond
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
827 ((= start end) ; never delete the last remaining extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
828 (mapcar 'delete-extent (cdr extents))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
829 (setcdr extents nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
830 (set-extent-endpoints (car extents) start start))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
831 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
832 (let ((indent-tabs-mode nil) ; if pad-p, don't use tabs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
833 (rest extents)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
834 left right last p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
835 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
836 (save-restriction
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
837 (goto-char end)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
838 (setq right (current-column))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
839 (goto-char start)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
840 (setq left (current-column))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
841 (if (< right left)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
842 (let ((tmp left))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
843 (setq left right right tmp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
844 (setq start (- start (- right left))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
845 end (+ end (- right left)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
846 ;; End may have been set to a value greater than point-max if drag
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
847 ;; or movement extends to end of buffer, so reset it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
848 (setq end (min end (point-max)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
849 (beginning-of-line)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
850 (narrow-to-region (point) end)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
851 (goto-char start)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
852 (while (and rest (not (eobp)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
853 (setq p (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
854 (move-to-column right pad-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
855 (set-extent-endpoints (car rest) p (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
856 ;; this code used to look at the return value
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
857 ;; of forward-line, but that doesn't work because
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
858 ;; forward-line has bogus behavior: If you're on
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
859 ;; the last line of a buffer but not at the very
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
860 ;; end, forward-line will move you to the very
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
861 ;; end and return 0 instead of 1, like it should.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
862 ;; the result was frequent infinite loops here,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
863 ;; creating very large numbers of extents at
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
864 ;; the same position. There was an N^2 sorting
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
865 ;; algorithm in extents.c for extents at a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
866 ;; particular position, and the result was very
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
867 ;; bad news.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
868 (forward-line 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
869 (if (not (eobp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
870 (move-to-column left pad-p))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
871 (setq last rest
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
872 rest (cdr rest)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
873 (cond (rest
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
874 (mapcar 'delete-extent rest)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
875 (setcdr last nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
876 ((not (eobp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
877 (while (not (eobp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
878 (setq p (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
879 (move-to-column right pad-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
880 (let ((e (make-extent p (point))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
881 (set-extent-face e (extent-face (car extents)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
882 (set-extent-priority e (extent-priority (car extents)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
883 (setcdr last (cons e nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
884 (setq last (cdr last)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
885 (forward-line 1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
886 (if (not (eobp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
887 (move-to-column left pad-p))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
888 )))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
889 ))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
890
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
891 (defun default-mouse-track-has-selection-p (buffer)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
892 (and (selection-owner-p)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
893 (extent-live-p primary-selection-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
894 (not (extent-detached-p primary-selection-extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
895 (eq buffer (extent-object primary-selection-extent))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
896
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
897 (defun default-mouse-track-anchor (adjust previous-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
898 (if adjust
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
899 (if (default-mouse-track-has-selection-p (current-buffer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
900 (let ((start (extent-start-position primary-selection-extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
901 (end (extent-end-position primary-selection-extent)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
902 (cond ((< (point) start) end)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
903 ((> (point) end) start)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
904 ((> (- (point) start) (- end (point))) start)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
905 (t end)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
906 previous-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
907 (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
908
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
909 (defun default-mouse-track-maybe-own-selection (pair type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
910 (let ((start (car pair))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
911 (end (cdr pair)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
912 (or (= start end) (push-mark (if (= (point) start) end start)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
913 (cond (zmacs-regions
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
914 (if (= start end)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
915 nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
916 ;; #### UTTER KLUDGE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
917 ;; If we don't have this sit-for here, then triple-clicking
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
918 ;; will result in the line not being highlighted as it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
919 ;; should. What appears to be happening is this:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
920 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
921 ;; -- each time the button goes down, the selection is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
922 ;; disowned (see comment "remove the existing selection
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
923 ;; to unclutter the display", below).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
924 ;; -- this causes a SelectionClear event to be sent to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
925 ;; XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
926 ;; -- each time the button goes up except the first, the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
927 ;; selection is owned again.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
928 ;; -- later, XEmacs processes the SelectionClear event.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
929 ;; The selection code attempts to keep track of the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
930 ;; time that it last asserted the selection, and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
931 ;; compare it to the time of the SelectionClear event,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
932 ;; to see if it's a bogus notification or not (as
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
933 ;; is the case here). However, for some unknown
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
934 ;; reason this doesn't work in the triple-clicking
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
935 ;; case, and the selection code bogusly thinks this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
936 ;; SelectionClear event is the real thing.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
937 ;; -- putting the sit-for in causes the pending
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
938 ;; SelectionClear events to get processed before
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
939 ;; the selection is reasserted, so everything works
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
940 ;; out OK.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
941 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
942 ;; Presumably(?) this means there is a weird timing bug
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
943 ;; in the selection code, but there's not a chance in hell
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
944 ;; that I have the patience to track it down. Blame the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
945 ;; designers of X for fucking everything up so badly.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
946 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
947 ;; This was originally a sit-for 0 but that wasn't
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
948 ;; sufficient to make things work. Even this isn't
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
949 ;; always sufficient but it seems to give something
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
950 ;; approaching a 99% success rate. Making it higher yet
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
951 ;; would help guarantee success with the price that the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
952 ;; delay would start to become noticable.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
953 ;;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
954 (and (eq (console-type) 'x)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
955 (sit-for 0.15 t))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
956 (zmacs-activate-region)))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
957 ((console-on-window-system-p)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
958 (if (= start end)
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
959 (disown-selection type)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
960 (if (consp default-mouse-track-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
961 ;; own the rectangular region
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
962 ;; this is a hack
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
963 (let ((r default-mouse-track-extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
964 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
965 (set-buffer (get-buffer-create " *rect yank temp buf*"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
966 (while r
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
967 (insert (extent-string (car r)) "\n")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
968 (setq r (cdr r)))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
969 (own-selection (buffer-substring (point-min) (point-max)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
970 (kill-buffer (current-buffer))))
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
971 (own-selection (cons (set-marker (make-marker) start)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
972 (set-marker (make-marker) end))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
973 type)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
974 (if (and (eq 'x (console-type))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
975 (not (= start end)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
976 ;; I guess cutbuffers should do something with rectangles too.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
977 ;; does anybody use them?
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
978 (x-store-cutbuffer (buffer-substring start end)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
979
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
980 (defun default-mouse-track-deal-with-down-event (click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
981 (let ((event default-mouse-track-down-event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
982 (if (null event) nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
983 (select-frame (event-frame event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
984 (let ((adjust default-mouse-track-adjust)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
985 ;; ####When you click on the splash-screen,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
986 ;; event-{closest-,}point can be out of bounds. Should
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
987 ;; event-closest-point really be allowed to return a bad
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
988 ;; position like that? Maybe pixel_to_glyph_translation
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
989 ;; needs to invalidate its cache when the buffer changes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
990 ;; -dkindred@cs.cmu.edu
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
991 (close-pos (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
992 (set-buffer (event-buffer event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
993 (let ((p (event-closest-point event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
994 (and p (min (max p (point-min)) (point-max))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
995 extent previous-point)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
996
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
997 (if (not (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
998 (error "not over window?"))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
999 (setq default-mouse-track-type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1000 (nth (mod (1- click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1001 (length default-mouse-track-type-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1002 default-mouse-track-type-list))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1003 (setq default-mouse-track-window (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1004 ;; Note that the extent used here is NOT the extent which
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1005 ;; ends up as the value of zmacs-region-extent - this one is used
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1006 ;; just during mouse-dragging.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1007 (setq default-mouse-track-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1008 (make-extent close-pos close-pos (event-buffer event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1009 (setq extent default-mouse-track-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1010 (set-extent-face extent 'zmacs-region)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1011 ;; While the selection is being dragged out, give the selection extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1012 ;; slightly higher priority than any mouse-highlighted extent, so that
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1013 ;; the exact endpoints of the selection will be visible while the mouse
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1014 ;; is down. Normally, the selection and mouse highlighting have the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1015 ;; same priority, so that conflicts between the two of them are
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1016 ;; resolved by the usual size-and-endpoint-comparison method.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1017 (set-extent-priority extent (1+ mouse-highlight-priority))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1018 (if mouse-track-rectangle-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1019 (setq default-mouse-track-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1020 (list default-mouse-track-extent)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
1021
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1022 (setq previous-point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1023 (if (and adjust
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1024 (markerp default-mouse-track-previous-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1025 (eq (current-buffer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1026 (marker-buffer default-mouse-track-previous-point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1027 (marker-position default-mouse-track-previous-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1028 (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1029 (default-mouse-track-set-point event default-mouse-track-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1030 (if (not adjust)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1031 (if (markerp default-mouse-track-previous-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1032 (set-marker default-mouse-track-previous-point (point))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1033 (setq default-mouse-track-previous-point (point-marker))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1034 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1035 ;; adjust point to a word or line boundary if appropriate
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1036 (let ((anchor (default-mouse-track-anchor adjust previous-point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1037 (setq default-mouse-track-min-anchor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1038 (save-excursion (goto-char anchor)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1039 (funcall
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1040 default-mouse-track-normalize-point-function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1041 default-mouse-track-type nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1042 (point)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1043 (setq default-mouse-track-max-anchor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1044 (save-excursion (goto-char anchor)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1045 (funcall
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1046 default-mouse-track-normalize-point-function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1047 default-mouse-track-type t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1048 (point))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1049 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1050 ;; remove the existing selection to unclutter the display
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1051 (if (not adjust)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1052 (cond (zmacs-regions
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1053 (zmacs-deactivate-region))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1054 ((console-on-window-system-p)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1055 (disown-selection)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1056 (setq default-mouse-track-down-event nil))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1057
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1058 (defun default-mouse-track-down-hook (event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1059 (setq default-mouse-track-down-event (copy-event event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1060 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1061
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1062 (defun default-mouse-track-cleanup-extents-hook ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1063 (remove-hook 'pre-command-hook 'default-mouse-track-cleanup-extents-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1064 (let ((extent default-mouse-track-extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1065 (if (consp extent) ; rectangle-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1066 (mapcar 'delete-extent extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1067 (if extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1068 (delete-extent extent)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1069
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1070 (defun default-mouse-track-cleanup-hook ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1071 (if zmacs-regions
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1072 (funcall 'default-mouse-track-cleanup-extents-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1073 (let ((extent default-mouse-track-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1074 (func #'(lambda (e)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1075 (and (extent-live-p e)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1076 (set-extent-face e 'primary-selection)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1077 (add-hook 'pre-command-hook 'default-mouse-track-cleanup-extents-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1078 (if (consp extent) ; rectangle-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1079 (mapcar func extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1080 (if extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1081 (funcall func extent))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1082
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1083 (defun default-mouse-track-cleanup-extent ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1084 (let ((dead-func
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1085 (function (lambda (x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1086 (or (not (extent-live-p x))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1087 (extent-detached-p x)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1088 (extent default-mouse-track-extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1089 (if (consp extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1090 (if (funcall dead-func extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1091 (let (newval)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1092 (mapcar (function (lambda (x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1093 (if (not (funcall dead-func x))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1094 (setq newval (cons x newval)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1095 extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1096 (setq default-mouse-track-extent (nreverse newval))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1097 (if (funcall dead-func extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1098 (setq default-mouse-track-extent nil)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1099
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1100 (defun default-mouse-track-drag-hook (event click-count was-timeout)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1101 (default-mouse-track-deal-with-down-event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1102 (default-mouse-track-set-point event default-mouse-track-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1103 (default-mouse-track-cleanup-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1104 (default-mouse-track-next-move default-mouse-track-min-anchor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1105 default-mouse-track-max-anchor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1106 default-mouse-track-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1107 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1108
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1109 (defun default-mouse-track-return-dragged-selection (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1110 (default-mouse-track-cleanup-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1111 (let ((extent default-mouse-track-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1112 result)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1113 (default-mouse-track-set-point-in-window event default-mouse-track-window)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1114 (default-mouse-track-next-move default-mouse-track-min-anchor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1115 default-mouse-track-max-anchor
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1116 extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1117 (cond ((consp extent) ; rectangle-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1118 (let ((first (car extent))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1119 (last (car (setq extent (nreverse extent)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1120 ;; nreverse is destructive so we need to reset this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1121 (setq default-mouse-track-extent extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1122 (setq result (cons (extent-start-position first)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1123 (extent-end-position last)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1124 ;; kludge to fix up region when dragging backwards...
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1125 (if (and (/= (point) (extent-start-position first))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1126 (/= (point) (extent-end-position last))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1127 (= (point) (extent-end-position first)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1128 (goto-char (car result)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1129 (extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1130 (setq result (cons (extent-start-position extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1131 (extent-end-position extent)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1132 ;; Minor kludge: if we're selecting in line-mode, include the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1133 ;; final newline. It's hard to do this in *-normalize-point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1134 (if (and result (eq default-mouse-track-type 'line))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1135 (let ((end-p (= (point) (cdr result))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1136 (goto-char (cdr result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1137 (if (not (eobp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1138 (setcdr result (1+ (cdr result))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1139 (goto-char (if end-p (cdr result) (car result)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1140 ;;; ;; Minor kludge sub 2. If in char mode, and we drag the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1141 ;;; ;; mouse past EOL, include the newline.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1142 ;;; ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1143 ;;; ;; Major problem: can't easily distinguish between being
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1144 ;;; ;; just past the last char on a line, and well past it,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1145 ;;; ;; to determine whether or not to include it in the region
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1146 ;;; ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1147 ;;; (if nil ; (eq default-mouse-track-type 'char)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1148 ;;; (let ((after-end-p (and (not (eobp))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1149 ;;; (eolp)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1150 ;;; (> (point) (car result)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1151 ;;; (if after-end-p
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1152 ;;; (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1153 ;;; (setcdr result (1+ (cdr result)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1154 ;;; (goto-char (cdr result))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1155 result))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1156
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1157 (defun default-mouse-track-drag-up-hook (event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1158 (let ((result (default-mouse-track-return-dragged-selection event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1159 (if result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1160 (default-mouse-track-maybe-own-selection result 'PRIMARY)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1161 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1162
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1163 (defun default-mouse-track-click-hook (event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1164 (default-mouse-track-drag-hook event click-count nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1165 (default-mouse-track-drag-up-hook event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1166 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1167
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1168 (add-hook 'mouse-track-down-hook 'default-mouse-track-down-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1169 (add-hook 'mouse-track-drag-hook 'default-mouse-track-drag-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1170 (add-hook 'mouse-track-drag-up-hook 'default-mouse-track-drag-up-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1171 (add-hook 'mouse-track-click-hook 'default-mouse-track-click-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1172 (add-hook 'mouse-track-cleanup-hook 'default-mouse-track-cleanup-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1173
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1174
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1175 ;;;;;;;;;;;; other mouse-track stuff (mostly associated with the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1176 ;;;;;;;;;;;; default handlers)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1177
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1178 (defun mouse-track-default (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1179 "Invoke `mouse-track' with only the default handlers active."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1180 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1181 (let ((mouse-track-down-hook 'default-mouse-track-down-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1182 (mouse-track-drag-hook 'default-mouse-track-drag-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1183 (mouse-track-drag-up-hook 'default-mouse-track-drag-up-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1184 (mouse-track-click-hook 'default-mouse-track-click-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1185 (mouse-track-cleanup-hook 'default-mouse-track-cleanup-hook))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1186 (mouse-track event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1187
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1188 (defun mouse-track-do-rectangle (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1189 "Like `mouse-track' but selects rectangles instead of regions."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1190 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1191 (let ((mouse-track-rectangle-p t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1192 (mouse-track event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1193
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1194 (defun mouse-track-adjust (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1195 "Extend the existing selection. This should be bound to a mouse button.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1196 The selection will be enlarged or shrunk so that the point of the mouse
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1197 click is one of its endpoints. This function in fact behaves fairly
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1198 similarly to `mouse-track', but begins by extending the existing selection
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1199 (or creating a new selection from the previous text cursor position to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1200 the current mouse position) instead of creating a new, empty selection.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1201
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1202 The mouse-track handlers are run from this command just like from
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1203 `mouse-track'. Therefore, do not call this command from a mouse-track
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1204 handler!"
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1205 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1206 (let ((default-mouse-track-adjust t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1207 (mouse-track event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1208
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1209 (defun mouse-track-adjust-default (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1210 "Extend the existing selection, using only the default handlers.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1211 This is just like `mouse-track-adjust' but will override any
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1212 custom mouse-track handlers that the user may have installed."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1213 (interactive "e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1214 (let ((default-mouse-track-adjust t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1215 (mouse-track-default event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1216
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1217 (defvar mouse-track-insert-selected-region nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1218
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1219 (defun mouse-track-insert-drag-up-hook (event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1220 (setq mouse-track-insert-selected-region
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1221 (default-mouse-track-return-dragged-selection event)))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 255
diff changeset
1222
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1223 (defun mouse-track-insert (event &optional delete)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1224 "Make a selection with the mouse and insert it at point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1225 This is exactly the same as the `mouse-track' command on \\[mouse-track],
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1226 except that point is not moved; the selected text is immediately inserted
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1227 after being selected\; and the selection is immediately disowned afterwards."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1228 (interactive "*e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1229 (setq mouse-track-insert-selected-region nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1230 (let ((mouse-track-drag-up-hook 'mouse-track-insert-drag-up-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1231 (mouse-track-click-hook 'mouse-track-insert-click-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1232 s)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1233 (save-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1234 (save-window-excursion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1235 (mouse-track event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1236 (if (consp mouse-track-insert-selected-region)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1237 (let ((pair mouse-track-insert-selected-region))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1238 (setq s (prog1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1239 (buffer-substring (car pair) (cdr pair))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1240 (if delete
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1241 (kill-region (car pair) (cdr pair)))))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1242 (or (null s) (equal s "") (insert s))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1243
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1244 (defun mouse-track-insert-click-hook (event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1245 (default-mouse-track-drag-hook event click-count nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1246 (mouse-track-insert-drag-up-hook event click-count)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1247 t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1248
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1249 (defun mouse-track-delete-and-insert (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1250 "Make a selection with the mouse and insert it at point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1251 This is exactly the same as the `mouse-track' command on \\[mouse-track],
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1252 except that point is not moved; the selected text is immediately inserted
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1253 after being selected\; and the text of the selection is deleted."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1254 (interactive "*e")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1255 (mouse-track-insert event t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1256
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1257 ;;;;;;;;;;;;;;;;;;;;;;;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1258
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1259
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1260 (defvar inhibit-help-echo nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1261 "Inhibits display of `help-echo' extent properties in the minibuffer.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1262 (defvar last-help-echo-object nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1263 (defvar help-echo-owns-message nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1264
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1265 (defun clear-help-echo (&optional ignored-frame)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1266 (if help-echo-owns-message
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1267 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1268 (setq help-echo-owns-message nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1269 last-help-echo-object nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1270 (clear-message 'help-echo))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1271
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1272 (defun show-help-echo (mess)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1273 ;; (clear-help-echo)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1274 (setq help-echo-owns-message t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1275 (display-message 'help-echo mess))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1276
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1277 (add-hook 'mouse-leave-frame-hook 'clear-help-echo)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1278
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1279 ;; It may be a good idea to move this to C, for better performance of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1280 ;; extent highlighting and pointer changes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1281 (defun default-mouse-motion-handler (event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1282 "For use as the value of `mouse-motion-handler'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1283 This implements the various pointer-shape variables,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1284 as well as extent highlighting, help-echo, toolbar up/down,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1285 and `mode-motion-hook'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1286 (let* ((frame (or (event-frame event) (selected-frame)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1287 (window (event-window event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1288 (buffer (event-buffer event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1289 (modeline-point (and buffer (event-modeline-position event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1290 (modeline-string (and modeline-point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1291 (symbol-value-in-buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1292 'generated-modeline-string buffer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1293 ;; point must be invalidated by modeline-point.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1294 (point (and buffer (not modeline-point)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1295 (event-point event)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1296 (extent (or (and point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1297 (extent-at point buffer 'mouse-face))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1298 (and modeline-point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1299 (extent-at modeline-point modeline-string
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1300 ;; Modeline extents don't have a
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1301 ;; mouse-face property set.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1302 'help-echo))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1303 (glyph-extent1 (event-glyph-extent event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1304 (glyph-extent (and glyph-extent1
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1305 (extent-live-p glyph-extent1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1306 glyph-extent1))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1307 ;; This is an extent:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1308 (user-pointer1 (or (and glyph-extent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1309 (extent-property glyph-extent 'pointer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1310 glyph-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1311 (and point (extent-at point buffer 'pointer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1312 (and modeline-point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1313 (extent-at modeline-point modeline-string
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1314 'pointer))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1315 ;; And this should be a glyph:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1316 (user-pointer (and user-pointer1 (extent-live-p user-pointer1)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1317 (extent-property user-pointer1 'pointer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1318 (button (event-toolbar-button event))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1319 (help (or (and glyph-extent (extent-property glyph-extent 'help-echo)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1320 glyph-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1321 (and button (not (null (toolbar-button-help-string button)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1322 button)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1323 (and point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1324 (extent-at point buffer 'help-echo))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1325 (and modeline-point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1326 (extent-at modeline-point modeline-string
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1327 'help-echo))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1328 ;; vars is a list of glyph variables to check for a pointer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1329 ;; value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1330 (vars (cond
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1331 ;; Checking if button is non-nil is not sufficent
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1332 ;; since the pointer could be over a blank portion
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1333 ;; of the toolbar.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1334 ((event-over-toolbar-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1335 '(toolbar-pointer-glyph nontext-pointer-glyph
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1336 text-pointer-glyph))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1337 ((or extent glyph-extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1338 '(selection-pointer-glyph text-pointer-glyph))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1339 ((event-over-modeline-p event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1340 '(modeline-pointer-glyph nontext-pointer-glyph
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1341 text-pointer-glyph))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1342 ((and (event-over-vertical-divider-p event)
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1343 ;; #### I disagree with the check below.
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1344 ;; Discuss it with Kirill for 21.1. --hniksic
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1345 (specifier-instance vertical-divider-always-visible-p
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1346 (event-window event)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1347 '(divider-pointer-glyph nontext-pointer-glyph
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1348 text-pointer-glyph))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1349 (point '(text-pointer-glyph))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1350 (buffer '(nontext-pointer-glyph text-pointer-glyph))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1351 (t '(nontext-pointer-glyph text-pointer-glyph))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1352 pointer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1353 (and user-pointer (glyphp user-pointer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1354 (push 'user-pointer vars))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1355 (while (and vars (not (pointer-image-instance-p pointer)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1356 (setq pointer (glyph-image-instance (symbol-value (car vars))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1357 (or window frame))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1358 vars (cdr vars)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1359
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1360 (if (pointer-image-instance-p pointer)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1361 (set-frame-pointer frame pointer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1362
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1363 ;; If last-pressed-toolbar-button is not nil, then check and see
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1364 ;; if we have moved to a new button and adjust the down flags
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1365 ;; accordingly.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1366 (when (and (featurep 'toolbar) toolbar-active)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1367 (unless (eq last-pressed-toolbar-button button)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1368 (release-previous-toolbar-button event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1369 (and button (press-toolbar-button event))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1370
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1371 (cond (extent (highlight-extent extent t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1372 (glyph-extent (highlight-extent glyph-extent t))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1373 (t (highlight-extent nil nil)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1374 (cond ((extentp help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1375 (or inhibit-help-echo
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1376 (eq help last-help-echo-object) ;save some time
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1377 (let ((hprop (extent-property help 'help-echo)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1378 (setq last-help-echo-object help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1379 (or (stringp hprop)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1380 (setq hprop (funcall hprop help)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1381 (and hprop (show-help-echo hprop)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1382 ((and (featurep 'toolbar)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1383 (toolbar-button-p help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1384 (toolbar-button-enabled-p help))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1385 (or (not toolbar-help-enabled)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1386 (eq help last-help-echo-object) ;save some time
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1387 (let ((hstring (toolbar-button-help-string button)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1388 (setq last-help-echo-object help)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1389 (or (stringp hstring)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1390 (setq hstring (funcall hstring help)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1391 (show-help-echo hstring))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1392 (last-help-echo-object
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1393 (clear-help-echo)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1394 (if mouse-grabbed-buffer (setq buffer mouse-grabbed-buffer))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1395 (if (and buffer (symbol-value-in-buffer 'mode-motion-hook buffer nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1396 (with-current-buffer buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1397 (run-hook-with-args 'mode-motion-hook event)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1398
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1399 ;; If the mode-motion-hook created a highlightable extent around
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1400 ;; the mouse-point, highlight it right away. Otherwise it wouldn't
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1401 ;; be highlighted until the *next* motion event came in.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1402 (if (and point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1403 (null extent)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1404 (setq extent (extent-at point
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1405 (event-buffer event) ; not buffer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1406 'mouse-face)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1407 (highlight-extent extent t)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1408 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1409
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1410 (setq mouse-motion-handler 'default-mouse-motion-handler)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1411
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1412 ;;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1413 ;; Vertical divider dragging
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1414 ;;
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1415 (defun drag-window-divider (event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1416 "Handle resizing windows by dragging window dividers.
367
a4f53d9b3154 Import from CVS: tag r21-1-13
cvs
parents: 298
diff changeset
1417 This is an internal function, normally bound to button1 event in
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1418 window-divider-map. You would not call it, but you may bind it to
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1419 other mouse buttons."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1420 (interactive "e")
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1421 ;; #### I disagree with the check below.
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1422 ;; Discuss it with Kirill for 21.1. --hniksic
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1423 (if (not (specifier-instance vertical-divider-always-visible-p
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1424 (event-window event)))
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 290
diff changeset
1425 (error "Not over a window"))
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1426 (let-specifier ((vertical-divider-shadow-thickness
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1427 (- (specifier-instance vertical-divider-shadow-thickness
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1428 (event-window event)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1429 (event-window event)))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1430 (let* ((window (event-window event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1431 (frame (event-channel event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1432 (last-timestamp (event-timestamp event))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1433 done)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1434 (while (not done)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1435 (let* ((edges (window-pixel-edges window))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1436 (old-right (caddr edges))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1437 (old-left (car edges))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1438 (backup-conf (current-window-configuration frame))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1439 (old-edges-all-windows (mapcar 'window-pixel-edges
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1440 (window-list))))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1441
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1442 ;; This is borrowed from modeline.el:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1443 ;; requeue event and quit if this is a misc-user, eval or
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1444 ;; keypress event.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1445 ;; quit if this is a button press or release event, or if the event
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1446 ;; occurred in some other frame.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1447 ;; drag if this is a mouse motion event and the time
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1448 ;; between this event and the last event is greater than
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1449 ;; drag-divider-event-lag.
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1450 ;; do nothing if this is any other kind of event.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1451 (setq event (next-event event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1452 (cond ((or (misc-user-event-p event)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1453 (key-press-event-p event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1454 (setq unread-command-events (nconc unread-command-events
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1455 (list event))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1456 done t))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1457 ((button-release-event-p event)
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1458 (setq done t))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1459 ((button-event-p event)
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1460 (setq done t))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1461 ((not (motion-event-p event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1462 (dispatch-event event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1463 ((not (eq frame (event-frame event)))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1464 (setq done t))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1465 ((< (abs (- (event-timestamp event) last-timestamp))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
1466 drag-divider-event-lag))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1467 (t
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1468 (setq last-timestamp (event-timestamp event))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1469 ;; Enlarge the window, calculating change in characters
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1470 ;; of default font. Do not let the window to become
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1471 ;; less than alolwed minimum (not because that's critical
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1472 ;; for the code performance, just the visual effect is
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1473 ;; better: when cursor goes to the left of the next left
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1474 ;; divider, the vindow being resized shrinks to minimal
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1475 ;; size.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1476 (enlarge-window (max (- window-min-width (window-width window))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1477 (/ (- (event-x-pixel event) old-right)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1478 (face-width 'default window)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1479 t window)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1480 ;; Backout the change if some windows got deleted, or
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1481 ;; if the change caused more than two windows to resize
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1482 ;; (shifting the whole stack right is ugly), or if the
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1483 ;; left window side has slipped (right side cannot be
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1484 ;; moved any funrther to the right, so enlarge-window
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1485 ;; plays bad games with the left edge.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1486 (if (or (/= (count-windows) (length old-edges-all-windows))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1487 (/= old-left (car (window-pixel-edges window)))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1488 ;; This check is very hairy. We allow any number
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1489 ;; of left edges to change, but only to the same
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1490 ;; new value. Similar procedure is for the right edges.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1491 (let ((all-that-bad nil)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1492 (new-left-ok nil)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1493 (new-right-ok nil))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1494 (mapcar* (lambda (window old-edges)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1495 (let ((new (car (window-pixel-edges window))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1496 (if (/= new (car old-edges))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1497 (if (and new-left-ok
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1498 (/= new-left-ok new))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1499 (setq all-that-bad t)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1500 (setq new-left-ok new)))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1501 (window-list) old-edges-all-windows)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1502 (mapcar* (lambda (window old-edges)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1503 (let ((new (caddr (window-pixel-edges window))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1504 (if (/= new (caddr old-edges))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1505 (if (and new-right-ok
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1506 (/= new-right-ok new))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1507 (setq all-that-bad t)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1508 (setq new-right-ok new)))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1509 (window-list) old-edges-all-windows)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 284
diff changeset
1510 all-that-bad))
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
1511 (set-window-configuration backup-conf)))))))))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1512
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1513 (setq vertical-divider-map (make-keymap))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
1514 (define-key vertical-divider-map 'button1 'drag-window-divider)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1515
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1516 ;;; mouse.el ends here