Mercurial > hg > xemacs-beta
annotate tests/Dnd/droptest.el @ 5885:c8bbb32fe124
Always return a string, #'current-message.
lisp/ChangeLog addition:
2015-04-04 Aidan Kehoe <kehoea@parhasard.net>
* gutter-items.el (append-progress-feedback):
* gutter-items.el (abort-progress-feedback):
Correct comments in both these functions, it's the progress stack
being adjusted, not the message stack.
* simple.el (message-stack):
Describe my recent change in the structure of this.
* simple.el (current-message):
Adjust the implementation of this to always return the string
displayed.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 04 Apr 2015 13:49:30 +0100 |
parents | d88ad9ccfa66 |
children |
rev | line source |
---|---|
428 | 1 ;; a short example how to use the new Drag'n'Drop API in |
2 ;; combination with extents. | |
5423
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
3 |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
4 ;; Copyright (C) 1998 Oliver Graf <ograf@fga.de> |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
5 |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
6 ;; This file is part of XEmacs. |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
7 |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
8 ;; XEmacs is free software: you can redistribute it and/or modify it |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
9 ;; under the terms of the GNU General Public License as published by the |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
10 ;; Free Software Foundation, either version 3 of the License, or (at your |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
11 ;; option) any later version. |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
12 |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
13 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
15 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
16 ;; for more details. |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
17 |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
18 ;; You should have received a copy of the GNU General Public License |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
19 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
20 |
d88ad9ccfa66
Migrate the rest of tests/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4790
diff
changeset
|
21 ;;; Synched up with: Not in FSF. |
428 | 22 |
23 (defun dnd-drop-message (event object text) | |
24 (message "Dropped %s with :%s" text object) | |
25 ;; signal that we have done something with the data | |
26 t) | |
27 | |
28 (defun do-nothing (event object) | |
29 ;; signal that the data is still unprocessed | |
30 nil) | |
31 | |
32 (defun start-drag (event what &optional typ) | |
33 ;; short drag interface, until the real one is implemented | |
4790
bc4f2511bbea
Remove support for the OffiX drag-and-drop protocol. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
428
diff
changeset
|
34 (cond ((featurep 'cde) |
428 | 35 (if (not typ) |
36 (funcall (intern "cde-start-drag-internal") event nil (list what)) | |
37 (funcall (intern "cde-start-drag-internal") event t what))) | |
38 (t display-message 'error "no valid drag protocols implemented"))) | |
39 | |
40 (defun start-region-drag (event) | |
41 (interactive "_e") | |
42 (if (click-inside-extent-p event zmacs-region-extent) | |
43 ;; okay, this is a drag | |
4790
bc4f2511bbea
Remove support for the OffiX drag-and-drop protocol. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
428
diff
changeset
|
44 (cond ((featurep 'cde) |
428 | 45 (cde-start-drag-region event |
46 (extent-start-position zmacs-region-extent) | |
47 (extent-end-position zmacs-region-extent))) | |
4790
bc4f2511bbea
Remove support for the OffiX drag-and-drop protocol. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
428
diff
changeset
|
48 (t (error "No CDE support compiled in"))))) |
428 | 49 |
50 (defun make-drop-targets () | |
51 (let ((buf (get-buffer-create "*DND misc-user extent test buffer*")) | |
52 (s nil) | |
53 (e nil)) | |
54 (set-buffer buf) | |
55 (pop-to-buffer buf) | |
56 (setq s (point)) | |
57 (insert "[ DROP TARGET 1]") | |
58 (setq e (point)) | |
59 (setq ext (make-extent s e)) | |
60 (set-extent-property ext | |
61 'experimental-dragdrop-drop-functions | |
62 '((do-nothing t t) | |
63 (dnd-drop-message t t "on target 1"))) | |
64 (set-extent-property ext 'mouse-face 'highlight) | |
65 (insert " ") | |
66 (setq s (point)) | |
67 (insert "[ DROP TARGET 2]") | |
68 (setq e (point)) | |
69 (setq ext (make-extent s e)) | |
70 (set-extent-property ext | |
71 'experimental-dragdrop-drop-functions | |
72 '((dnd-drop-message t t "on target 2"))) | |
73 (set-extent-property ext 'mouse-face 'highlight) | |
74 (insert " ") | |
75 (setq s (point)) | |
76 (insert "[ DROP TARGET 3]") | |
77 (setq e (point)) | |
78 (setq ext (make-extent s e)) | |
79 (set-extent-property ext | |
80 'experimental-dragdrop-drop-functions | |
81 '((dnd-drop-message t t "on target 3"))) | |
82 (set-extent-property ext 'mouse-face 'highlight) | |
83 (newline 2))) | |
84 | |
85 (defun make-drag-starters () | |
86 (let ((buf (get-buffer-create "*DND misc-user extent test buffer*")) | |
87 (s nil) | |
88 (e nil) | |
89 (ext nil) | |
90 (kmap nil)) | |
91 (set-buffer buf) | |
92 (pop-to-buffer buf) | |
93 (erase-buffer buf) | |
94 (insert "Try to drag data from one of the upper extents to one\nof the lower extents. Make sure that your minibuffer is big\ncause it is used to display the data.\n\nYou may also try to select some of this text and drag it with button2.\n\nTo ") | |
95 (setq s (point)) | |
96 (insert "EXIT") | |
97 (setq e (point)) | |
98 (insert " this demo, press 'q'.") | |
99 (setq ext (make-extent s e)) | |
100 (setq kmap (make-keymap)) | |
101 (define-key kmap [button1] 'end-dnd-demo) | |
102 (set-extent-property ext 'keymap kmap) | |
103 (set-extent-property ext 'mouse-face 'highlight) | |
104 (newline 2) | |
105 (setq s (point)) | |
106 (insert "[ TEXT DRAG TEST ]") | |
107 (setq e (point)) | |
108 (setq ext (make-extent s e)) | |
109 (set-extent-property ext 'mouse-face 'isearch) | |
110 (setq kmap (make-keymap)) | |
111 (define-key kmap [button1] 'text-drag) | |
112 (set-extent-property ext 'keymap kmap) | |
113 (insert " ") | |
114 (setq s (point)) | |
115 (insert "[ FILE DRAG TEST ]") | |
116 (setq e (point)) | |
117 (setq ext (make-extent s e)) | |
118 (set-extent-property ext 'mouse-face 'isearch) | |
119 (setq kmap (make-keymap)) | |
120 (if (featurep 'cde) | |
121 (define-key kmap [button1] 'cde-file-drag) | |
122 (define-key kmap [button1] 'file-drag)) | |
123 (set-extent-property ext 'keymap kmap) | |
124 (insert " ") | |
125 (setq s (point)) | |
126 (insert "[ FILES DRAG TEST ]") | |
127 (setq e (point)) | |
128 (setq ext (make-extent s e)) | |
129 (set-extent-property ext 'mouse-face 'isearch) | |
130 (setq kmap (make-keymap)) | |
131 (define-key kmap [button1] 'files-drag) | |
132 (set-extent-property ext 'keymap kmap) | |
133 (insert " ") | |
134 (setq s (point)) | |
135 (insert "[ URL DRAG TEST ]") | |
136 (setq e (point)) | |
137 (setq ext (make-extent s e)) | |
138 (set-extent-property ext 'mouse-face 'isearch) | |
139 (setq kmap (make-keymap)) | |
140 (if (featurep 'cde) | |
141 (define-key kmap [button1] 'cde-file-drag) | |
142 (define-key kmap [button1] 'url-drag)) | |
143 (set-extent-property ext 'keymap kmap) | |
144 (newline 3))) | |
145 | |
146 (defun text-drag (event) | |
147 (interactive "@e") | |
148 (start-drag event "That's a test")) | |
149 | |
150 (defun file-drag (event) | |
151 (interactive "@e") | |
152 (start-drag event "/tmp/DropTest.xpm" 2)) | |
153 | |
154 (defun cde-file-drag (event) | |
155 (interactive "@e") | |
156 (start-drag event '("/tmp/DropTest.xpm") t)) | |
157 | |
158 (defun url-drag (event) | |
159 (interactive "@e") | |
160 (start-drag event "http://www.xemacs.org/" 8)) | |
161 | |
162 (defun files-drag (event) | |
163 (interactive "@e") | |
164 (start-drag event '("/tmp/DropTest.html" "/tmp/DropTest.xpm" "/tmp/DropTest.tex") 3)) | |
165 | |
166 (setq experimental-dragdrop-drop-functions '((do-nothing t t) | |
167 ;; CDE does not have any button info... | |
168 (dnd-drop-message 0 t "cde-drop somewhere else") | |
169 (dnd-drop-message 2 t "region somewhere else") | |
170 (dnd-drop-message 1 t "drag-source somewhere else") | |
171 (do-nothing t t))) | |
172 | |
173 (make-drag-starters) | |
174 (make-drop-targets) | |
175 | |
176 (defun end-dnd-demo () | |
177 (interactive) | |
178 (global-set-key [button2] button2-func) | |
179 (bury-buffer)) | |
180 | |
181 (setq lmap (make-keymap)) | |
182 (use-local-map lmap) | |
183 (local-set-key [q] 'end-dnd-demo) | |
184 (setq button2-func (lookup-key global-map [button2])) | |
185 (global-set-key [button2] 'start-region-drag) |