1 /* Drag'n'Drop definitions
2 created 03-may-98 by Oliver Graf <ograf@fga.de>
3 Copyright (C) 1998 Oliver Graf <ograf@fga.de>
5 This file is part of XEmacs.
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Synched up with: Not in FSF. */
24 /* This file should be Mule-ized. */
26 /* A short introduction to the new Drag'n'Drop Model:
28 Currently only drops from OffiX are implemented.
30 A drop generates a extended misc-user-event, as defined in events.[ch].
31 This event contains the same as a eval and a button event.
32 The function of a drop is set to 'dragdrop-drop-dispatch' which will be
33 defined in ../lisp/dragdrop.el.
34 The object of the misc-user-event has the following format:
36 TYPE is one of 'dragdrop-MIME and 'dragdrop-URL
37 DATA - if TYPE is 'dragdrop-URL, DATA is a list of valid URL strings. It
38 is always a list, also if only one URL string is within it.
39 - if TYPE is 'dragdrop-MIME, DATA is a list of MIME elements.
40 Each can be a string or a list.
41 if it is a string it is the pure MIME data complete with header
43 if it is a list it should look like
44 ( MIME-TYPE MIME-ENCODING MIME-DATA )
45 MIME-TYPE list of type and key.value conses. Same as in tm-view
46 MIME-ENC the same (a string in this case)
54 /* The supported protocol list */
55 Lisp_Object Vdragdrop_protocols;
57 /* Drag'n'Drop data types known by XEmacs */
58 Lisp_Object Qdragdrop_MIME;
59 Lisp_Object Qdragdrop_URL;
61 /* External defined functions to handle Drag'n'Drop */
62 Lisp_Object Qdragdrop_drop_dispatch;
64 /* from wget -- thanxx Hrvoje */
65 /* A list of unsafe characters for encoding, as per RFC1738. '@' and
66 ':' (not listed in RFC) were added because of user/password
67 encoding, and \033 for safe printing. */
69 #define URL_UNSAFE " <>\"#%{}|\\^~[]`@:\033"
71 /* HEX digit -> ASCII char */
72 #define HEXD2ASC(x) (((x) < 10) ? ((x) + '0') : ((x) - 10 + 'A'))
74 /* Encodes the unsafe characters (listed in URL_UNSAFE) in a given
75 string, returning a malloc-ed %XX encoded string.
76 if method is != NULL it is prepended to the string. */
78 dnd_url_hexify_string (const char *s, const char *m)
85 for (i = 0; *s; s++, i++)
86 if (strchr (URL_UNSAFE, *s))
87 i += 2; /* Two more characters (hex digits) */
90 res = (char *)xmalloc (i + 1 + strlen (m));
96 res = (char *)xmalloc (i + 1);
100 if (strchr (URL_UNSAFE, *s))
102 const unsigned char c = *s;
104 *p++ = HEXD2ASC (c >> 4);
105 *p++ = HEXD2ASC (c & 0xf);
114 syms_of_dragdrop (void)
116 defsymbol (&Qdragdrop_MIME, "dragdrop-MIME");
117 defsymbol (&Qdragdrop_URL, "dragdrop-URL");
118 defsymbol (&Qdragdrop_drop_dispatch, "dragdrop-drop-dispatch");
122 vars_of_dragdrop (void)
124 Fprovide (intern ("dragdrop-api"));
126 DEFVAR_CONST_LISP ("dragdrop-protocols", &Vdragdrop_protocols /*
127 A list of supported Drag'n'drop protocols.
128 Each element is the feature symbol of the protocol.
131 Vdragdrop_protocols = Qnil;
133 #ifdef HAVE_MS_WINDOWS
134 Vdragdrop_protocols = Fcons ( Qmswindows , Vdragdrop_protocols );
137 Vdragdrop_protocols = Fcons ( intern ("cde") , Vdragdrop_protocols );
139 #ifdef HAVE_OFFIX_DND
140 Vdragdrop_protocols = Fcons ( intern ("offix") , Vdragdrop_protocols );
143 Vdragdrop_protocols = Fcons ( Qgtk , Vdragdrop_protocols );