comparison lisp/prim/mouse.el @ 197:acd284d43ca1 r20-3b25

Import from CVS: tag r20-3b25
author cvs
date Mon, 13 Aug 2007 10:00:02 +0200
parents 3d6bfa290dbd
children e45d5e7c476e
comparison
equal deleted inserted replaced
196:58e0786448ca 197:acd284d43ca1
31 (global-set-key '(control button1) 'mouse-track-insert) 31 (global-set-key '(control button1) 'mouse-track-insert)
32 (global-set-key '(control shift button1) 'mouse-track-delete-and-insert) 32 (global-set-key '(control shift button1) 'mouse-track-delete-and-insert)
33 (global-set-key '(meta button1) 'mouse-track-do-rectangle) 33 (global-set-key '(meta button1) 'mouse-track-do-rectangle)
34 34
35 ;; enable drag regions (ograf@fga.de) 35 ;; enable drag regions (ograf@fga.de)
36 ;; if button2 is dragged from within a region, this becomes a drop
36 (if (or (featurep 'offix) ;; do we have DnD support? 37 (if (or (featurep 'offix) ;; do we have DnD support?
37 (featurep 'cde)) 38 (featurep 'cde))
38 (global-set-key 'button2 'mouse-drag-or-yank) 39 (global-set-key 'button2 'mouse-drag-or-yank)
39 (global-set-key 'button2 'mouse-yank)) 40 (global-set-key 'button2 'mouse-yank))
41
42 ;; enable drops from OffiX (ograf@fga.de)
43 ;; accept any button1,2,3 drop with `mouse-offix-drop'
44 (cond ((featurep 'offix)
45 (global-set-key 'drop1 'mouse-offix-drop)
46 (global-set-key 'drop2 'mouse-offix-drop)
47 (global-set-key 'drop3 'mouse-offix-drop)))
40 48
41 (defcustom mouse-track-rectangle-p nil 49 (defcustom mouse-track-rectangle-p nil
42 "*If true, then dragging out a region with the mouse selects rectangles 50 "*If true, then dragging out a region with the mouse selects rectangles
43 instead of simple start/end regions." 51 instead of simple start/end regions."
44 :type 'boolean 52 :type 'boolean
148 (defun mouse-drag-or-yank (event) 156 (defun mouse-drag-or-yank (event)
149 "Either drag or paste the current selection. If the variable 157 "Either drag or paste the current selection. If the variable
150 `mouse-yank-at-point' is non-nil, then moves the cursor to the location of 158 `mouse-yank-at-point' is non-nil, then moves the cursor to the location of
151 the click before pasting. 159 the click before pasting.
152 This functions has to be improved. Until now it is just a (working) test." 160 This functions has to be improved. Until now it is just a (working) test."
153 ;; by ograf@fga.de 161 ;; by Oliver Graf <ograf@fga.de>
154 (interactive "e") 162 (interactive "e")
155 (if (click-inside-extent-p event zmacs-region-extent) 163 (if (click-inside-extent-p event zmacs-region-extent)
156 ;; okay, this is a drag 164 ;; okay, this is a drag
157 (cond ((featurep 'offix) 165 (cond ((featurep 'offix)
158 (offix-start-drag-region event 166 (offix-start-drag-region event
167 ;; no drag, call region-funct 175 ;; no drag, call region-funct
168 (and (not mouse-yank-at-point) 176 (and (not mouse-yank-at-point)
169 (mouse-set-point event)) 177 (mouse-set-point event))
170 (funcall mouse-yank-function)) 178 (funcall mouse-yank-function))
171 ) 179 )
180
181 (defun mouse-offix-drop (event)
182 "Do something with an OffiX drop event. Inserts Text drops and
183 executes appropriate commands for specific drops.
184 Text drops follow the `mouse-yank-at-point' variable."
185 ;; by Oliver Graf <ograf@fga.de>
186 (interactive "e")
187 (let ((type (car (event-dnd-data event)))
188 (data (cadr (event-dnd-data event)))
189 (frame (event-channel event)))
190 (cond ((= type 2)
191 (let ((x pop-up-windows))
192 (setq pop-up-windows nil)
193 (pop-to-buffer (find-file-noselect data) nil frame)
194 (make-frame-visible frame)
195 (setq pop-up-windows x)))
196 ((= type 3)
197 (let ((x pop-up-windows))
198 (setq pop-up-windows nil)
199 (while (not (eq data ()))
200 (pop-to-buffer (find-file-noselect (car data)) nil frame)
201 (setq data (cdr data)))
202 (make-frame-visible frame)
203 (setq pop-up-windows x)))
204 ((= type 4)
205 (and (not mouse-yank-at-point)
206 (mouse-set-point event))
207 (insert data))
208 ((= type 5) (dired data))
209 ((or (= type 6) (= type 7)) (dired data)) ;; this is junk
210 ((= type 8) (funcall browse-url-browser-function data))
211 ((= type 9)
212 (let ((buf (generate-new-buffer "DndMIME")))
213 (set-buffer buf)
214 (pop-to-buffer buf nil frame)
215 (insert data)
216 (make-frame-visible frame)))
217 (t ;; this is raw data or unknown stuff
218 (let ((buf (generate-new-buffer "DndRawData")))
219 (set-buffer buf)
220 (pop-to-buffer buf nil frame)
221 (insert data)
222 (hexlify-buffer)
223 (make-frame-visible frame))))))
172 224
173 (defun mouse-eval-sexp (click force-window) 225 (defun mouse-eval-sexp (click force-window)
174 "Evaluate the sexp under the mouse. Usually, this is the last sexp before 226 "Evaluate the sexp under the mouse. Usually, this is the last sexp before
175 the click, but if you click on a left paren, then it is the sexp beginning 227 the click, but if you click on a left paren, then it is the sexp beginning
176 with the paren that is evaluated. Also, since strings evaluate to themselves, 228 with the paren that is evaluated. Also, since strings evaluate to themselves,