Mercurial > hg > xemacs-beta
comparison src/console-x.c @ 2828:a25c824ed558
[xemacs-hg @ 2005-06-26 18:04:49 by aidan]
Rename the ascii-character property, support more keysyms.
author | aidan |
---|---|
date | Sun, 26 Jun 2005 18:05:05 +0000 |
parents | 04bc9d2f42c7 |
children | c1ec282bb160 |
comparison
equal
deleted
inserted
replaced
2827:936a6576c655 | 2828:a25c824ed558 |
---|---|
29 | 29 |
30 #include <config.h> | 30 #include <config.h> |
31 #include "lisp.h" | 31 #include "lisp.h" |
32 | 32 |
33 #include "buffer.h" | 33 #include "buffer.h" |
34 #include "device.h" | |
35 #include "elhash.h" | |
34 #include "process.h" /* canonicalize_host_name */ | 36 #include "process.h" /* canonicalize_host_name */ |
35 #include "redisplay.h" /* for display_arg */ | 37 #include "redisplay.h" /* for display_arg */ |
36 | 38 |
39 #include "device-impl.h" | |
37 #include "console-x-impl.h" | 40 #include "console-x-impl.h" |
38 | 41 |
39 DEFINE_CONSOLE_TYPE (x); | 42 DEFINE_CONSOLE_TYPE (x); |
43 | |
44 extern void x_has_keysym (KeySym, Lisp_Object, int); | |
40 | 45 |
41 static int | 46 static int |
42 x_initially_selected_for_input (struct console *UNUSED (con)) | 47 x_initially_selected_for_input (struct console *UNUSED (con)) |
43 { | 48 { |
44 return 1; | 49 return 1; |
294 connection = x_canonicalize_console_connection (connection, errb); | 299 connection = x_canonicalize_console_connection (connection, errb); |
295 | 300 |
296 RETURN_UNGCPRO (concat2 (connection, screen_str)); | 301 RETURN_UNGCPRO (concat2 (connection, screen_str)); |
297 } | 302 } |
298 | 303 |
304 /* Given a key, if it maps to a character and we weren't previously aware | |
305 that it could be generated on console CON, and if it's unbound in the | |
306 global map, bind it to self-insert-command. Return Qt if the binding was | |
307 done; Qnil if not. */ | |
308 | |
309 static Lisp_Object | |
310 x_perhaps_init_unseen_key_defaults (struct console *con, Lisp_Object key) | |
311 { | |
312 KeySym xkeysym; | |
313 const Extbyte *keysym_ext; | |
314 Lisp_Object key_name, previous_binding = Qnil; | |
315 extern Lisp_Object Qcharacter_of_keysym, Vcurrent_global_map; | |
316 | |
317 /* Getting the device exactly right is not horrendously important; as long | |
318 as it's an X11 device it should be okay, because the global keymap (and | |
319 whether the key is bound) _is_ global, and any previously seen keysym | |
320 will already be bound, or not, in it. However, there is a corner case | |
321 where a symbol has been typed, and then explicitly unbound; if the next | |
322 event using that symbol comes in on some other frame, it'll get bound | |
323 again. This is not realistically an issue. */ | |
324 struct device *d = XDEVICE(con->selected_device); | |
325 | |
326 if (SYMBOLP (key)) | |
327 { | |
328 key_name = symbol_name(XSYMBOL(key)); | |
329 } | |
330 else | |
331 { | |
332 Ibyte buf[MAX_ICHAR_LEN + 1]; | |
333 CHECK_CHAR(key); | |
334 | |
335 buf[set_itext_ichar(buf, XCHAR(key))] = '\0'; | |
336 key_name = build_string(buf); | |
337 | |
338 /* We need to do the lookup and compare later, because we can't check | |
339 the Qcharacter_of_keysym property belonging to an actual character. */ | |
340 previous_binding = Flookup_key (Vcurrent_global_map, key, Qnil); | |
341 } | |
342 | |
343 if (!NILP(Fgethash(key, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), Qnil))) | |
344 { | |
345 return Qnil; | |
346 } | |
347 | |
348 LISP_STRING_TO_EXTERNAL (key_name, keysym_ext, Qctext); | |
349 xkeysym = XStringToKeysym(keysym_ext); | |
350 if (NoSymbol == xkeysym) | |
351 { | |
352 return Qnil; | |
353 } | |
354 | |
355 x_has_keysym(xkeysym, DEVICE_X_KEYSYM_MAP_HASH_TABLE (d), 0); | |
356 | |
357 if (SYMBOLP(key)) | |
358 { | |
359 return NILP(Fget (key, Qcharacter_of_keysym, Qnil)) ? Qnil : Qt; | |
360 } | |
361 else | |
362 { | |
363 return EQ(previous_binding, Flookup_key(Vcurrent_global_map, key, Qnil)) | |
364 ? Qnil : Qt; | |
365 } | |
366 } | |
367 | |
299 void | 368 void |
300 console_type_create_x (void) | 369 console_type_create_x (void) |
301 { | 370 { |
302 INITIALIZE_CONSOLE_TYPE (x, "x", "console-x-p"); | 371 INITIALIZE_CONSOLE_TYPE (x, "x", "console-x-p"); |
303 | 372 |
305 CONSOLE_HAS_METHOD (x, canonicalize_console_connection); | 374 CONSOLE_HAS_METHOD (x, canonicalize_console_connection); |
306 CONSOLE_HAS_METHOD (x, semi_canonicalize_device_connection); | 375 CONSOLE_HAS_METHOD (x, semi_canonicalize_device_connection); |
307 CONSOLE_HAS_METHOD (x, canonicalize_device_connection); | 376 CONSOLE_HAS_METHOD (x, canonicalize_device_connection); |
308 CONSOLE_HAS_METHOD (x, device_to_console_connection); | 377 CONSOLE_HAS_METHOD (x, device_to_console_connection); |
309 CONSOLE_HAS_METHOD (x, initially_selected_for_input); | 378 CONSOLE_HAS_METHOD (x, initially_selected_for_input); |
379 CONSOLE_HAS_METHOD (x, perhaps_init_unseen_key_defaults); | |
310 } | 380 } |
311 | 381 |
312 | 382 |
313 void | 383 void |
314 reinit_console_type_create_x (void) | 384 reinit_console_type_create_x (void) |