annotate lisp/dragdrop.el @ 5891:a0e751d6c3ad

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