Mercurial > hg > xemacs-beta
annotate src/dragdrop.c @ 4690:257b468bf2ca
Move the #'query-coding-region implementation to C.
This is necessary because there is no reasonable way to access the
corresponding mswindows-multibyte functionality from Lisp, and we need such
functionality if we're going to have a reliable and portable
#'query-coding-region implementation. However, this change doesn't yet
provide #'query-coding-region for the mswindow-multibyte coding systems,
there should be no functional differences between an XEmacs with this change
and one without it.
src/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
Move the #'query-coding-region implementation to C.
This is necessary because there is no reasonable way to access the
corresponding mswindows-multibyte functionality from Lisp, and we
need such functionality if we're going to have a reliable and
portable #'query-coding-region implementation. However, this
change doesn't yet provide #'query-coding-region for the
mswindow-multibyte coding systems, there should be no functional
differences between an XEmacs with this change and one without it.
* mule-coding.c (struct fixed_width_coding_system):
Add a new coding system type, fixed_width, and implement it. It
uses the CCL infrastructure but has a much simpler creation API,
and its own query_method, formerly in lisp/mule/mule-coding.el.
* unicode.c:
Move the Unicode query method implementation here from
unicode.el.
* lisp.h: Declare Fmake_coding_system_internal, Fcopy_range_table
here.
* intl-win32.c (complex_vars_of_intl_win32):
Use Fmake_coding_system_internal, not Fmake_coding_system.
* general-slots.h: Add Qsucceeded, Qunencodable, Qinvalid_sequence
here.
* file-coding.h (enum coding_system_variant):
Add fixed_width_coding_system here.
(struct coding_system_methods):
Add query_method and query_lstream_method to the coding system
methods.
Provide flags for the query methods.
Declare the default query method; initialise it correctly in
INITIALIZE_CODING_SYSTEM_TYPE.
* file-coding.c (default_query_method):
New function, the default query method for coding systems that do
not set it. Moved from coding.el.
(make_coding_system_1):
Accept new elements in PROPS in #'make-coding-system; aliases, a
list of aliases; safe-chars and safe-charsets (these were
previously accepted but not saved); and category.
(Fmake_coding_system_internal):
New function, what used to be #'make-coding-system--on Mule
builds, we've now moved some of the functionality of this to
Lisp.
(Fcoding_system_canonical_name_p):
Move this earlier in the file, since it's now called from within
make_coding_system_1.
(Fquery_coding_region):
Move the implementation of this here, from coding.el.
(complex_vars_of_file_coding):
Call Fmake_coding_system_internal, not Fmake_coding_system;
specify safe-charsets properties when we're a mule build.
* extents.h (mouse_highlight_priority, Fset_extent_priority,
Fset_extent_face, Fmap_extents):
Make these available to other C files.
lisp/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
Move the #'query-coding-region implementation to C.
* coding.el:
Consolidate code that depends on the presence or absence of Mule
at the end of this file.
(default-query-coding-region, query-coding-region):
Move these functions to C.
(default-query-coding-region-safe-charset-skip-chars-map):
Remove this variable, the corresponding C variable is
Vdefault_query_coding_region_chartab_cache in file-coding.c.
(query-coding-string): Update docstring to reflect actual multiple
values, be more careful about not modifying a range table that
we're currently mapping over.
(encode-coding-char): Make the implementation of this simpler.
(featurep 'mule): Autoload #'make-coding-system from
mule/make-coding-system.el if we're a mule build; provide an
appropriate compiler macro.
Do various non-mule compatibility things if we're not a mule
build.
* update-elc.el (additional-dump-dependencies):
Add mule/make-coding-system as a dump time dependency if we're a
mule build.
* unicode.el (ccl-encode-to-ucs-2):
(decode-char):
(encode-char):
Move these earlier in the file, for the sake of some byte compile
warnings.
(unicode-query-coding-region):
Move this to unicode.c
* mule/make-coding-system.el:
New file, not dumped. Contains the functionality to rework the
arguments necessary for fixed-width coding systems, and contains
the implementation of #'make-coding-system, which now calls
#'make-coding-system-internal.
* mule/vietnamese.el (viscii):
* mule/latin.el (iso-8859-2):
(windows-1250):
(iso-8859-3):
(iso-8859-4):
(iso-8859-14):
(iso-8859-15):
(iso-8859-16):
(iso-8859-9):
(macintosh):
(windows-1252):
* mule/hebrew.el (iso-8859-8):
* mule/greek.el (iso-8859-7):
(windows-1253):
* mule/cyrillic.el (iso-8859-5):
(koi8-r):
(koi8-u):
(windows-1251):
(alternativnyj):
(koi8-ru):
(koi8-t):
(koi8-c):
(koi8-o):
* mule/arabic.el (iso-8859-6):
(windows-1256):
Move all these coding systems to being of type fixed-width, not of
type CCL. This allows the distinct query-coding-region for them to
be in C, something which will eventually allow us to implement
query-coding-region for the mswindows-multibyte coding systems.
* mule/general-late.el (posix-charset-to-coding-system-hash):
Document why we're pre-emptively persuading the byte compiler that
the ELC for this file needs to be written using escape-quoted.
Call #'set-unicode-query-skip-chars-args, now the Unicode
query-coding-region implementation is in C.
* mule/thai-xtis.el (tis-620):
Don't bother checking whether we're XEmacs or not here.
* mule/mule-coding.el:
Move the eight bit fixed-width functionality from this file to
make-coding-system.el.
tests/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
* automated/mule-tests.el:
Check a coding system's type, not an 8-bit-fixed property, for
whether that coding system should be treated as a fixed-width
coding system.
* automated/query-coding-tests.el:
Don't test the query coding functionality for mswindows-multibyte
coding systems, it's not yet implemented.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 19 Sep 2009 22:53:13 +0100 |
parents | facf3239ba30 |
children | bc4f2511bbea |
rev | line source |
---|---|
428 | 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> | |
2367 | 4 Copyright (C) 2004 Ben Wing. |
428 | 5 |
6 This file is part of XEmacs. | |
7 | |
8 XEmacs is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
10 Free Software Foundation; either version 2, or (at your option) any | |
11 later version. | |
12 | |
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with XEmacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
22 | |
23 /* Synched up with: Not in FSF. */ | |
24 | |
25 /* This file should be Mule-ized. */ | |
26 | |
27 /* A short introduction to the new Drag'n'Drop Model: | |
28 | |
29 Currently only drops from OffiX are implemented. | |
30 | |
31 A drop generates a extended misc-user-event, as defined in events.[ch]. | |
32 This event contains the same as a eval and a button event. | |
33 The function of a drop is set to 'dragdrop-drop-dispatch' which will be | |
34 defined in ../lisp/dragdrop.el. | |
35 The object of the misc-user-event has the following format: | |
36 ( TYPE . DATA ) | |
3025 | 37 TYPE is one of `dragdrop-MIME' and `dragdrop-URL' |
38 DATA - if TYPE is `dragdrop-URL', DATA is a list of valid URL strings. It | |
428 | 39 is always a list, also if only one URL string is within it. |
3025 | 40 - if TYPE is `dragdrop-MIME', DATA is a list of MIME elements. |
428 | 41 Each can be a string or a list. |
42 if it is a string it is the pure MIME data complete with header | |
43 and body. | |
44 if it is a list it should look like | |
45 ( MIME-TYPE MIME-ENCODING MIME-DATA ) | |
46 MIME-TYPE list of type and key.value conses. Same as in tm-view | |
47 MIME-ENC the same (a string in this case) | |
48 MIME-DATA is a string | |
49 */ | |
50 | |
51 #include <config.h> | |
52 #include "lisp.h" | |
53 #include "dragdrop.h" | |
54 | |
55 /* The supported protocol list */ | |
56 Lisp_Object Vdragdrop_protocols; | |
57 | |
58 /* Drag'n'Drop data types known by XEmacs */ | |
59 Lisp_Object Qdragdrop_MIME; | |
60 Lisp_Object Qdragdrop_URL; | |
61 | |
62 /* External defined functions to handle Drag'n'Drop */ | |
63 Lisp_Object Qdragdrop_drop_dispatch; | |
64 | |
65 /* from wget -- thanxx Hrvoje */ | |
66 /* A list of unsafe characters for encoding, as per RFC1738. '@' and | |
67 ':' (not listed in RFC) were added because of user/password | |
68 encoding, and \033 for safe printing. */ | |
69 | |
70 #define URL_UNSAFE " <>\"#%{}|\\^~[]`@:\033" | |
71 | |
72 /* HEX digit -> ASCII char */ | |
73 #define HEXD2ASC(x) (((x) < 10) ? ((x) + '0') : ((x) - 10 + 'A')) | |
74 | |
75 /* Encodes the unsafe characters (listed in URL_UNSAFE) in a given | |
76 string, returning a malloc-ed %XX encoded string. | |
77 if method is != NULL it is prepended to the string. */ | |
2367 | 78 Ibyte * |
79 dnd_url_hexify_string (const Ibyte *s, const Ibyte *m) | |
428 | 80 { |
2367 | 81 const Ibyte *b; |
82 Ibyte *p, *res; | |
83 Bytecount i; | |
428 | 84 |
85 b = s; | |
86 for (i = 0; *s; s++, i++) | |
87 if (strchr (URL_UNSAFE, *s)) | |
88 i += 2; /* Two more characters (hex digits) */ | |
89 if (m) | |
90 { | |
2367 | 91 res = xnew_ibytes (i + ITEXT_ZTERM_SIZE + qxestrlen (m)); |
92 qxestrcpy (res, m); | |
93 p = res + qxestrlen (m); | |
428 | 94 } |
95 else | |
96 { | |
2367 | 97 res = xnew_ibytes (i + ITEXT_ZTERM_SIZE); |
428 | 98 p = res; |
99 } | |
100 for (s = b; *s; s++) | |
101 if (strchr (URL_UNSAFE, *s)) | |
102 { | |
2367 | 103 const Ibyte c = *s; |
428 | 104 *p++ = '%'; |
105 *p++ = HEXD2ASC (c >> 4); | |
106 *p++ = HEXD2ASC (c & 0xf); | |
107 } | |
108 else | |
109 *p++ = *s; | |
110 *p = '\0'; | |
111 return res; | |
112 } | |
113 | |
114 void | |
115 syms_of_dragdrop (void) | |
116 { | |
563 | 117 DEFSYMBOL (Qdragdrop_MIME); |
118 DEFSYMBOL (Qdragdrop_URL); | |
119 DEFSYMBOL (Qdragdrop_drop_dispatch); | |
428 | 120 } |
121 | |
122 void | |
123 vars_of_dragdrop (void) | |
124 { | |
125 Fprovide (intern ("dragdrop-api")); | |
126 | |
127 DEFVAR_CONST_LISP ("dragdrop-protocols", &Vdragdrop_protocols /* | |
128 A list of supported Drag'n'drop protocols. | |
129 Each element is the feature symbol of the protocol. | |
130 */ ); | |
131 | |
132 Vdragdrop_protocols = Qnil; | |
133 | |
134 #ifdef HAVE_MS_WINDOWS | |
2367 | 135 Vdragdrop_protocols = Fcons (Qmswindows, Vdragdrop_protocols); |
428 | 136 #endif |
137 #ifdef HAVE_CDE | |
2367 | 138 Vdragdrop_protocols = Fcons (intern ("cde"), Vdragdrop_protocols); |
428 | 139 #endif |
140 #ifdef HAVE_OFFIX_DND | |
2367 | 141 Vdragdrop_protocols = Fcons (intern ("offix"), Vdragdrop_protocols); |
428 | 142 #endif |
462 | 143 #ifdef HAVE_GTK |
2367 | 144 Vdragdrop_protocols = Fcons (Qgtk, Vdragdrop_protocols); |
462 | 145 #endif |
428 | 146 } |