1268
|
1 /* Shared event code between X and GTK -- include file.
|
|
2 Copyright (C) 1991-5, 1997 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
4 Copyright (C) 1996, 2001, 2002, 2003 Ben Wing.
|
|
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 /* For some code it's reasonable to have only one copy and conditionalize
|
|
26 at run-time. For other code it isn't. #### Perhaps all code should be
|
|
27 included here, not in event-xlike.c. However, event-xlike.c is always
|
|
28 X-specific, whereas the following code isn't, in the GTK case. */
|
|
29
|
|
30 static int
|
|
31 #ifdef THIS_IS_GTK
|
|
32 emacs_gtk_event_pending_p (int how_many)
|
|
33 #else
|
|
34 emacs_Xt_event_pending_p (int how_many)
|
|
35 #endif
|
|
36 {
|
|
37 Lisp_Object event;
|
|
38 int tick_count_val;
|
|
39
|
|
40 /* If `how_many' is 0, then this function returns whether there are any
|
|
41 X, timeout, or fd events pending (that is, whether
|
|
42 emacs_Xt_next_event() would return immediately without blocking).
|
|
43
|
|
44 If `how_many' is > 0, then this function returns whether there are
|
|
45 that many *user generated* events available (keyboard, mouse click,
|
|
46 etc.). This also implies that emacs_Xt_next_event() would not block.
|
|
47 */
|
|
48
|
|
49 /* This function used to simply check whether there were any X events (or
|
|
50 if user_p was 1, it iterated over all the pending X events using
|
|
51 XCheckIfEvent(), looking for keystrokes and button events). That
|
|
52 worked in the old cheesoid event loop, which didn't go through
|
|
53 XtAppDispatchEvent(), but it doesn't work any more -- X events may not
|
|
54 result in anything. For example, a button press in a blank part of
|
|
55 the menubar appears as an X event but will not result in any Emacs
|
|
56 events (a button press that activates the menubar results in an Emacs
|
|
57 event through the stop_next_event mechanism).
|
|
58
|
|
59 The only accurate way of determining whether these X events translate
|
|
60 into Emacs events is to go ahead and dispatch them until there's
|
|
61 something on the dispatch queue. */
|
|
62
|
|
63 if (!how_many)
|
|
64 {
|
|
65 /* We're being asked for *ALL* events, not just user events. */
|
|
66
|
|
67 /* (1) Any pending events in the dispatch queue? */
|
|
68 if (!NILP (dispatch_event_queue))
|
|
69 return 1;
|
|
70
|
|
71 /* (2) Any TTY or process input available?
|
|
72
|
|
73 Note that formerly we just checked the value of XtAppPending() to
|
|
74 determine if there was file-desc input. This doesn't work any
|
|
75 more with the signal_event_pipe; XtAppPending() will says "yes" in
|
|
76 this case but there isn't really any input. So instead we keep
|
|
77 track of the file descriptors, and call select() ourselves.
|
|
78 Another way of fixing this problem is for the signal_event_pipe to
|
|
79 generate actual input in the form of an identity eval event or
|
|
80 something. (#### maybe this actually happens?) */
|
|
81
|
|
82 if (poll_fds_for_input (non_fake_input_wait_mask))
|
|
83 return 1;
|
|
84
|
|
85 #ifndef THIS_IS_GTK
|
|
86 /* (3) Any timeout input available? */
|
|
87 if (XtAppPending (Xt_app_con) & XtIMTimer)
|
|
88 return 1;
|
|
89 #else
|
|
90 /* #### Is there any way to do this in Gtk? I don't think there
|
|
91 is a 'peek' for events */
|
|
92 #endif
|
|
93 }
|
|
94 else
|
|
95 {
|
|
96 /* HOW_MANY > 0 */
|
|
97 EVENT_CHAIN_LOOP (event, dispatch_event_queue)
|
|
98 {
|
|
99 if (command_event_p (event))
|
|
100 {
|
|
101 how_many--;
|
|
102 if (how_many <= 0)
|
|
103 return 1;
|
|
104 }
|
|
105 }
|
|
106 }
|
|
107
|
|
108 /* XtAppPending() can be super-slow, esp. over a network connection.
|
|
109 Quantify results have indicated that in some cases the call to
|
|
110 detect_input_pending() completely dominates the running time of
|
|
111 redisplay(). Fortunately, in a SIGIO world we can more quickly
|
|
112 determine whether there are any X events: if an event has happened
|
|
113 since the last time we checked, then a SIGIO will have happened. On a
|
|
114 machine with broken SIGIO, we'll still be in an OK state --
|
|
115 quit_check_signal_tick_count will get ticked at least every 1/4
|
|
116 second, so we'll be no more than that much behind reality. (In general
|
|
117 it's OK if we erroneously report no input pending when input is
|
|
118 actually pending() -- preemption is just a bit less efficient, that's
|
|
119 all. It's bad bad bad if you err the other way -- you've promised
|
|
120 that `next-event' won't block but it actually will, and some action
|
|
121 might get delayed until the next time you hit a key.)
|
|
122 */
|
|
123
|
|
124 if (!in_modal_loop)
|
|
125 {
|
|
126 /* quit_check_signal_tick_count is volatile so try to avoid race
|
|
127 conditions by using a temporary variable */
|
|
128 tick_count_val = quit_check_signal_tick_count;
|
|
129 if (last_quit_check_signal_tick_count != tick_count_val
|
|
130 #if !defined (THIS_IS_GTK) && (!defined (SIGIO) || defined (CYGWIN))
|
|
131 || (XtIMXEvent & XtAppPending (Xt_app_con))
|
|
132 #endif
|
|
133 )
|
|
134 {
|
|
135 last_quit_check_signal_tick_count = tick_count_val;
|
|
136
|
|
137 /* We need to drain the entire queue now -- if we only drain part of
|
|
138 it, we may later on end up with events actually pending but
|
|
139 detect_input_pending() returning false because there wasn't
|
|
140 another SIGIO. */
|
|
141 event_stream_drain_queue ();
|
|
142
|
|
143 if (!how_many)
|
|
144 return !NILP (dispatch_event_queue);
|
|
145
|
|
146 EVENT_CHAIN_LOOP (event, dispatch_event_queue)
|
|
147 {
|
|
148 if (command_event_p (event))
|
|
149 {
|
|
150 how_many--;
|
|
151 if (how_many <= 0)
|
|
152 return 1;
|
|
153 }
|
|
154 }
|
|
155
|
|
156 return 0;
|
|
157 }
|
|
158 }
|
|
159
|
|
160 return 0;
|
|
161 }
|
2828
|
162
|
|
163 #if defined(THIS_IS_X) || !defined(__GDK_KEYS_H__)
|
|
164
|
|
165 /* Use an appropriate map to Unicode within x_keysym_to_character. Arguments
|
|
166 are evaluated multiple times.
|
|
167
|
|
168 Breaks if an X11 keysym maps to zero in Unicode. */
|
|
169
|
|
170 #define USE_UNICODE_MAP(keysym, map) \
|
|
171 if (keysym >= FIRST_KNOWN_##map \
|
|
172 && (keysym < (FIRST_KNOWN_##map + countof(map))) \
|
|
173 && map[keysym - FIRST_KNOWN_##map ]) do \
|
|
174 { \
|
|
175 keysym -= FIRST_KNOWN_##map ; \
|
|
176 return Funicode_to_char(make_int(map[keysym]), Qnil); \
|
|
177 } while (0)
|
|
178
|
|
179 /* Maps to Unicode for X11 KeySyms, where we don't have a direct internal
|
|
180 mapping based on a Mule character set, or whatever. Taken from Markus
|
|
181 Kuhn's X11.keysyms--if you're ever comparing with that file, note the
|
|
182 sequences of KeySyms often leave out entries, so you'll have to fill them
|
|
183 in. Doesn't include support for Hangul, which it should, if the X11
|
|
184 Hangul keysyms have ever been used anywhere.
|
|
185
|
|
186 I'm not #ifdef'ing this based on wheter MULE is defined, because it's a
|
|
187 matter of 324 bytes in a stripped executable, and I want the
|
|
188 testing. :-P */
|
|
189
|
|
190 static UINT_16_BIT const TECHNICAL[] =
|
|
191 {
|
|
192 0x23B7, /* #x08A1 LEFT RADICAL Technical */
|
|
193
|
|
194 #define FIRST_KNOWN_TECHNICAL 0x8A1
|
|
195
|
|
196 0x0, /* #x08A2 TOP LEFT RADICAL Technical */
|
|
197 0x0, /* #x08A3 HORIZONTAL CONNECTOR Technical */
|
|
198 0x2320, /* #x08A4 TOP INTEGRAL Technical */
|
|
199 0x2321, /* #x08A5 BOTTOM INTEGRAL Technical */
|
|
200 0x0, /* #x08A6 VERTICAL CONNECTOR Technical */
|
|
201 0x23A1, /* #x08A7 TOP LEFT SQUARE BRACKET Technical */
|
|
202 0x23A3, /* #x08A8 BOTTOM LEFT SQUARE BRACKET Technical */
|
|
203 0x23A4, /* #x08A9 TOP RIGHT SQUARE BRACKET Technical */
|
|
204 0x23A6, /* #x08AA BOTTOM RIGHT SQUARE BRACKET Technical */
|
|
205 0x239B, /* #x08AB TOP LEFT PARENTHESIS Technical */
|
|
206 0x239D, /* #x08AC BOTTOM LEFT PARENTHESIS Technical */
|
|
207 0x239E, /* #x08AD TOP RIGHT PARENTHESIS Technical */
|
|
208 0x23A0, /* #x08AE BOTTOM RIGHT PARENTHESIS Technical */
|
|
209 0x23A8, /* #x08AF LEFT MIDDLE CURLY BRACE Technical */
|
|
210 0x23AC, /* #x08B0 RIGHT MIDDLE CURLY BRACE Technical */
|
|
211 0x0, /* #x08B1 TOP LEFT SUMMATION Technical */
|
|
212 0x0, /* #x08B2 BOTTOM LEFT SUMMATION Technical */
|
|
213 0x0, /* #x08B3 TOP VERTICAL SUMMATION CONNECTOR Technical */
|
|
214 0x0, /* #x08B4 BOTTOM VERTICAL SUMMATION CONNECTOR Technical */
|
|
215 0x0, /* #x08B5 TOP RIGHT SUMMATION Technical */
|
|
216 0x0, /* #x08B6 BOTTOM RIGHT SUMMATION Technical */
|
|
217 0x0, /* #x08B7 RIGHT MIDDLE SUMMATION Technical */
|
|
218 0x0, /* #x08B8 */
|
|
219 0x0, /* #x08B9 */
|
|
220 0x0, /* #x08BA */
|
|
221 0x0, /* #x08BB */
|
|
222 0x2264, /* #x08BC LESS THAN OR EQUAL SIGN Technical */
|
|
223 0x2260, /* #x08BD NOT EQUAL SIGN Technical */
|
|
224 0x2265, /* #x08BE GREATER THAN OR EQUAL SIGN Technical */
|
|
225 0x222B, /* #x08BF INTEGRAL Technical */
|
|
226 0x2234, /* #x08C0 THEREFORE Technical */
|
|
227 0x221D, /* #x08C1 VARIATION, PROPORTIONAL TO Technical */
|
|
228 0x221E, /* #x08C2 INFINITY Technical */
|
|
229 0x0, /* #x08C3 */
|
|
230 0x0, /* #x08C4 */
|
|
231 0x2207, /* #x08C5 NABLA, DEL Technical */
|
|
232 0x0, /* #x08C6 */
|
|
233 0x0, /* #x08C7 */
|
|
234 0x223C, /* #x08C8 IS APPROXIMATE TO Technical */
|
|
235 0x2243, /* #x08C9 SIMILAR OR EQUAL TO Technical */
|
|
236 0x0, /* #x08CA */
|
|
237 0x0, /* #x08CB */
|
|
238 0x0, /* #x08CC */
|
|
239 0x21D4, /* #x08CD IF AND ONLY IF Technical */
|
|
240 0x21D2, /* #x08CE IMPLIES Technical */
|
|
241 0x2261, /* #x08CF IDENTICAL TO Technical */
|
|
242 0x0, /* #x08D0 */
|
|
243 0x0, /* #x08D1 */
|
|
244 0x0, /* #x08D2 */
|
|
245 0x0, /* #x08D3 */
|
|
246 0x0, /* #x08D4 */
|
|
247 0x0, /* #x08D5 */
|
|
248 0x221A, /* #x08D6 RADICAL Technical */
|
|
249 0x0, /* #x08D7 */
|
|
250 0x0, /* #x08D8 */
|
|
251 0x0, /* #x08D9 */
|
|
252 0x2282, /* #x08DA IS INCLUDED IN Technical */
|
|
253 0x2283, /* #x08DB INCLUDES Technical */
|
|
254 0x2229, /* #x08DC INTERSECTION Technical */
|
|
255 0x222A, /* #x08DD UNION Technical */
|
|
256 0x2227, /* #x08DE LOGICAL AND Technical */
|
|
257 0x2228, /* #x08DF LOGICAL OR Technical */
|
|
258 0x0, /* #x08E0 */
|
|
259 0x0, /* #x08E1 */
|
|
260 0x0, /* #x08E2 */
|
|
261 0x0, /* #x08E3 */
|
|
262 0x0, /* #x08E4 */
|
|
263 0x0, /* #x08E5 */
|
|
264 0x0, /* #x08E6 */
|
|
265 0x0, /* #x08E7 */
|
|
266 0x0, /* #x08E8 */
|
|
267 0x0, /* #x08E9 */
|
|
268 0x0, /* #x08Ea */
|
|
269 0x0, /* #x08Eb */
|
|
270 0x0, /* #x08Ec */
|
|
271 0x0, /* #x08Ed */
|
|
272 0x0, /* #x08Ee */
|
|
273 0x2202, /* #x08EF PARTIAL DERIVATIVE Technical */
|
|
274 0x0, /* #x08F0 */
|
|
275 0x0, /* #x08F1 */
|
|
276 0x0, /* #x08F2 */
|
|
277 0x0, /* #x08F3 */
|
|
278 0x0, /* #x08F4 */
|
|
279 0x0, /* #x08F5 */
|
|
280 0x0192, /* #x08F6 FUNCTION Technical */
|
|
281 0x0, /* #x08F7 */
|
|
282 0x0, /* #x08F8 */
|
|
283 0x0, /* #x08F9 */
|
|
284 0x0, /* #x08FA */
|
|
285 0x2190, /* #x08FB LEFT ARROW Technical */
|
|
286 0x2191, /* #x08FC UPWARD ARROW Technical */
|
|
287 0x2192, /* #x08FD RIGHT ARROW Technical */
|
|
288 0x2193, /* #x08FE DOWNWARD ARROW Technical */
|
|
289 };
|
|
290
|
|
291 static UINT_16_BIT const SPECIAL[] =
|
|
292 {
|
|
293 0x25C6, /* #x09E0 SOLID DIAMOND Special */
|
|
294
|
|
295 #define FIRST_KNOWN_SPECIAL 0x9E0
|
|
296
|
|
297 0x2592, /* #x09E1 CHECKERBOARD Special */
|
|
298 0x2409, /* #x09E2 ``HT'' Special */
|
|
299 0x240C, /* #x09E3 ``FF'' Special */
|
|
300 0x240D, /* #x09E4 ``CR'' Special */
|
|
301 0x240A, /* #x09E5 ``LF'' Special */
|
|
302 0x0, /* #x09E6 */
|
|
303 0x0, /* #x09E7 */
|
|
304 0x2424, /* #x09E8 ``NL'' Special */
|
|
305 0x240B, /* #x09E9 ``VT'' Special */
|
|
306 0x2518, /* #x09EA LOWER-RIGHT CORNER Special */
|
|
307 0x2510, /* #x09EB UPPER-RIGHT CORNER Special */
|
|
308 0x250C, /* #x09EC UPPER-LEFT CORNER Special */
|
|
309 0x2514, /* #x09ED LOWER-LEFT CORNER Special */
|
|
310 0x253C, /* #x09EE CROSSING-LINES Special */
|
|
311 0x23BA, /* #x09EF HORIZONTAL LINE, SCAN 1 Special */
|
|
312 0x23BB, /* #x09F0 HORIZONTAL LINE, SCAN 3 Special */
|
|
313 0x2500, /* #x09F1 HORIZONTAL LINE, SCAN 5 Special */
|
|
314 0x23BC, /* #x09F2 HORIZONTAL LINE, SCAN 7 Special */
|
|
315 0x23BD, /* #x09F3 HORIZONTAL LINE, SCAN 9 Special */
|
|
316 0x251C, /* #x09F4 LEFT ``T'' Special */
|
|
317 0x2524, /* #x09F5 RIGHT ``T'' Special */
|
|
318 0x2534, /* #x09F6 BOTTOM ``T'' Special */
|
|
319 0x252C, /* #x09F7 TOP ``T'' Special */
|
|
320 0x2502 /* #x09F8 VERTICAL BAR Special */
|
|
321 };
|
|
322
|
|
323 static UINT_16_BIT const PUBLISHING[] =
|
|
324 {
|
|
325 0x2003, /* #x0AA1 EM SPACE Publish */
|
|
326
|
|
327 #define FIRST_KNOWN_PUBLISHING 0xAA1
|
|
328
|
|
329 0x2002, /* #x0AA2 EN SPACE Publish */
|
|
330 0x2004, /* #x0AA3 3/EM SPACE Publish */
|
|
331 0x2005, /* #x0AA4 4/EM SPACE Publish */
|
|
332 0x2007, /* #x0AA5 DIGIT SPACE Publish */
|
|
333 0x2008, /* #x0AA6 PUNCTUATION SPACE Publish */
|
|
334 0x2009, /* #x0AA7 THIN SPACE Publish */
|
|
335 0x200A, /* #x0AA8 HAIR SPACE Publish */
|
|
336 0x2014, /* #x0AA9 EM DASH Publish */
|
|
337 0x2013, /* #x0AAA EN DASH Publish */
|
|
338 0x0, /* #x0AAB */
|
|
339 0x0, /* #x0AAC SIGNIFICANT BLANK SYMBOL Publish */
|
|
340 0x0, /* #x0AAD */
|
|
341 0x2026, /* #x0AAE ELLIPSIS Publish */
|
|
342 0x2025, /* #x0AAF DOUBLE BASELINE DOT Publish */
|
|
343 0x2153, /* #x0AB0 VULGAR FRACTION ONE THIRD Publish */
|
|
344 0x2154, /* #x0AB1 VULGAR FRACTION TWO THIRDS Publish */
|
|
345 0x2155, /* #x0AB2 VULGAR FRACTION ONE FIFTH Publish */
|
|
346 0x2156, /* #x0AB3 VULGAR FRACTION TWO FIFTHS Publish */
|
|
347 0x2157, /* #x0AB4 VULGAR FRACTION THREE FIFTHS Publish */
|
|
348 0x2158, /* #x0AB5 VULGAR FRACTION FOUR FIFTHS Publish */
|
|
349 0x2159, /* #x0AB6 VULGAR FRACTION ONE SIXTH Publish */
|
|
350 0x215A, /* #x0AB7 VULGAR FRACTION FIVE SIXTHS Publish */
|
|
351 0x2105, /* #x0AB8 CARE OF Publish */
|
|
352 0x0, /* #x0AB9 */
|
|
353 0x0, /* #x0ABA */
|
|
354 0x2012, /* #x0ABB FIGURE DASH Publish */
|
3458
|
355 0x3008, /* #x0ABC LEFT ANGLE BRACKET Publish */
|
|
356 0x002E, /* #x0ABD DECIMAL POINT Publish */
|
|
357 0x3009, /* #x0ABE RIGHT ANGLE BRACKET Publish */
|
2828
|
358 0x0, /* #x0ABF MARKER Publish */
|
|
359 0x0, /* #x0AC0 */
|
|
360 0x0, /* #x0AC1 */
|
|
361 0x0, /* #x0AC2 */
|
|
362 0x215B, /* #x0AC3 VULGAR FRACTION ONE EIGHTH Publish */
|
|
363 0x215C, /* #x0AC4 VULGAR FRACTION THREE EIGHTHS Publish */
|
|
364 0x215D, /* #x0AC5 VULGAR FRACTION FIVE EIGHTHS Publish */
|
|
365 0x215E, /* #x0AC6 VULGAR FRACTION SEVEN EIGHTHS Publish */
|
|
366 0x0, /* #x0AC7 */
|
|
367 0x0, /* #x0AC8 */
|
|
368 0x2122, /* #x0AC9 TRADEMARK SIGN Publish */
|
|
369 0x0, /* #x0ACA SIGNATURE MARK Publish */
|
|
370 0x0, /* #x0ACB TRADEMARK SIGN IN CIRCLE Publish */
|
|
371 0x0, /* #x0ACC LEFT OPEN TRIANGLE Publish */
|
|
372 0x0, /* #x0ACD RIGHT OPEN TRIANGLE Publish */
|
|
373 0x0, /* #x0ACE EM OPEN CIRCLE Publish */
|
|
374 0x0, /* #x0ACF EM OPEN RECTANGLE Publish */
|
|
375 0x2018, /* #x0AD0 LEFT SINGLE QUOTATION MARK Publish */
|
|
376 0x2019, /* #x0AD1 RIGHT SINGLE QUOTATION MARK Publish */
|
|
377 0x201C, /* #x0AD2 LEFT DOUBLE QUOTATION MARK Publish */
|
|
378 0x201D, /* #x0AD3 RIGHT DOUBLE QUOTATION MARK Publish */
|
|
379 0x211E, /* #x0AD4 PRESCRIPTION, TAKE, RECIPE Publish */
|
|
380 0x0, /* #x0AD5 */
|
|
381 0x2032, /* #x0AD6 MINUTES Publish */
|
|
382 0x2033, /* #x0AD7 SECONDS Publish */
|
|
383 0x0, /* #x0AD8 */
|
|
384 0x271D, /* #x0AD9 LATIN CROSS Publish */
|
|
385 0x0, /* #x0ADA HEXAGRAM Publish */
|
|
386 0x0, /* #x0ADB FILLED RECTANGLE BULLET Publish */
|
|
387 0x0, /* #x0ADC FILLED LEFT TRIANGLE BULLET Publish */
|
|
388 0x0, /* #x0ADD FILLED RIGHT TRIANGLE BULLET Publish */
|
|
389 0x0, /* #x0ADE EM FILLED CIRCLE Publish */
|
|
390 0x0, /* #x0ADF EM FILLED RECTANGLE Publish */
|
|
391 0x0, /* #x0AE0 EN OPEN CIRCLE BULLET Publish */
|
|
392 0x0, /* #x0AE1 EN OPEN SQUARE BULLET Publish */
|
|
393 0x0, /* #x0AE2 OPEN RECTANGULAR BULLET Publish */
|
|
394 0x0, /* #x0AE3 OPEN TRIANGULAR BULLET UP Publish */
|
|
395 0x0, /* #x0AE4 OPEN TRIANGULAR BULLET DOWN Publish */
|
|
396 0x0, /* #x0AE5 OPEN STAR Publish */
|
|
397 0x0, /* #x0AE6 EN FILLED CIRCLE BULLET Publish */
|
|
398 0x0, /* #x0AE7 EN FILLED SQUARE BULLET Publish */
|
|
399 0x0, /* #x0AE8 FILLED TRIANGULAR BULLET UP Publish */
|
|
400 0x0, /* #x0AE9 FILLED TRIANGULAR BULLET DOWN Publish */
|
|
401 0x0, /* #x0AEA LEFT POINTER Publish */
|
|
402 0x0, /* #x0AEB RIGHT POINTER Publish */
|
|
403 0x2663, /* #x0AEC CLUB Publish */
|
|
404 0x2666, /* #x0AED DIAMOND Publish */
|
|
405 0x2665, /* #x0AEE HEART Publish */
|
|
406 0x0, /* #x0AEF */
|
|
407 0x2720, /* #x0AF0 MALTESE CROSS Publish */
|
|
408 0x2020, /* #x0AF1 DAGGER Publish */
|
|
409 0x2021, /* #x0AF2 DOUBLE DAGGER Publish */
|
|
410 0x2713, /* #x0AF3 CHECK MARK, TICK Publish */
|
|
411 0x2717, /* #x0AF4 BALLOT CROSS Publish */
|
|
412 0x266F, /* #x0AF5 MUSICAL SHARP Publish */
|
|
413 0x266D, /* #x0AF6 MUSICAL FLAT Publish */
|
|
414 0x2642, /* #x0AF7 MALE SYMBOL Publish */
|
|
415 0x2640, /* #x0AF8 FEMALE SYMBOL Publish */
|
|
416 0x260E, /* #x0AF9 TELEPHONE SYMBOL Publish */
|
|
417 0x2315, /* #x0AFA TELEPHONE RECORDER SYMBOL Publish */
|
|
418 0x2117, /* #x0AFB PHONOGRAPH COPYRIGHT SIGN Publish */
|
|
419 0x2038, /* #x0AFC CARET Publish */
|
|
420 0x201A, /* #x0AFD SINGLE LOW QUOTATION MARK Publish */
|
|
421 0x201E, /* #x0AFE DOUBLE LOW QUOTATION MARK Publish */
|
|
422 };
|
|
423
|
|
424 static UINT_16_BIT const APL[] =
|
|
425 {
|
|
426 0x22A5, /* #x0BC2 DOWN TACK APL */
|
|
427 #define FIRST_KNOWN_APL 0xBC2
|
|
428 0x0, /* #x0BC3 UP SHOE (CAP) APL */
|
|
429 0x230A, /* #x0BC4 DOWN STILE APL */
|
|
430 0x0, /* #x0BC5 */
|
|
431 0x0, /* #x0BC6 UNDERBAR APL */
|
|
432 0x0, /* #x0BC7 */
|
|
433 0x0, /* #x0BC8 */
|
|
434 0x0, /* #x0BC9 */
|
|
435 0x2218, /* #x0BCA JOT APL */
|
|
436 0x0, /* #x0BCB */
|
|
437 0x2395, /* #x0BCC QUAD APL */
|
|
438 0x0, /* #x0BCD */
|
|
439 0x22A4, /* #x0BCE UP TACK APL */
|
|
440 0x25CB, /* #x0BCF CIRCLE APL */
|
|
441 0x0, /* #x0BD0 */
|
|
442 0x0, /* #x0BD1 */
|
|
443 0x0, /* #x0BD2 */
|
|
444 0x2308, /* #x0BD3 UP STILE APL */
|
|
445 0x0, /* #x0BD4 */
|
|
446 0x0, /* #x0BD5 */
|
|
447 0x0, /* #x0BD6 DOWN SHOE (CUP) APL */
|
|
448 0x0, /* #x0BD7 */
|
|
449 0x0, /* #x0BD8 RIGHT SHOE APL */
|
|
450 0x0, /* #x0BD9 */
|
|
451 0x0, /* #x0BDA LEFT SHOE APL */
|
|
452 0x0, /* #x0BDB */
|
|
453 0x0, /* #x0BDC */
|
|
454 0x22A2, /* #x0BDC LEFT TACK APL */
|
|
455 0x0, /* #x0BDE */
|
|
456 0x0, /* #x0BDF */
|
|
457 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, /* 0x0BB0--0x0BBB */
|
|
458 0x0, 0x0, 0x0, 0x0,
|
|
459 0x22A3, /* #x0BFC RIGHT TACK APL */
|
|
460 };
|
|
461
|
|
462 /* For every key on the keyboard that has a known character correspondence,
|
|
463 we define the character-of-keysym property of its XEmacs keysym, and make
|
|
464 the default binding for the key be self-insert-command.
|
|
465
|
|
466 The following magic is based on intimate knowledge of some of
|
|
467 X11/keysymdef.h. The keysym mappings defined by X11 are based on the
|
|
468 iso8859 standards, except for Cyrillic and Greek.
|
|
469
|
|
470 In a non-Mule world, a user can still have a multi-lingual editor, by
|
|
471 doing (set-face-font "...-iso8859-2" (current-buffer)) for all their
|
|
472 Latin-2 buffers, etc. and the X11 keysyms corresponding to characters in
|
|
473 those character sets will still do the right thing (because of the
|
|
474 make_char (code + 0x80) non-Mule case below.) Of course, X11 keysyms in
|
|
475 other character sets will not do the right thing, because XEmacs won't
|
|
476 support the right thing.
|
|
477
|
|
478 This code is also called when a command lookup is about to fail, and the
|
|
479 X11 platform code has worked out that it previously wasn't aware the
|
|
480 keysym of that command could be generated by the user's keyboard; in that
|
|
481 case, we bind its XEmacs keysym to self-insert-command if it has a
|
|
482 character correspondence we know about, and tell the general event code
|
|
483 that we've done so, so it can try the lookup again.
|
|
484
|
|
485 Called from the GTK code because GTK 1 has no defined way of doing the
|
|
486 same thing, and this works for it on X11. It should be moved back into
|
|
487 event-Xt.c when and if the GTK port moves to GTK 2. */
|
|
488
|
|
489 #ifndef THIS_IS_GTK
|
|
490 static Lisp_Object
|
|
491 x_keysym_to_character(KeySym keysym)
|
|
492 #else
|
|
493 Lisp_Object
|
|
494 gtk_keysym_to_character(guint keysym)
|
|
495 #endif
|
|
496 {
|
|
497 Lisp_Object charset = Qzero;
|
|
498 int code = 0;
|
|
499
|
|
500 /* Markus Kuhn's spec says keysyms in the range #x01000100 to #x0110FFFF
|
|
501 and only those should correspond directly to Unicode code points, in
|
|
502 the range #x100-#x10FFFF; actual implementations can have the Latin 1
|
|
503 code points do the same thing with keysyms
|
3439
|
504 #x01000000-#x01000100. */
|
2828
|
505
|
3439
|
506 if (keysym >= 0x01000000 && keysym <= 0x0110FFFF)
|
2828
|
507 return Funicode_to_char (make_int(keysym & 0xffffff), Qnil);
|
|
508
|
|
509 if ((keysym & 0xff) < 0xa0)
|
|
510 return Qnil;
|
|
511
|
|
512 switch (keysym >> 8)
|
|
513 {
|
|
514
|
|
515 #define USE_CHARSET(var,cs) \
|
|
516 ((var) = charset_by_leading_byte (LEADING_BYTE_##cs))
|
|
517
|
|
518 case 0: /* ASCII + Latin1 */
|
|
519 USE_CHARSET (charset, LATIN_ISO8859_1);
|
|
520 code = keysym & 0x7f;
|
|
521 break;
|
|
522 case 1: /* Latin2 */
|
|
523 USE_CHARSET (charset, LATIN_ISO8859_2);
|
|
524 code = keysym & 0x7f;
|
|
525 break;
|
|
526 case 2: /* Latin3 */
|
|
527 USE_CHARSET (charset, LATIN_ISO8859_3);
|
|
528 code = keysym & 0x7f;
|
|
529 break;
|
|
530 case 3: /* Latin4 */
|
|
531 USE_CHARSET (charset, LATIN_ISO8859_4);
|
|
532 code = keysym & 0x7f;
|
|
533 break;
|
|
534 case 4: /* Katakana */
|
|
535 USE_CHARSET (charset, KATAKANA_JISX0201);
|
|
536 if ((keysym & 0xff) > 0xa0)
|
|
537 code = keysym & 0x7f;
|
|
538 break;
|
|
539 case 5: /* Arabic */
|
|
540 USE_CHARSET (charset, ARABIC_ISO8859_6);
|
|
541 code = keysym & 0x7f;
|
|
542 break;
|
|
543 case 6: /* Cyrillic */
|
|
544 {
|
|
545 static UExtbyte const cyrillic[] = /* 0x20 - 0x7f */
|
|
546 {0x00, 0x72, 0x73, 0x71, 0x74, 0x75, 0x76, 0x77,
|
|
547 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x00, 0x7e, 0x7f,
|
|
548 0x70, 0x22, 0x23, 0x21, 0x24, 0x25, 0x26, 0x27,
|
|
549 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x00, 0x2e, 0x2f,
|
|
550 0x6e, 0x50, 0x51, 0x66, 0x54, 0x55, 0x64, 0x53,
|
|
551 0x65, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e,
|
|
552 0x5f, 0x6f, 0x60, 0x61, 0x62, 0x63, 0x56, 0x52,
|
|
553 0x6c, 0x6b, 0x57, 0x68, 0x6d, 0x69, 0x67, 0x6a,
|
|
554 0x4e, 0x30, 0x31, 0x46, 0x34, 0x35, 0x44, 0x33,
|
|
555 0x45, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
|
|
556 0x3f, 0x4f, 0x40, 0x41, 0x42, 0x43, 0x36, 0x32,
|
|
557 0x4c, 0x4b, 0x37, 0x48, 0x4d, 0x49, 0x47, 0x4a};
|
|
558 USE_CHARSET (charset, CYRILLIC_ISO8859_5);
|
|
559 code = cyrillic[(keysym & 0x7f) - 0x20];
|
|
560 break;
|
|
561 }
|
|
562 case 7: /* Greek */
|
|
563 {
|
|
564 static UExtbyte const greek[] = /* 0x20 - 0x7f */
|
|
565 {0x00, 0x36, 0x38, 0x39, 0x3a, 0x5a, 0x00, 0x3c,
|
|
566 0x3e, 0x5b, 0x00, 0x3f, 0x00, 0x00, 0x35, 0x2f,
|
|
567 0x00, 0x5c, 0x5d, 0x5e, 0x5f, 0x7a, 0x40, 0x7c,
|
|
568 0x7d, 0x7b, 0x60, 0x7e, 0x00, 0x00, 0x00, 0x00,
|
|
569 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
|
570 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
|
571 0x50, 0x51, 0x53, 0x00, 0x54, 0x55, 0x56, 0x57,
|
|
572 0x58, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
573 0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
|
574 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
|
575 0x70, 0x71, 0x73, 0x72, 0x74, 0x75, 0x76, 0x77,
|
|
576 0x78, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
577 USE_CHARSET (charset, GREEK_ISO8859_7);
|
|
578 code = greek[(keysym & 0x7f) - 0x20];
|
|
579 break;
|
|
580 }
|
|
581 case 8:
|
|
582 USE_UNICODE_MAP(keysym, TECHNICAL);
|
|
583 break;
|
|
584 case 9:
|
|
585 USE_UNICODE_MAP(keysym, SPECIAL);
|
|
586 break;
|
|
587 case 10:
|
|
588 USE_UNICODE_MAP(keysym, PUBLISHING);
|
|
589 break;
|
|
590 case 11:
|
|
591 USE_UNICODE_MAP(keysym, APL);
|
|
592 break;
|
|
593 case 12: /* Hebrew */
|
|
594 USE_CHARSET (charset, HEBREW_ISO8859_8);
|
|
595 code = keysym & 0x7f;
|
|
596 break;
|
|
597 case 13: /* Thai */
|
|
598 /* #### This needs to deal with character composition.
|
|
599 Are you sure we can't leave it to the X server? */
|
|
600 USE_CHARSET (charset, THAI_TIS620);
|
|
601 code = keysym & 0x7f;
|
|
602 break;
|
|
603 case 14: /* Korean Hangul. Would like some information on whether this
|
|
604 is worth doing--there don't appear to be any Korean keyboard
|
|
605 layouts in the XKB data files. */
|
|
606 break;
|
|
607
|
|
608 case 19: /* Latin 9 - ISO8859-15. */
|
|
609 USE_CHARSET (charset, LATIN_ISO8859_15);
|
|
610 code = keysym & 0x7f;
|
|
611 break;
|
|
612 case 32: /* Currency. The lower sixteen bits of these keysyms happily
|
|
613 correspond exactly to the Unicode code points of the
|
|
614 associated characters */
|
|
615 return Funicode_to_char(make_int(keysym & 0xffff), Qnil);
|
|
616 break;
|
|
617 default:
|
|
618 break;
|
|
619 }
|
|
620
|
|
621 if (code == 0)
|
|
622 return Qnil;
|
|
623
|
|
624 #ifdef MULE
|
|
625 return make_char (make_ichar (charset, code, 0));
|
|
626 #else
|
|
627 return make_char (code + 0x80);
|
|
628 #endif
|
|
629 }
|
|
630
|
|
631 #endif /* defined(THIS_IS_X) || !defined(__GDK_KEYS_H__) */
|