annotate lisp/dragdrop.el @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents c9fe270a4101
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1 ;;; dragdrop.el --- window system-independent Drag'n'Drop support.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3 ;; Copyright (C) 1998 Oliver Graf <ograf@fga.de>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5 ;; Maintainer: XEmacs Development Team, Oliver Graf <ograf@fga.de>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
6 ;; Keywords: drag, drop, dumped
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
7
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
9
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
13 ;; any later version.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
14
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
18 ;; General Public License for more details.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
19
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
24
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
26
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
27 ;;; Commentary:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
28
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
29 ;; This file is dumped with XEmacs (when drag'n'drop support is compiled in).
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
30
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
31 ;;; Code:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
32
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
33 ;; we need mouse-set-point
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
34 (require 'mouse)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
35 (provide 'dragdrop)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
36
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
37 ;; I think this is a better name for the custom group
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
38 ;; looks better in the menu and the group display as dragdrop
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
39 ;; Anyway: is dragdrop- a good prefix for all this?
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
40 ;; What if someone trys drop<TAB> in the minibuffer?
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
41 (defgroup drag-n-drop nil
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
42 "*{EXPERIMENTAL} Window system-independent drag'n'drop support."
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
43 :group 'editing)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
44
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
45 (defcustom dragdrop-drop-at-point nil
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
46 "*{EXPERIMENTAL} If non-nil, drop text at the cursor location.
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
47 Otherwise, the cursor will be moved to the location of the pointer drop before
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
48 text is inserted."
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
49 :type 'boolean
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
50 :group 'drag-n-drop)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
51
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
52 (defcustom dragdrop-autoload-tm-view nil
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
53 "*{EXPERIMENTAL} If non-nil, autoload tm-view to decode MIME data.
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 290
diff changeset
54 Otherwise, the buffer is only decoded if tm-view is already available."
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
55 :type 'boolean
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
56 :group 'drag-n-drop)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
57
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
58 ;; the widget for editing the drop-functions
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
59 (define-widget 'dragdrop-function-widget 'list
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
60 "*{EXPERIMENTAL} Widget for editing drop dispatch functions."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
61 :args `((choice :tag "Function"
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
62 (function-item experimental-dragdrop-drop-url-default)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
63 (function-item experimental-dragdrop-drop-mime-default)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
64 (function-item experimental-dragdrop-drop-log-function)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
65 (function :tag "Other" nil))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
66 (choice :tag "Button" :value t
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
67 (choice-item :tag "Ignore" t)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
68 (choice-item 0) (choice-item 1) (choice-item 2)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
69 (choice-item 3) (choice-item 4) (choice-item 5)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
70 (choice-item 6) (choice-item 7))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
71 (radio-button-choice :tag "Modifiers"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
72 (const :tag "Ignore Modifier Keys" t)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
73 (checklist :greedy t
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
74 :format "Modifier Keys:\n%v"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
75 :extra-offset 6
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
76 (const shift)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
77 (const control)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
78 (const meta)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
79 (const alt)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
80 (const hyper)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
81 (const super)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
82 (repeat :inline t :value nil :tag "Extra Function Arguments"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
83 (sexp :tag "Arg" :value nil)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
84 :value '(nil t t))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
85
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
86 (defcustom experimental-dragdrop-drop-functions '((experimental-dragdrop-drop-url-default t t)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
87 (experimental-dragdrop-drop-mime-default t t))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
88 "*{EXPERIMENTAL} This is the standart drop function search list.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
89 Each element is a list of a function, a button selector, a modifier
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
90 selector and optional argumets to the function call.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
91 The function must accept at least two arguments: first is the event
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
92 of the drop, second the object data, followed by any of the optional
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
93 arguments provided in this list.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
94 The functions are called in order, until one returns t."
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
95 :group 'drag-n-drop
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
96 :type '(repeat dragdrop-function-widget))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
97
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
98 (defgroup dnd-debug nil
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
99 "*{EXPERIMENTAL} Drag'n'Drop debugging options."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
100 :group 'drag-n-drop)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
101
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
102 (defcustom dragdrop-drop-log nil
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
103 "*{EXPERIMENTAL} If non-nil, every drop is logged.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
104 The name of the buffer is set in the custom 'dragdrop-drop-log-name"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
105 :group 'dnd-debug
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
106 :type 'boolean)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
107
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
108 (defcustom dragdrop-drop-log-name "*drop log buffer*"
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
109 "*{EXPERIMENTAL} The name of the buffer used to log drops.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
110 Set dragdrop-drop-log to non-nil to enable this feature."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
111 :group 'dnd-debug
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
112 :type 'string)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
113
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
114 (defvar dragdrop-drop-log-buffer nil
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
115 "*{EXPERIMENTAL} Buffer to log drops in debug mode.")
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
116
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
117 ;;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
118 ;; Drop API
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
119 ;;
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
120 (defun dragdrop-drop-dispatch (object)
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
121 "*{EXPERIMENTAL} This function identifies DROP type misc-user-events.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
122 It calls functions which will handle the drag."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
123 (let ((event current-mouse-event))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
124 (and dragdrop-drop-log
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
125 (experimental-dragdrop-drop-log-function event object))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
126 (dragdrop-drop-find-functions event object)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
127
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
128 (defun dragdrop-drop-find-functions (event object)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
129 "Finds valid drop-handle functions and executes them to dispose the drop.
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
130 It does this by looking for extent-properties called
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
131 'experimental-dragdrop-drop-functions and for variables named like this."
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
132 (catch 'dragdrop-drop-is-done
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
133 (and (event-over-text-area-p event)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
134 ;; let's search the extents
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
135 (catch 'dragdrop-extents-done
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
136 (let ((window (event-window event))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
137 (pos (event-point event))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
138 (cpos (event-closest-point event))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
139 (buffer nil))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
140 (or window (throw 'dragdrop-extents-done nil))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
141 (or pos (setq pos cpos))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
142 (select-window window)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
143 (setq buffer (window-buffer))
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
144 (let ((ext (extent-at pos buffer 'experimental-dragdrop-drop-functions)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
145 (while (not (eq ext nil))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
146 (dragdrop-drop-do-functions
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
147 (extent-property ext 'experimental-dragdrop-drop-functions)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
148 event
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
149 object)
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
150 (setq ext (extent-at pos buffer
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
151 'experimental-dragdrop-drop-functions
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
152 ext)))))))
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
153 ;; now look into the variable experimental-dragdrop-drop-functions
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
154 (dragdrop-drop-do-functions experimental-dragdrop-drop-functions event object)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
155
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
156 (defun dragdrop-compare-mods (first-mods second-mods)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
157 "Returns t if both first-mods and second-mods contain the same elements.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
158 Order is not important."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
159 (let ((moda (copy-sequence first-mods))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
160 (modb (copy-sequence second-mods)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
161 (while (and (not (eq moda ()))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
162 (not (eq modb ())))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
163 (setq modb (delete (car moda) modb))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
164 (setq moda (delete (car moda) moda)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
165 (and (eq moda ())
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
166 (eq modb ()))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
167
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
168 (defun dragdrop-drop-do-functions (drop-funs event object)
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
169 "Calls all functions in drop-funs with object until one returns t.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
170 Returns t if one of drop-funs returns t. Otherwise returns nil."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
171 (let ((flist nil)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
172 (button (event-button event))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
173 (mods (event-modifiers event)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
174 (while (not (eq drop-funs ()))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
175 (setq flist (car drop-funs))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
176 (and (or (eq (cadr flist) t)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
177 (= (cadr flist) button))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
178 (or (eq (caddr flist) t)
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 290
diff changeset
179 (dragdrop-compare-mods (caddr flist) mods))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
180 (apply (car flist) `(,event ,object ,@(cdddr flist)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
181 ;; (funcall (car flist) event object)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
182 (throw 'dragdrop-drop-is-done t))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
183 (setq drop-funs (cdr drop-funs))))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
184 nil)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
185
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
186 (defun experimental-dragdrop-drop-log-function (event object &optional message buffer)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
187 "*{EXPERIMENTAL} Logs any drops into a buffer.
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
188 If buffer is nil, it inserts the data into a buffer called after
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
189 dragdrop-drop-log-name.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
190 If dragdrop-drop-log is non-nil, this is done automatically for each drop.
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
191 The function always returns nil."
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
192 (save-excursion
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
193 (cond ((buffer-live-p buffer)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
194 (set-buffer buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
195 ((stringp buffer)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
196 (set-buffer (get-buffer-create buffer)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
197 ((buffer-live-p dragdrop-drop-log-buffer)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
198 (set-buffer dragdrop-drop-log-buffer))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
199 (t
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
200 (setq dragdrop-drop-log-buffer (get-buffer-create dragdrop-drop-log-name))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
201 (set-buffer dragdrop-drop-log-buffer)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
202 (insert (format "* %s: %s\n"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
203 (current-time-string)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
204 (if message message "received a drop")))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
205 (insert (format " at %d,%d (%d,%d) with button %d and mods %s\n"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
206 (event-x event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
207 (event-y event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
208 (event-x-pixel event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
209 (event-y-pixel event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
210 (event-button event)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
211 (event-modifiers event)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
212 (insert (format " data is of type %s (%d %s)\n"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
213 (cond ((eq (car object) 'dragdrop-URL) "URL")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
214 ((eq (car object) 'dragdrop-MIME) "MIME")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
215 (t "UNKNOWN"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
216 (length (cdr object))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
217 (if (= (length (cdr object)) 1) "element" "elements")))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
218 (let ((i 1)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
219 (data (cdr object)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
220 (while (not (eq data ()))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
221 (insert (format " Element %d: %S\n"
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
222 i (car data)))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
223 (setq i (1+ i))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
224 (setq data (cdr data))))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
225 (insert "----------\n"))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
226 nil)
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
227
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
228 (defun experimental-dragdrop-drop-url-default (event object)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
229 "*{EXPERIMENTAL} Default handler for dropped URL data.
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
230 Finds files and URLs. Returns nil if object does not contain URL data."
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
231 (cond ((eq (car object) 'dragdrop-URL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
232 (let ((data (cdr object))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
233 (frame (event-channel event))
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
234 (x pop-up-windows)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
235 (window (event-window event)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
236 (setq pop-up-windows nil)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
237 (while (not (eq data ()))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
238 (cond ((dragdrop-is-some-url "file" (car data))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
239 ;; if it is some file, pop it to a buffer
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
240 (cond (window
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
241 (select-window window)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
242 (switch-to-buffer (find-file-noselect
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
243 (substring (car data) 5))))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
244 ;; to-do: open ftp URLs with efs...
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
245 (t
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
246 ;; some other URL, try to fire up some browser for it
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
247 (if (boundp 'browse-url-browser-function)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
248 (funcall browse-url-browser-function (car data))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
249 (display-message 'error
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
250 "Can't show URL, no browser selected"))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
251 (undo-boundary)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
252 (setq data (cdr data)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
253 (make-frame-visible frame)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
254 (setq pop-up-windows x)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
255 t))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
256 (t nil)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
257
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
258 (defun experimental-dragdrop-drop-mime-default (event object)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
259 "*{EXPERIMENTAL} Default handler for dropped MIME data.
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
260 Inserts text into buffer, creates MIME buffers for other types.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
261 Returns nil if object does not contain MIME data."
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
262 (cond ((eq (car object) 'dragdrop-MIME)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
263 (let ((ldata (cdr object))
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
264 (frame (event-channel event))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
265 (x pop-up-windows)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
266 (data nil))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
267 ;; how should this be handled???
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
268 ;; insert drops of text/* into buffer
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
269 ;; create new buffer if pointer is outside buffer...
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
270 ;; but there are many other ways...
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
271 ;;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
272 ;; first thing: check if it's only text/plain and if the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
273 ;; drop happened inside some buffer. if yes insert it into
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
274 ;; this buffer (hope it is not encoded in some MIME way)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
275 ;;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
276 ;; Remember: ("text/plain" "dosnotmatter" "somedata")
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
277 ;; drops are inserted at mouse-point, if inside a buffer
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
278 (while (not (eq ldata ()))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
279 (setq data (car ldata))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
280 (if (and (listp data)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
281 (= (length data) 3)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
282 (listp (car data))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
283 (stringp (caar data))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
284 (string= (caar data) "text/plain")
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
285 (event-over-text-area-p event))
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
286 (let ((window (event-window event)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
287 (and window
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
288 (select-window window))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
289 (and (not dragdrop-drop-at-point)
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
290 (mouse-set-point event))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
291 (insert (caddr data)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
292 (let ((buf (get-buffer-create "*MIME-Drop data*")))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
293 (set-buffer buf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
294 (pop-to-buffer buf nil frame)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
295 (or (featurep 'tm-view)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
296 (and dragdrop-autoload-tm-view
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
297 (require 'tm-view)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
298 (cond ((stringp data)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
299 ;; this is some raw MIME stuff
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
300 ;; create some buffer and let tm do the job
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
301 ;;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
302 ;; this is always the same buffer!!!
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
303 ;; change?
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
304 (erase-buffer)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
305 (insert data)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
306 (and (featurep 'tm-view)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
307 (mime/viewer-mode buf)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
308 ((and (listp data)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
309 (= (length data) 3))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
310 ;; change the internal content-type representation to the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
311 ;; way tm does it ("content/type" (key . value)*)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
312 ;; but for now list will do the job
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
313 ;;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
314 ;; this is always the same buffer!!!
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
315 ;; change?
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
316 (erase-buffer)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
317 (insert (caddr data))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
318 (and (featurep 'tm-view)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
319 ;; this list of (car data) should be done before
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
320 ;; enqueing the event
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
321 (mime/viewer-mode buf (car data) (cadr data))))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
322 (t
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
323 (display-message 'error "Wrong drop data")))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
324 (undo-boundary)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
325 (setq ldata (cdr ldata)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
326 (make-frame-visible frame)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
327 (setq pop-up-windows x))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
328 t)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
329 (t nil)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
330
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
331 (defun dragdrop-is-some-url (method url)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
332 "Returns true if method equals the start of url.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
333 If method does not end into ':' this is appended before the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
334 compare."
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
335 (cond ((and (stringp url)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
336 (stringp method)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
337 (> (length url) (length method)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
338 ;; is this ?: check efficient enough?
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
339 (if (not (string= (substring method -1) ":"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
340 (setq method (concat method ":")))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
341 (string= method (substring url 0 (length method))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
342 (t nil)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
343
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
344 ;;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
345 ;; Drag API
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
346 ;;
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
347 (defun experimental-dragdrop-drag (event object)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
348 "*{EXPERIMENTAL} The generic drag function.
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
349 Tries to do the best with object in the selected protocol.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
350 Object must comply to the standart drag'n'drop object
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
351 format."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
352 (error "Not implemented"))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
353
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
354 (defun experimental-dragdrop-drag-region (event begin end)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
355 "*{EXPERIMENTAL} Drag a region.
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
356 This function uses special data types if the low-level
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
357 protocol requires it. It does so by calling
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
358 dragdrop-drag-pure-text."
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 290
diff changeset
359 (experimental-dragdrop-drag-pure-text event
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
360 (buffer-substring-no-properties begin end)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
361
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
362 (defun experimental-dragdrop-drag-pure-text (event text)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
363 "*{EXPERIMENTAL} Drag text-only data.
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
364 Takes care of special low-level protocol data types.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
365 Text must be a list of strings."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
366 (error "Not implemented"))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
367
290
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
368 (defun experimental-dragdrop-drag-pure-file (event file)
c9fe270a4101 Import from CVS: tag r21-0b43
cvs
parents: 288
diff changeset
369 "*{EXPERIMENTAL} Drag filepath-only data.
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
370 Takes care of special low-level protocol data types.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
371 file must be a list of strings."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
372 (error "Not implemented"))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
373
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
374 ;;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
375 ;; The following ones come from frame.el but the better belong here
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
376 ;; until changed
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
377 ;;
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
378 (defun cde-start-drag (event type data)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
379 "Implement the CDE drag operation.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
380 Calls the internal function cde-start-drag-internal to do the actual work."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
381 (interactive "_eXX")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
382 (if (featurep 'cde)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
383 ;; Avoid build-time doc string warning by calling the function
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
384 ;; in the following roundabout way:
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
385 (funcall (intern "cde-start-drag-internal")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
386 event type data)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
387 (error "CDE functionality not compiled in.")))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
388
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
389 (defun cde-start-drag-region (event begin end)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
390 "Implement the CDE drag operation for a region.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
391 Calls the internal function CDE-start-drag-internal to do the actual work.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
392 This always does buffer transfers."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
393 ;; Oliver Graf <ograf@fga.de>
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
394 (interactive "_er")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
395 (if (featurep 'cde)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
396 (funcall (intern "cde-start-drag-internal")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
397 event nil (list (buffer-substring-no-properties begin end)))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
398 (error "CDE functionality not compiled in.")))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
399
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
400 ;; the OffiX drag stuff will soon move also (perhaps mouse.el)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
401 ;; if the drag event is done
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
402 (defun offix-start-drag (event data &optional type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
403 "Implement the OffiX drag operation.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
404 Calls the internal function offix-start-drag-internal to do the actual work.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
405 If type is not given, DndText is assumed."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
406 ;; Oliver Graf <ograf@fga.de>
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
407 (interactive "esi")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
408 (if (featurep 'offix)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
409 (funcall (intern "offix-start-drag-internal") event data type)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
410 (error "OffiX functionality not compiled in.")))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
411
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
412 (defun offix-start-drag-region (event begin end)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
413 "Implement the OffiX drag operation for a region.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
414 Calls the internal function offix-start-drag-internal to do the actual work.
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
415 This always assumes DndText as type."
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
416 ;; Oliver Graf <ograf@fga.de>
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
417 (interactive "_er")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
418 (if (featurep 'offix)
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
419 (funcall (intern "offix-start-drag-internal")
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
420 event (buffer-substring-no-properties begin end))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
421 (error "OffiX functionality not compiled in.")))
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
422
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 284
diff changeset
423
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
424 ;;; dragdrop.el ends here