Mercurial > hg > xemacs-beta
comparison src/keymap.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
35 #include "events.h" | 35 #include "events.h" |
36 #include "frame.h" | 36 #include "frame.h" |
37 #include "insdel.h" | 37 #include "insdel.h" |
38 #include "keymap.h" | 38 #include "keymap.h" |
39 #include "window.h" | 39 #include "window.h" |
40 | |
41 #ifdef WINDOWSNT | |
42 /* Hmm, under unix we want X modifiers, under NT we want X modifiers if | |
43 we are running X and Windows modifiers otherwise. | |
44 gak. This is a kludge until we support multiple native GUIs! | |
45 */ | |
46 #undef MOD_ALT | |
47 #undef MOD_CONTROL | |
48 #undef MOD_SHIFT | |
49 #endif | |
50 | |
51 #include "events-mod.h" | 40 #include "events-mod.h" |
52 | 41 |
53 | 42 |
54 /* A keymap contains six slots: | 43 /* A keymap contains six slots: |
55 | 44 |
97 off of the main map. The hash key for a modifier combination is | 86 off of the main map. The hash key for a modifier combination is |
98 an integer, computed by MAKE_MODIFIER_HASH_KEY(). | 87 an integer, computed by MAKE_MODIFIER_HASH_KEY(). |
99 | 88 |
100 If the key `C-a' was bound to some command, the hierarchy would look like | 89 If the key `C-a' was bound to some command, the hierarchy would look like |
101 | 90 |
102 keymap-1: associates the integer MOD_CONTROL with keymap-2 | 91 keymap-1: associates the integer XEMACS_MOD_CONTROL with keymap-2 |
103 keymap-2: associates "a" with the command | 92 keymap-2: associates "a" with the command |
104 | 93 |
105 Similarly, if the key `C-H-a' was bound to some command, the hierarchy | 94 Similarly, if the key `C-H-a' was bound to some command, the hierarchy |
106 would look like | 95 would look like |
107 | 96 |
108 keymap-1: associates the integer (MOD_CONTROL | MOD_HYPER) | 97 keymap-1: associates the integer (XEMACS_MOD_CONTROL | XEMACS_MOD_HYPER) |
109 with keymap-2 | 98 with keymap-2 |
110 keymap-2: associates "a" with the command | 99 keymap-2: associates "a" with the command |
111 | 100 |
112 Note that a special exception is made for the meta modifier, in order | 101 Note that a special exception is made for the meta modifier, in order |
113 to deal with ESC/meta lossage. Any key combination containing the | 102 to deal with ESC/meta lossage. Any key combination containing the |
114 meta modifier is first indexed off of the main map into the meta | 103 meta modifier is first indexed off of the main map into the meta |
115 submap (with hash key MOD_META) and then indexed off of the | 104 submap (with hash key XEMACS_MOD_META) and then indexed off of the |
116 meta submap with the meta modifier removed from the key combination. | 105 meta submap with the meta modifier removed from the key combination. |
117 For example, when associating a command with C-M-H-a, we'd have | 106 For example, when associating a command with C-M-H-a, we'd have |
118 | 107 |
119 keymap-1: associates the integer MOD_META with keymap-2 | 108 keymap-1: associates the integer XEMACS_MOD_META with keymap-2 |
120 keymap-2: associates the integer (MOD_CONTROL | MOD_HYPER) | 109 keymap-2: associates the integer (XEMACS_MOD_CONTROL | XEMACS_MOD_HYPER) |
121 with keymap-3 | 110 with keymap-3 |
122 keymap-3: associates "a" with the command | 111 keymap-3: associates "a" with the command |
123 | 112 |
124 Note that keymap-2 might have normal bindings in it; these would be | 113 Note that keymap-2 might have normal bindings in it; these would be |
125 for key combinations containing only the meta modifier, such as | 114 for key combinations containing only the meta modifier, such as |
129 then that would make the key "C-M-H-a" be a prefix character. | 118 then that would make the key "C-M-H-a" be a prefix character. |
130 | 119 |
131 Note that this new model of keymaps takes much of the magic away from | 120 Note that this new model of keymaps takes much of the magic away from |
132 the Escape key: the value of the variable `esc-map' is no longer indexed | 121 the Escape key: the value of the variable `esc-map' is no longer indexed |
133 in the `global-map' under the ESC key. It's indexed under the integer | 122 in the `global-map' under the ESC key. It's indexed under the integer |
134 MOD_META. This is not user-visible, however; none of the "bucky" | 123 XEMACS_MOD_META. This is not user-visible, however; none of the "bucky" |
135 maps are. | 124 maps are. |
136 | 125 |
137 There is a hack in Flookup_key() that makes (lookup-key global-map "\^[") | 126 There is a hack in Flookup_key() that makes (lookup-key global-map "\^[") |
138 and (define-key some-random-map "\^[" my-esc-map) work as before, for | 127 and (define-key some-random-map "\^[" my-esc-map) work as before, for |
139 compatibility. | 128 compatibility. |
404 | 393 |
405 /************************************************************************/ | 394 /************************************************************************/ |
406 /* Some low-level functions */ | 395 /* Some low-level functions */ |
407 /************************************************************************/ | 396 /************************************************************************/ |
408 | 397 |
409 static unsigned int | 398 static int |
410 bucky_sym_to_bucky_bit (Lisp_Object sym) | 399 bucky_sym_to_bucky_bit (Lisp_Object sym) |
411 { | 400 { |
412 if (EQ (sym, Qcontrol)) return MOD_CONTROL; | 401 if (EQ (sym, Qcontrol)) return XEMACS_MOD_CONTROL; |
413 if (EQ (sym, Qmeta)) return MOD_META; | 402 if (EQ (sym, Qmeta)) return XEMACS_MOD_META; |
414 if (EQ (sym, Qsuper)) return MOD_SUPER; | 403 if (EQ (sym, Qsuper)) return XEMACS_MOD_SUPER; |
415 if (EQ (sym, Qhyper)) return MOD_HYPER; | 404 if (EQ (sym, Qhyper)) return XEMACS_MOD_HYPER; |
416 if (EQ (sym, Qalt)) return MOD_ALT; | 405 if (EQ (sym, Qalt)) return XEMACS_MOD_ALT; |
417 if (EQ (sym, Qsymbol)) return MOD_ALT; /* #### - reverse compat */ | 406 if (EQ (sym, Qsymbol)) return XEMACS_MOD_ALT; /* #### - reverse compat */ |
418 if (EQ (sym, Qshift)) return MOD_SHIFT; | 407 if (EQ (sym, Qshift)) return XEMACS_MOD_SHIFT; |
419 | 408 |
420 return 0; | 409 return 0; |
421 } | 410 } |
422 | 411 |
423 static Lisp_Object | 412 static Lisp_Object |
424 control_meta_superify (Lisp_Object frob, unsigned int modifiers) | 413 control_meta_superify (Lisp_Object frob, int modifiers) |
425 { | 414 { |
426 if (modifiers == 0) | 415 if (modifiers == 0) |
427 return frob; | 416 return frob; |
428 frob = Fcons (frob, Qnil); | 417 frob = Fcons (frob, Qnil); |
429 if (modifiers & MOD_SHIFT) frob = Fcons (Qshift, frob); | 418 if (modifiers & XEMACS_MOD_SHIFT) frob = Fcons (Qshift, frob); |
430 if (modifiers & MOD_ALT) frob = Fcons (Qalt, frob); | 419 if (modifiers & XEMACS_MOD_ALT) frob = Fcons (Qalt, frob); |
431 if (modifiers & MOD_HYPER) frob = Fcons (Qhyper, frob); | 420 if (modifiers & XEMACS_MOD_HYPER) frob = Fcons (Qhyper, frob); |
432 if (modifiers & MOD_SUPER) frob = Fcons (Qsuper, frob); | 421 if (modifiers & XEMACS_MOD_SUPER) frob = Fcons (Qsuper, frob); |
433 if (modifiers & MOD_CONTROL) frob = Fcons (Qcontrol, frob); | 422 if (modifiers & XEMACS_MOD_CONTROL) frob = Fcons (Qcontrol, frob); |
434 if (modifiers & MOD_META) frob = Fcons (Qmeta, frob); | 423 if (modifiers & XEMACS_MOD_META) frob = Fcons (Qmeta, frob); |
435 return frob; | 424 return frob; |
436 } | 425 } |
437 | 426 |
438 static Lisp_Object | 427 static Lisp_Object |
439 make_key_description (CONST struct key_data *key, int prettify) | 428 make_key_description (const struct key_data *key, int prettify) |
440 { | 429 { |
441 Lisp_Object keysym = key->keysym; | 430 Lisp_Object keysym = key->keysym; |
442 unsigned int modifiers = key->modifiers; | 431 int modifiers = key->modifiers; |
443 | 432 |
444 if (prettify && CHARP (keysym)) | 433 if (prettify && CHARP (keysym)) |
445 { | 434 { |
446 /* This is a little slow, but (control a) is prettier than (control 65). | 435 /* This is a little slow, but (control a) is prettier than (control 65). |
447 It's now ok to do this for digit-chars too, since we've fixed the | 436 It's now ok to do this for digit-chars too, since we've fixed the |
462 /* Low-level keymap-store functions */ | 451 /* Low-level keymap-store functions */ |
463 /************************************************************************/ | 452 /************************************************************************/ |
464 | 453 |
465 static Lisp_Object | 454 static Lisp_Object |
466 raw_lookup_key (Lisp_Object keymap, | 455 raw_lookup_key (Lisp_Object keymap, |
467 CONST struct key_data *raw_keys, int raw_keys_count, | 456 const struct key_data *raw_keys, int raw_keys_count, |
468 int keys_so_far, int accept_default); | 457 int keys_so_far, int accept_default); |
469 | 458 |
470 /* Relies on caller to gc-protect args */ | 459 /* Relies on caller to gc-protect args */ |
471 static Lisp_Object | 460 static Lisp_Object |
472 keymap_lookup_directly (Lisp_Object keymap, | 461 keymap_lookup_directly (Lisp_Object keymap, |
473 Lisp_Object keysym, unsigned int modifiers) | 462 Lisp_Object keysym, int modifiers) |
474 { | 463 { |
475 Lisp_Keymap *k; | 464 Lisp_Keymap *k; |
476 | 465 |
477 if ((modifiers & ~(MOD_CONTROL | MOD_META | MOD_SUPER | MOD_HYPER | 466 modifiers &= ~(XEMACS_MOD_BUTTON1 | XEMACS_MOD_BUTTON2 | XEMACS_MOD_BUTTON3 |
478 | MOD_ALT | MOD_SHIFT)) != 0) | 467 | XEMACS_MOD_BUTTON4 | XEMACS_MOD_BUTTON5); |
468 if ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER | |
469 | XEMACS_MOD_HYPER | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT)) | |
470 != 0) | |
479 abort (); | 471 abort (); |
480 | 472 |
481 k = XKEYMAP (keymap); | 473 k = XKEYMAP (keymap); |
482 | 474 |
483 /* If the keysym is a one-character symbol, use the char code instead. */ | 475 /* If the keysym is a one-character symbol, use the char code instead. */ |
486 Lisp_Object i_fart_on_gcc = | 478 Lisp_Object i_fart_on_gcc = |
487 make_char (string_char (XSYMBOL (keysym)->name, 0)); | 479 make_char (string_char (XSYMBOL (keysym)->name, 0)); |
488 keysym = i_fart_on_gcc; | 480 keysym = i_fart_on_gcc; |
489 } | 481 } |
490 | 482 |
491 if (modifiers & MOD_META) /* Utterly hateful ESC lossage */ | 483 if (modifiers & XEMACS_MOD_META) /* Utterly hateful ESC lossage */ |
492 { | 484 { |
493 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), | 485 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (XEMACS_MOD_META), |
494 k->table, Qnil); | 486 k->table, Qnil); |
495 if (NILP (submap)) | 487 if (NILP (submap)) |
496 return Qnil; | 488 return Qnil; |
497 k = XKEYMAP (submap); | 489 k = XKEYMAP (submap); |
498 modifiers &= ~MOD_META; | 490 modifiers &= ~XEMACS_MOD_META; |
499 } | 491 } |
500 | 492 |
501 if (modifiers != 0) | 493 if (modifiers != 0) |
502 { | 494 { |
503 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (modifiers), | 495 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (modifiers), |
627 keymap_tick++; | 619 keymap_tick++; |
628 } | 620 } |
629 | 621 |
630 | 622 |
631 static Lisp_Object | 623 static Lisp_Object |
632 create_bucky_submap (Lisp_Keymap *k, unsigned int modifiers, | 624 create_bucky_submap (Lisp_Keymap *k, int modifiers, |
633 Lisp_Object parent_for_debugging_info) | 625 Lisp_Object parent_for_debugging_info) |
634 { | 626 { |
635 Lisp_Object submap = Fmake_sparse_keymap (Qnil); | 627 Lisp_Object submap = Fmake_sparse_keymap (Qnil); |
636 /* User won't see this, but it is nice for debugging Emacs */ | 628 /* User won't see this, but it is nice for debugging Emacs */ |
637 XKEYMAP (submap)->name | 629 XKEYMAP (submap)->name |
643 } | 635 } |
644 | 636 |
645 | 637 |
646 /* Relies on caller to gc-protect keymap, keysym, value */ | 638 /* Relies on caller to gc-protect keymap, keysym, value */ |
647 static void | 639 static void |
648 keymap_store (Lisp_Object keymap, CONST struct key_data *key, | 640 keymap_store (Lisp_Object keymap, const struct key_data *key, |
649 Lisp_Object value) | 641 Lisp_Object value) |
650 { | 642 { |
651 Lisp_Object keysym = key->keysym; | 643 Lisp_Object keysym = key->keysym; |
652 unsigned int modifiers = key->modifiers; | 644 int modifiers = key->modifiers; |
653 Lisp_Keymap *k = XKEYMAP (keymap); | 645 Lisp_Keymap *k = XKEYMAP (keymap); |
654 | 646 |
655 assert ((modifiers & ~(MOD_CONTROL | MOD_META | MOD_SUPER | MOD_HYPER | 647 modifiers &= ~(XEMACS_MOD_BUTTON1 | XEMACS_MOD_BUTTON2 | XEMACS_MOD_BUTTON3 |
656 | MOD_ALT | MOD_SHIFT)) == 0); | 648 | XEMACS_MOD_BUTTON4 | XEMACS_MOD_BUTTON5); |
649 assert ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META | |
650 | XEMACS_MOD_SUPER | XEMACS_MOD_HYPER | |
651 | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT)) == 0); | |
657 | 652 |
658 /* If the keysym is a one-character symbol, use the char code instead. */ | 653 /* If the keysym is a one-character symbol, use the char code instead. */ |
659 if (SYMBOLP (keysym) && string_char_length (XSYMBOL (keysym)->name) == 1) | 654 if (SYMBOLP (keysym) && string_char_length (XSYMBOL (keysym)->name) == 1) |
660 keysym = make_char (string_char (XSYMBOL (keysym)->name, 0)); | 655 keysym = make_char (string_char (XSYMBOL (keysym)->name, 0)); |
661 | 656 |
662 if (modifiers & MOD_META) /* Utterly hateful ESC lossage */ | 657 if (modifiers & XEMACS_MOD_META) /* Utterly hateful ESC lossage */ |
663 { | 658 { |
664 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), | 659 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (XEMACS_MOD_META), |
665 k->table, Qnil); | 660 k->table, Qnil); |
666 if (NILP (submap)) | 661 if (NILP (submap)) |
667 submap = create_bucky_submap (k, MOD_META, keymap); | 662 submap = create_bucky_submap (k, XEMACS_MOD_META, keymap); |
668 k = XKEYMAP (submap); | 663 k = XKEYMAP (submap); |
669 modifiers &= ~MOD_META; | 664 modifiers &= ~XEMACS_MOD_META; |
670 } | 665 } |
671 | 666 |
672 if (modifiers != 0) | 667 if (modifiers != 0) |
673 { | 668 { |
674 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (modifiers), | 669 Lisp_Object submap = Fgethash (MAKE_MODIFIER_HASH_KEY (modifiers), |
1067 else if (CONSP (idx)) | 1062 else if (CONSP (idx)) |
1068 { | 1063 { |
1069 if (!INTP (XCDR (idx))) | 1064 if (!INTP (XCDR (idx))) |
1070 return Qnil; | 1065 return Qnil; |
1071 indirection.keysym = XCAR (idx); | 1066 indirection.keysym = XCAR (idx); |
1072 indirection.modifiers = XINT (XCDR (idx)); | 1067 indirection.modifiers = (unsigned char) XINT (XCDR (idx)); |
1073 } | 1068 } |
1074 else if (SYMBOLP (idx)) | 1069 else if (SYMBOLP (idx)) |
1075 { | 1070 { |
1076 indirection.keysym = idx; | 1071 indirection.keysym = idx; |
1077 indirection.modifiers = 0; | 1072 indirection.modifiers = 0; |
1098 return object; | 1093 return object; |
1099 } | 1094 } |
1100 } | 1095 } |
1101 | 1096 |
1102 static Lisp_Object | 1097 static Lisp_Object |
1103 keymap_lookup_1 (Lisp_Object keymap, CONST struct key_data *key, | 1098 keymap_lookup_1 (Lisp_Object keymap, const struct key_data *key, |
1104 int accept_default) | 1099 int accept_default) |
1105 { | 1100 { |
1106 /* This function can GC */ | 1101 /* This function can GC */ |
1107 return get_keyelt (keymap_lookup_directly (keymap, | 1102 return get_keyelt (keymap_lookup_directly (keymap, |
1108 key->keysym, key->modifiers), | 1103 key->keysym, key->modifiers), |
1256 and perform any necessary canonicalization. */ | 1251 and perform any necessary canonicalization. */ |
1257 | 1252 |
1258 static void | 1253 static void |
1259 define_key_check_and_coerce_keysym (Lisp_Object spec, | 1254 define_key_check_and_coerce_keysym (Lisp_Object spec, |
1260 Lisp_Object *keysym, | 1255 Lisp_Object *keysym, |
1261 unsigned int modifiers) | 1256 int modifiers) |
1262 { | 1257 { |
1263 /* Now, check and massage the trailing keysym specifier. */ | 1258 /* Now, check and massage the trailing keysym specifier. */ |
1264 if (SYMBOLP (*keysym)) | 1259 if (SYMBOLP (*keysym)) |
1265 { | 1260 { |
1266 if (string_char_length (XSYMBOL (*keysym)->name) == 1) | 1261 if (string_char_length (XSYMBOL (*keysym)->name) == 1) |
1279 /* || (XCHAR (*keysym) >= 128 && XCHAR (*keysym) < 160) */) | 1274 /* || (XCHAR (*keysym) >= 128 && XCHAR (*keysym) < 160) */) |
1280 /* yuck! Can't make the above restriction; too many compatibility | 1275 /* yuck! Can't make the above restriction; too many compatibility |
1281 problems ... */ | 1276 problems ... */ |
1282 signal_simple_error ("keysym char must be printable", *keysym); | 1277 signal_simple_error ("keysym char must be printable", *keysym); |
1283 /* #### This bites! I want to be able to write (control shift a) */ | 1278 /* #### This bites! I want to be able to write (control shift a) */ |
1284 if (modifiers & MOD_SHIFT) | 1279 if (modifiers & XEMACS_MOD_SHIFT) |
1285 signal_simple_error | 1280 signal_simple_error |
1286 ("The `shift' modifier may not be applied to ASCII keysyms", | 1281 ("The `shift' modifier may not be applied to ASCII keysyms", |
1287 spec); | 1282 spec); |
1288 } | 1283 } |
1289 else | 1284 else |
1456 returned_value->keysym = spec; | 1451 returned_value->keysym = spec; |
1457 returned_value->modifiers = 0; | 1452 returned_value->modifiers = 0; |
1458 } | 1453 } |
1459 else if (CONSP (spec)) | 1454 else if (CONSP (spec)) |
1460 { | 1455 { |
1461 unsigned int modifiers = 0; | 1456 int modifiers = 0; |
1462 Lisp_Object keysym = Qnil; | 1457 Lisp_Object keysym = Qnil; |
1463 Lisp_Object rest = spec; | 1458 Lisp_Object rest = spec; |
1464 | 1459 |
1465 /* First, parse out the leading modifier symbols. */ | 1460 /* First, parse out the leading modifier symbols. */ |
1466 while (CONSP (rest)) | 1461 while (CONSP (rest)) |
1467 { | 1462 { |
1468 unsigned int modifier; | 1463 int modifier; |
1469 | 1464 |
1470 keysym = XCAR (rest); | 1465 keysym = XCAR (rest); |
1471 modifier = bucky_sym_to_bucky_bit (keysym); | 1466 modifier = bucky_sym_to_bucky_bit (keysym); |
1472 modifiers |= modifier; | 1467 modifiers |= modifier; |
1473 if (!NILP (XCDR (rest))) | 1468 if (!NILP (XCDR (rest))) |
1594 UNGCPRO; | 1589 UNGCPRO; |
1595 return retval; | 1590 return retval; |
1596 } | 1591 } |
1597 | 1592 |
1598 static int | 1593 static int |
1599 meta_prefix_char_p (CONST struct key_data *key) | 1594 meta_prefix_char_p (const struct key_data *key) |
1600 { | 1595 { |
1601 Lisp_Event event; | 1596 Lisp_Event event; |
1602 | 1597 |
1603 event.event_type = key_press_event; | 1598 event.event_type = key_press_event; |
1604 event.channel = Vselected_console; | 1599 event.channel = Vselected_console; |
1633 static void | 1628 static void |
1634 define_key_alternate_name (struct key_data *key, | 1629 define_key_alternate_name (struct key_data *key, |
1635 struct key_data *returned_value) | 1630 struct key_data *returned_value) |
1636 { | 1631 { |
1637 Lisp_Object keysym = key->keysym; | 1632 Lisp_Object keysym = key->keysym; |
1638 unsigned int modifiers = key->modifiers; | 1633 int modifiers = key->modifiers; |
1639 unsigned int modifiers_sans_control = (modifiers & (~MOD_CONTROL)); | 1634 int modifiers_sans_control = (modifiers & (~XEMACS_MOD_CONTROL)); |
1640 unsigned int modifiers_sans_meta = (modifiers & (~MOD_META)); | 1635 int modifiers_sans_meta = (modifiers & (~XEMACS_MOD_META)); |
1641 returned_value->keysym = Qnil; /* By default, no "alternate" key */ | 1636 returned_value->keysym = Qnil; /* By default, no "alternate" key */ |
1642 returned_value->modifiers = 0; | 1637 returned_value->modifiers = 0; |
1643 if (modifiers_sans_meta == MOD_CONTROL) | 1638 if (modifiers_sans_meta == XEMACS_MOD_CONTROL) |
1644 { | 1639 { |
1645 if EQ (keysym, QKspace) | 1640 if EQ (keysym, QKspace) |
1646 MACROLET (make_char ('@'), modifiers); | 1641 MACROLET (make_char ('@'), modifiers); |
1647 else if (!CHARP (keysym)) | 1642 else if (!CHARP (keysym)) |
1648 return; | 1643 return; |
1665 } | 1660 } |
1666 } | 1661 } |
1667 else if (modifiers_sans_meta != 0) | 1662 else if (modifiers_sans_meta != 0) |
1668 return; | 1663 return; |
1669 else if (EQ (keysym, QKbackspace)) /* backspace => c-h */ | 1664 else if (EQ (keysym, QKbackspace)) /* backspace => c-h */ |
1670 MACROLET (make_char ('h'), (modifiers | MOD_CONTROL)); | 1665 MACROLET (make_char ('h'), (modifiers | XEMACS_MOD_CONTROL)); |
1671 else if (EQ (keysym, QKtab)) /* tab => c-i */ | 1666 else if (EQ (keysym, QKtab)) /* tab => c-i */ |
1672 MACROLET (make_char ('i'), (modifiers | MOD_CONTROL)); | 1667 MACROLET (make_char ('i'), (modifiers | XEMACS_MOD_CONTROL)); |
1673 else if (EQ (keysym, QKlinefeed)) /* linefeed => c-j */ | 1668 else if (EQ (keysym, QKlinefeed)) /* linefeed => c-j */ |
1674 MACROLET (make_char ('j'), (modifiers | MOD_CONTROL)); | 1669 MACROLET (make_char ('j'), (modifiers | XEMACS_MOD_CONTROL)); |
1675 else if (EQ (keysym, QKreturn)) /* return => c-m */ | 1670 else if (EQ (keysym, QKreturn)) /* return => c-m */ |
1676 MACROLET (make_char ('m'), (modifiers | MOD_CONTROL)); | 1671 MACROLET (make_char ('m'), (modifiers | XEMACS_MOD_CONTROL)); |
1677 else if (EQ (keysym, QKescape)) /* escape => c-[ */ | 1672 else if (EQ (keysym, QKescape)) /* escape => c-[ */ |
1678 MACROLET (make_char ('['), (modifiers | MOD_CONTROL)); | 1673 MACROLET (make_char ('['), (modifiers | XEMACS_MOD_CONTROL)); |
1679 else | 1674 else |
1680 return; | 1675 return; |
1681 #undef MACROLET | 1676 #undef MACROLET |
1682 } | 1677 } |
1683 | 1678 |
1710 new_keys = make_vector (indx, Qnil); | 1705 new_keys = make_vector (indx, Qnil); |
1711 for (i = 0; i < indx; i++) | 1706 for (i = 0; i < indx; i++) |
1712 XVECTOR_DATA (new_keys) [i] = XVECTOR_DATA (keys) [i]; | 1707 XVECTOR_DATA (new_keys) [i] = XVECTOR_DATA (keys) [i]; |
1713 } | 1708 } |
1714 else | 1709 else |
1715 abort (); | 1710 { |
1711 new_keys = Qnil; | |
1712 abort (); | |
1713 } | |
1716 | 1714 |
1717 if (EQ (keys, new_keys)) | 1715 if (EQ (keys, new_keys)) |
1718 error_with_frob (mpc_binding, | 1716 error_with_frob (mpc_binding, |
1719 "can't bind %s: %s has a non-keymap binding", | 1717 "can't bind %s: %s has a non-keymap binding", |
1720 (char *) XSTRING_DATA (Fkey_description (keys)), | 1718 (char *) XSTRING_DATA (Fkey_description (keys)), |
1906 */ | 1904 */ |
1907 Lisp_Object meta_map; | 1905 Lisp_Object meta_map; |
1908 struct gcpro ngcpro1; | 1906 struct gcpro ngcpro1; |
1909 | 1907 |
1910 NGCPRO1 (c); | 1908 NGCPRO1 (c); |
1911 meta_map = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), | 1909 meta_map = Fgethash (MAKE_MODIFIER_HASH_KEY (XEMACS_MOD_META), |
1912 XKEYMAP (keymap)->table, Qnil); | 1910 XKEYMAP (keymap)->table, Qnil); |
1913 if (!NILP (meta_map) | 1911 if (!NILP (meta_map) |
1914 && keymap_fullness (meta_map) != 0) | 1912 && keymap_fullness (meta_map) != 0) |
1915 signal_simple_error_2 | 1913 signal_simple_error_2 |
1916 ("Map contains meta-bindings, can't bind", | 1914 ("Map contains meta-bindings, can't bind", |
1933 raw_key2.modifiers = 0; | 1931 raw_key2.modifiers = 0; |
1934 } | 1932 } |
1935 | 1933 |
1936 if (metized) | 1934 if (metized) |
1937 { | 1935 { |
1938 raw_key1.modifiers |= MOD_META; | 1936 raw_key1.modifiers |= XEMACS_MOD_META; |
1939 raw_key2.modifiers |= MOD_META; | 1937 raw_key2.modifiers |= XEMACS_MOD_META; |
1940 metized = 0; | 1938 metized = 0; |
1941 } | 1939 } |
1942 | 1940 |
1943 /* This crap is to make sure that someone doesn't bind something like | 1941 /* This crap is to make sure that someone doesn't bind something like |
1944 "C-x M-a" while "C-x ESC" has a non-keymap binding. */ | 1942 "C-x M-a" while "C-x ESC" has a non-keymap binding. */ |
1945 if (raw_key1.modifiers & MOD_META) | 1943 if (raw_key1.modifiers & XEMACS_MOD_META) |
1946 ensure_meta_prefix_char_keymapp (keys, idx, keymap); | 1944 ensure_meta_prefix_char_keymapp (keys, idx, keymap); |
1947 | 1945 |
1948 if (++idx == len) | 1946 if (++idx == len) |
1949 { | 1947 { |
1950 keymap_store (keymap, &raw_key1, def); | 1948 keymap_store (keymap, &raw_key1, def); |
1990 to make where-is-internal really fly. */ | 1988 to make where-is-internal really fly. */ |
1991 | 1989 |
1992 struct raw_lookup_key_mapper_closure | 1990 struct raw_lookup_key_mapper_closure |
1993 { | 1991 { |
1994 int remaining; | 1992 int remaining; |
1995 CONST struct key_data *raw_keys; | 1993 const struct key_data *raw_keys; |
1996 int raw_keys_count; | 1994 int raw_keys_count; |
1997 int keys_so_far; | 1995 int keys_so_far; |
1998 int accept_default; | 1996 int accept_default; |
1999 }; | 1997 }; |
2000 | 1998 |
2001 static Lisp_Object raw_lookup_key_mapper (Lisp_Object k, void *); | 1999 static Lisp_Object raw_lookup_key_mapper (Lisp_Object k, void *); |
2002 | 2000 |
2003 /* Caller should gc-protect args (keymaps may autoload) */ | 2001 /* Caller should gc-protect args (keymaps may autoload) */ |
2004 static Lisp_Object | 2002 static Lisp_Object |
2005 raw_lookup_key (Lisp_Object keymap, | 2003 raw_lookup_key (Lisp_Object keymap, |
2006 CONST struct key_data *raw_keys, int raw_keys_count, | 2004 const struct key_data *raw_keys, int raw_keys_count, |
2007 int keys_so_far, int accept_default) | 2005 int keys_so_far, int accept_default) |
2008 { | 2006 { |
2009 /* This function can GC */ | 2007 /* This function can GC */ |
2010 struct raw_lookup_key_mapper_closure c; | 2008 struct raw_lookup_key_mapper_closure c; |
2011 c.remaining = raw_keys_count - 1; | 2009 c.remaining = raw_keys_count - 1; |
2024 struct raw_lookup_key_mapper_closure *c = | 2022 struct raw_lookup_key_mapper_closure *c = |
2025 (struct raw_lookup_key_mapper_closure *) arg; | 2023 (struct raw_lookup_key_mapper_closure *) arg; |
2026 int accept_default = c->accept_default; | 2024 int accept_default = c->accept_default; |
2027 int remaining = c->remaining; | 2025 int remaining = c->remaining; |
2028 int keys_so_far = c->keys_so_far; | 2026 int keys_so_far = c->keys_so_far; |
2029 CONST struct key_data *raw_keys = c->raw_keys; | 2027 const struct key_data *raw_keys = c->raw_keys; |
2030 Lisp_Object cmd; | 2028 Lisp_Object cmd; |
2031 | 2029 |
2032 if (! meta_prefix_char_p (&(raw_keys[0]))) | 2030 if (! meta_prefix_char_p (&(raw_keys[0]))) |
2033 { | 2031 { |
2034 /* Normal case: every case except the meta-hack (see below). */ | 2032 /* Normal case: every case except the meta-hack (see below). */ |
2063 /* First look for the prefix-char directly */ | 2061 /* First look for the prefix-char directly */ |
2064 cmd = keymap_lookup_1 (k, &(raw_keys[0]), accept_default); | 2062 cmd = keymap_lookup_1 (k, &(raw_keys[0]), accept_default); |
2065 if (NILP (cmd)) | 2063 if (NILP (cmd)) |
2066 { | 2064 { |
2067 /* Do kludgy return of the meta-map */ | 2065 /* Do kludgy return of the meta-map */ |
2068 cmd = Fgethash (MAKE_MODIFIER_HASH_KEY (MOD_META), | 2066 cmd = Fgethash (MAKE_MODIFIER_HASH_KEY (XEMACS_MOD_META), |
2069 XKEYMAP (k)->table, Qnil); | 2067 XKEYMAP (k)->table, Qnil); |
2070 } | 2068 } |
2071 } | 2069 } |
2072 else | 2070 else |
2073 { | 2071 { |
2075 cmd = keymap_lookup_1 (k, &(raw_keys[0]), accept_default); | 2073 cmd = keymap_lookup_1 (k, &(raw_keys[0]), accept_default); |
2076 cmd = get_keymap (cmd, 0, 1); | 2074 cmd = get_keymap (cmd, 0, 1); |
2077 if (!NILP (cmd)) | 2075 if (!NILP (cmd)) |
2078 cmd = raw_lookup_key (cmd, raw_keys + 1, remaining, | 2076 cmd = raw_lookup_key (cmd, raw_keys + 1, remaining, |
2079 keys_so_far + 1, accept_default); | 2077 keys_so_far + 1, accept_default); |
2080 else if ((raw_keys[1].modifiers & MOD_META) == 0) | 2078 else if ((raw_keys[1].modifiers & XEMACS_MOD_META) == 0) |
2081 { | 2079 { |
2082 struct key_data metified; | 2080 struct key_data metified; |
2083 metified.keysym = raw_keys[1].keysym; | 2081 metified.keysym = raw_keys[1].keysym; |
2084 metified.modifiers = raw_keys[1].modifiers | MOD_META; | 2082 metified.modifiers = raw_keys[1].modifiers | |
2083 (unsigned char) XEMACS_MOD_META; | |
2085 | 2084 |
2086 /* Search for meta-next-char sequence directly */ | 2085 /* Search for meta-next-char sequence directly */ |
2087 cmd = keymap_lookup_1 (k, &metified, accept_default); | 2086 cmd = keymap_lookup_1 (k, &metified, accept_default); |
2088 if (remaining == 1) | 2087 if (remaining == 1) |
2089 ; | 2088 ; |
2739 outside of this file doesn't need to know about. | 2738 outside of this file doesn't need to know about. |
2740 */ | 2739 */ |
2741 | 2740 |
2742 struct map_keymap_unsorted_closure | 2741 struct map_keymap_unsorted_closure |
2743 { | 2742 { |
2744 void (*fn) (CONST struct key_data *, Lisp_Object binding, void *arg); | 2743 void (*fn) (const struct key_data *, Lisp_Object binding, void *arg); |
2745 void *arg; | 2744 void *arg; |
2746 unsigned int modifiers; | 2745 int modifiers; |
2747 }; | 2746 }; |
2748 | 2747 |
2749 /* used by map_keymap() */ | 2748 /* used by map_keymap() */ |
2750 static int | 2749 static int |
2751 map_keymap_unsorted_mapper (Lisp_Object keysym, Lisp_Object value, | 2750 map_keymap_unsorted_mapper (Lisp_Object keysym, Lisp_Object value, |
2752 void *map_keymap_unsorted_closure) | 2751 void *map_keymap_unsorted_closure) |
2753 { | 2752 { |
2754 /* This function can GC */ | 2753 /* This function can GC */ |
2755 struct map_keymap_unsorted_closure *closure = | 2754 struct map_keymap_unsorted_closure *closure = |
2756 (struct map_keymap_unsorted_closure *) map_keymap_unsorted_closure; | 2755 (struct map_keymap_unsorted_closure *) map_keymap_unsorted_closure; |
2757 unsigned int modifiers = closure->modifiers; | 2756 int modifiers = closure->modifiers; |
2758 unsigned int mod_bit; | 2757 int mod_bit; |
2759 mod_bit = MODIFIER_HASH_KEY_BITS (keysym); | 2758 mod_bit = MODIFIER_HASH_KEY_BITS (keysym); |
2760 if (mod_bit != 0) | 2759 if (mod_bit != 0) |
2761 { | 2760 { |
2762 int omod = modifiers; | 2761 int omod = modifiers; |
2763 closure->modifiers = (modifiers | mod_bit); | 2762 closure->modifiers = (modifiers | mod_bit); |
2803 map_keymap_sort_predicate (Lisp_Object obj1, Lisp_Object obj2, | 2802 map_keymap_sort_predicate (Lisp_Object obj1, Lisp_Object obj2, |
2804 Lisp_Object pred) | 2803 Lisp_Object pred) |
2805 { | 2804 { |
2806 /* obj1 and obj2 are conses with keysyms in their cars. Cdrs are ignored. | 2805 /* obj1 and obj2 are conses with keysyms in their cars. Cdrs are ignored. |
2807 */ | 2806 */ |
2808 unsigned int bit1, bit2; | 2807 int bit1, bit2; |
2809 int sym1_p = 0; | 2808 int sym1_p = 0; |
2810 int sym2_p = 0; | 2809 int sym2_p = 0; |
2811 obj1 = XCAR (obj1); | 2810 obj1 = XCAR (obj1); |
2812 obj2 = XCAR (obj2); | 2811 obj2 = XCAR (obj2); |
2813 | 2812 |
2877 | 2876 |
2878 | 2877 |
2879 /* used by map_keymap() */ | 2878 /* used by map_keymap() */ |
2880 static void | 2879 static void |
2881 map_keymap_sorted (Lisp_Object keymap_table, | 2880 map_keymap_sorted (Lisp_Object keymap_table, |
2882 unsigned int modifiers, | 2881 int modifiers, |
2883 void (*function) (CONST struct key_data *key, | 2882 void (*function) (const struct key_data *key, |
2884 Lisp_Object binding, | 2883 Lisp_Object binding, |
2885 void *map_keymap_sorted_closure), | 2884 void *map_keymap_sorted_closure), |
2886 void *map_keymap_sorted_closure) | 2885 void *map_keymap_sorted_closure) |
2887 { | 2886 { |
2888 /* This function can GC */ | 2887 /* This function can GC */ |
2902 contents = list_sort (contents, Qnil, map_keymap_sort_predicate); | 2901 contents = list_sort (contents, Qnil, map_keymap_sort_predicate); |
2903 for (; !NILP (contents); contents = XCDR (contents)) | 2902 for (; !NILP (contents); contents = XCDR (contents)) |
2904 { | 2903 { |
2905 Lisp_Object keysym = XCAR (XCAR (contents)); | 2904 Lisp_Object keysym = XCAR (XCAR (contents)); |
2906 Lisp_Object binding = XCDR (XCAR (contents)); | 2905 Lisp_Object binding = XCDR (XCAR (contents)); |
2907 unsigned int sub_bits = MODIFIER_HASH_KEY_BITS (keysym); | 2906 int sub_bits = MODIFIER_HASH_KEY_BITS (keysym); |
2908 if (sub_bits != 0) | 2907 if (sub_bits != 0) |
2909 map_keymap_sorted (XKEYMAP (get_keymap (binding, | 2908 map_keymap_sorted (XKEYMAP (get_keymap (binding, |
2910 1, 1))->table, | 2909 1, 1))->table, |
2911 (modifiers | sub_bits), | 2910 (modifiers | sub_bits), |
2912 function, | 2911 function, |
2923 } | 2922 } |
2924 | 2923 |
2925 | 2924 |
2926 /* used by Fmap_keymap() */ | 2925 /* used by Fmap_keymap() */ |
2927 static void | 2926 static void |
2928 map_keymap_mapper (CONST struct key_data *key, | 2927 map_keymap_mapper (const struct key_data *key, |
2929 Lisp_Object binding, | 2928 Lisp_Object binding, |
2930 void *function) | 2929 void *function) |
2931 { | 2930 { |
2932 /* This function can GC */ | 2931 /* This function can GC */ |
2933 Lisp_Object fn; | 2932 Lisp_Object fn; |
2936 } | 2935 } |
2937 | 2936 |
2938 | 2937 |
2939 static void | 2938 static void |
2940 map_keymap (Lisp_Object keymap_table, int sort_first, | 2939 map_keymap (Lisp_Object keymap_table, int sort_first, |
2941 void (*function) (CONST struct key_data *key, | 2940 void (*function) (const struct key_data *key, |
2942 Lisp_Object binding, | 2941 Lisp_Object binding, |
2943 void *fn_arg), | 2942 void *fn_arg), |
2944 void *fn_arg) | 2943 void *fn_arg) |
2945 { | 2944 { |
2946 /* This function can GC */ | 2945 /* This function can GC */ |
3008 }; | 3007 }; |
3009 | 3008 |
3010 | 3009 |
3011 static void | 3010 static void |
3012 accessible_keymaps_mapper_1 (Lisp_Object keysym, Lisp_Object contents, | 3011 accessible_keymaps_mapper_1 (Lisp_Object keysym, Lisp_Object contents, |
3013 unsigned int modifiers, | 3012 int modifiers, |
3014 struct accessible_keymaps_closure *closure) | 3013 struct accessible_keymaps_closure *closure) |
3015 { | 3014 { |
3016 /* This function can GC */ | 3015 /* This function can GC */ |
3017 unsigned int subbits = MODIFIER_HASH_KEY_BITS (keysym); | 3016 int subbits = MODIFIER_HASH_KEY_BITS (keysym); |
3018 | 3017 |
3019 if (subbits != 0) | 3018 if (subbits != 0) |
3020 { | 3019 { |
3021 Lisp_Object submaps; | 3020 Lisp_Object submaps; |
3022 | 3021 |
3490 returning, then we reconsider. | 3489 returning, then we reconsider. |
3491 firstonly means give up after finding the first match; | 3490 firstonly means give up after finding the first match; |
3492 keys_so_far and modifiers_so_far describe which map we're looking in; | 3491 keys_so_far and modifiers_so_far describe which map we're looking in; |
3493 If we're in the "meta" submap of the map that "C-x 4" is bound to, | 3492 If we're in the "meta" submap of the map that "C-x 4" is bound to, |
3494 then keys_so_far will be {(control x), \4}, and modifiers_so_far | 3493 then keys_so_far will be {(control x), \4}, and modifiers_so_far |
3495 will be MOD_META. That is, keys_so_far is the chain of keys that we | 3494 will be XEMACS_MOD_META. That is, keys_so_far is the chain of keys that we |
3496 have followed, and modifiers_so_far_so_far is the bits (partial keys) | 3495 have followed, and modifiers_so_far_so_far is the bits (partial keys) |
3497 beyond that. | 3496 beyond that. |
3498 | 3497 |
3499 (keys_so_far is a global buffer and the keys_count arg says how much | 3498 (keys_so_far is a global buffer and the keys_count arg says how much |
3500 of it we're currently interested in.) | 3499 of it we're currently interested in.) |
3508 Lisp_Object definition; | 3507 Lisp_Object definition; |
3509 Lisp_Object *shadow; | 3508 Lisp_Object *shadow; |
3510 int shadow_count; | 3509 int shadow_count; |
3511 int firstonly; | 3510 int firstonly; |
3512 int keys_count; | 3511 int keys_count; |
3513 unsigned int modifiers_so_far; | 3512 int modifiers_so_far; |
3514 char *target_buffer; | 3513 char *target_buffer; |
3515 struct key_data *keys_so_far; | 3514 struct key_data *keys_so_far; |
3516 int keys_so_far_total_size; | 3515 int keys_so_far_total_size; |
3517 int keys_so_far_malloced; | 3516 int keys_so_far_malloced; |
3518 }; | 3517 }; |
3523 where_is_recursive_mapper (Lisp_Object map, void *arg) | 3522 where_is_recursive_mapper (Lisp_Object map, void *arg) |
3524 { | 3523 { |
3525 /* This function can GC */ | 3524 /* This function can GC */ |
3526 struct where_is_closure *c = (struct where_is_closure *) arg; | 3525 struct where_is_closure *c = (struct where_is_closure *) arg; |
3527 Lisp_Object definition = c->definition; | 3526 Lisp_Object definition = c->definition; |
3528 CONST int firstonly = c->firstonly; | 3527 const int firstonly = c->firstonly; |
3529 CONST unsigned int keys_count = c->keys_count; | 3528 const int keys_count = c->keys_count; |
3530 CONST unsigned int modifiers_so_far = c->modifiers_so_far; | 3529 const int modifiers_so_far = c->modifiers_so_far; |
3531 char *target_buffer = c->target_buffer; | 3530 char *target_buffer = c->target_buffer; |
3532 Lisp_Object keys = Fgethash (definition, | 3531 Lisp_Object keys = Fgethash (definition, |
3533 XKEYMAP (map)->inverse_table, | 3532 XKEYMAP (map)->inverse_table, |
3534 Qnil); | 3533 Qnil); |
3535 Lisp_Object submaps; | 3534 Lisp_Object submaps; |
3598 !NILP (submaps); | 3597 !NILP (submaps); |
3599 submaps = XCDR (submaps)) | 3598 submaps = XCDR (submaps)) |
3600 { | 3599 { |
3601 Lisp_Object key = XCAR (XCAR (submaps)); | 3600 Lisp_Object key = XCAR (XCAR (submaps)); |
3602 Lisp_Object submap = XCDR (XCAR (submaps)); | 3601 Lisp_Object submap = XCDR (XCAR (submaps)); |
3603 unsigned int lower_modifiers; | 3602 int lower_modifiers; |
3604 int lower_keys_count = keys_count; | 3603 int lower_keys_count = keys_count; |
3605 unsigned int bucky; | 3604 int bucky; |
3606 | 3605 |
3607 submap = get_keymap (submap, 0, 0); | 3606 submap = get_keymap (submap, 0, 0); |
3608 | 3607 |
3609 if (EQ (submap, map)) | 3608 if (EQ (submap, map)) |
3610 /* Arrgh! Some loser has introduced a loop... */ | 3609 /* Arrgh! Some loser has introduced a loop... */ |
3641 { | 3640 { |
3642 int size = lower_keys_count + 50; | 3641 int size = lower_keys_count + 50; |
3643 if (! c->keys_so_far_malloced) | 3642 if (! c->keys_so_far_malloced) |
3644 { | 3643 { |
3645 struct key_data *new = xnew_array (struct key_data, size); | 3644 struct key_data *new = xnew_array (struct key_data, size); |
3646 memcpy ((void *)new, (CONST void *)c->keys_so_far, | 3645 memcpy ((void *)new, (const void *)c->keys_so_far, |
3647 c->keys_so_far_total_size * sizeof (struct key_data)); | 3646 c->keys_so_far_total_size * sizeof (struct key_data)); |
3648 } | 3647 } |
3649 else | 3648 else |
3650 XREALLOC_ARRAY (c->keys_so_far, struct key_data, size); | 3649 XREALLOC_ARRAY (c->keys_so_far, struct key_data, size); |
3651 | 3650 |
3894 int mice_only_p; /* whether we are to display only button bindings */ | 3893 int mice_only_p; /* whether we are to display only button bindings */ |
3895 }; | 3894 }; |
3896 | 3895 |
3897 struct describe_map_shadow_closure | 3896 struct describe_map_shadow_closure |
3898 { | 3897 { |
3899 CONST struct key_data *raw_key; | 3898 const struct key_data *raw_key; |
3900 Lisp_Object self; | 3899 Lisp_Object self; |
3901 }; | 3900 }; |
3902 | 3901 |
3903 static Lisp_Object | 3902 static Lisp_Object |
3904 describe_map_mapper_shadow_search (Lisp_Object map, void *arg) | 3903 describe_map_mapper_shadow_search (Lisp_Object map, void *arg) |
3923 return keymap_lookup_directly (km, k->keysym, k->modifiers); | 3922 return keymap_lookup_directly (km, k->keysym, k->modifiers); |
3924 } | 3923 } |
3925 | 3924 |
3926 | 3925 |
3927 static void | 3926 static void |
3928 describe_map_mapper (CONST struct key_data *key, | 3927 describe_map_mapper (const struct key_data *key, |
3929 Lisp_Object binding, | 3928 Lisp_Object binding, |
3930 void *describe_map_closure) | 3929 void *describe_map_closure) |
3931 { | 3930 { |
3932 /* This function can GC */ | 3931 /* This function can GC */ |
3933 struct describe_map_closure *closure = | 3932 struct describe_map_closure *closure = |
3934 (struct describe_map_closure *) describe_map_closure; | 3933 (struct describe_map_closure *) describe_map_closure; |
3935 Lisp_Object keysym = key->keysym; | 3934 Lisp_Object keysym = key->keysym; |
3936 unsigned int modifiers = key->modifiers; | 3935 int modifiers = key->modifiers; |
3937 | 3936 |
3938 /* Don't mention suppressed commands. */ | 3937 /* Don't mention suppressed commands. */ |
3939 if (SYMBOLP (binding) | 3938 if (SYMBOLP (binding) |
3940 && !NILP (closure->partial) | 3939 && !NILP (closure->partial) |
3941 && !NILP (Fget (binding, closure->partial, Qnil))) | 3940 && !NILP (Fget (binding, closure->partial, Qnil))) |
4005 { | 4004 { |
4006 /* obj1 and obj2 are conses of the form | 4005 /* obj1 and obj2 are conses of the form |
4007 ( ( <keysym> . <modifiers> ) . <binding> ) | 4006 ( ( <keysym> . <modifiers> ) . <binding> ) |
4008 keysym and modifiers are used, binding is ignored. | 4007 keysym and modifiers are used, binding is ignored. |
4009 */ | 4008 */ |
4010 unsigned int bit1, bit2; | 4009 int bit1, bit2; |
4011 obj1 = XCAR (obj1); | 4010 obj1 = XCAR (obj1); |
4012 obj2 = XCAR (obj2); | 4011 obj2 = XCAR (obj2); |
4013 bit1 = XINT (XCDR (obj1)); | 4012 bit1 = XINT (XCDR (obj1)); |
4014 bit2 = XINT (XCDR (obj2)); | 4013 bit2 = XINT (XCDR (obj2)); |
4015 if (bit1 != bit2) | 4014 if (bit1 != bit2) |
4125 buffer_insert_c_string (buf, "\n"); | 4124 buffer_insert_c_string (buf, "\n"); |
4126 while (!NILP (list)) | 4125 while (!NILP (list)) |
4127 { | 4126 { |
4128 Lisp_Object elt = XCAR (XCAR (list)); | 4127 Lisp_Object elt = XCAR (XCAR (list)); |
4129 Lisp_Object keysym = XCAR (elt); | 4128 Lisp_Object keysym = XCAR (elt); |
4130 unsigned int modifiers = XINT (XCDR (elt)); | 4129 int modifiers = XINT (XCDR (elt)); |
4131 | 4130 |
4132 if (!NILP (elt_prefix)) | 4131 if (!NILP (elt_prefix)) |
4133 buffer_insert_lisp_string (buf, elt_prefix); | 4132 buffer_insert_lisp_string (buf, elt_prefix); |
4134 | 4133 |
4135 if (modifiers & MOD_META) buffer_insert_c_string (buf, "M-"); | 4134 if (modifiers & XEMACS_MOD_META) |
4136 if (modifiers & MOD_CONTROL) buffer_insert_c_string (buf, "C-"); | 4135 buffer_insert_c_string (buf, "M-"); |
4137 if (modifiers & MOD_SUPER) buffer_insert_c_string (buf, "S-"); | 4136 if (modifiers & XEMACS_MOD_CONTROL) |
4138 if (modifiers & MOD_HYPER) buffer_insert_c_string (buf, "H-"); | 4137 buffer_insert_c_string (buf, "C-"); |
4139 if (modifiers & MOD_ALT) buffer_insert_c_string (buf, "Alt-"); | 4138 if (modifiers & XEMACS_MOD_SUPER) |
4140 if (modifiers & MOD_SHIFT) buffer_insert_c_string (buf, "Sh-"); | 4139 buffer_insert_c_string (buf, "S-"); |
4140 if (modifiers & XEMACS_MOD_HYPER) | |
4141 buffer_insert_c_string (buf, "H-"); | |
4142 if (modifiers & XEMACS_MOD_ALT) | |
4143 buffer_insert_c_string (buf, "Alt-"); | |
4144 if (modifiers & XEMACS_MOD_SHIFT) | |
4145 buffer_insert_c_string (buf, "Sh-"); | |
4141 if (SYMBOLP (keysym)) | 4146 if (SYMBOLP (keysym)) |
4142 { | 4147 { |
4143 Lisp_Object code = Fget (keysym, Vcharacter_set_property, Qnil); | 4148 Lisp_Object code = Fget (keysym, Vcharacter_set_property, Qnil); |
4144 Emchar c = (CHAR_OR_CHAR_INTP (code) | 4149 Emchar c = (CHAR_OR_CHAR_INTP (code) |
4145 ? XCHAR_OR_CHAR_INT (code) : (Emchar) -1); | 4150 ? XCHAR_OR_CHAR_INT (code) : (Emchar) -1); |
4202 | 4207 |
4203 | 4208 |
4204 void | 4209 void |
4205 syms_of_keymap (void) | 4210 syms_of_keymap (void) |
4206 { | 4211 { |
4212 INIT_LRECORD_IMPLEMENTATION (keymap); | |
4213 | |
4207 defsymbol (&Qminor_mode_map_alist, "minor-mode-map-alist"); | 4214 defsymbol (&Qminor_mode_map_alist, "minor-mode-map-alist"); |
4208 | 4215 |
4209 defsymbol (&Qkeymapp, "keymapp"); | 4216 defsymbol (&Qkeymapp, "keymapp"); |
4210 | 4217 |
4211 defsymbol (&Qsuppress_keymap, "suppress-keymap"); | 4218 defsymbol (&Qsuppress_keymap, "suppress-keymap"); |
4337 */ ); | 4344 */ ); |
4338 keymap_tick = 0; | 4345 keymap_tick = 0; |
4339 | 4346 |
4340 staticpro (&Vcurrent_global_map); | 4347 staticpro (&Vcurrent_global_map); |
4341 | 4348 |
4342 Vsingle_space_string = make_string ((CONST Bufbyte *) " ", 1); | 4349 Vsingle_space_string = make_string ((const Bufbyte *) " ", 1); |
4343 staticpro (&Vsingle_space_string); | 4350 staticpro (&Vsingle_space_string); |
4344 } | 4351 } |
4345 | 4352 |
4346 void | 4353 void |
4347 complex_vars_of_keymap (void) | 4354 complex_vars_of_keymap (void) |
4353 Vcurrent_global_map = Fmake_keymap (Qnil); | 4360 Vcurrent_global_map = Fmake_keymap (Qnil); |
4354 | 4361 |
4355 meta_disgustitute = Fmake_keymap (Qnil); | 4362 meta_disgustitute = Fmake_keymap (Qnil); |
4356 Ffset (ESC_prefix, meta_disgustitute); | 4363 Ffset (ESC_prefix, meta_disgustitute); |
4357 /* no need to protect meta_disgustitute, though */ | 4364 /* no need to protect meta_disgustitute, though */ |
4358 keymap_store_internal (MAKE_MODIFIER_HASH_KEY (MOD_META), | 4365 keymap_store_internal (MAKE_MODIFIER_HASH_KEY (XEMACS_MOD_META), |
4359 XKEYMAP (Vcurrent_global_map), | 4366 XKEYMAP (Vcurrent_global_map), |
4360 meta_disgustitute); | 4367 meta_disgustitute); |
4361 XKEYMAP (Vcurrent_global_map)->sub_maps_cache = Qt; | 4368 XKEYMAP (Vcurrent_global_map)->sub_maps_cache = Qt; |
4362 | 4369 |
4363 Vkey_translation_map = Fmake_sparse_keymap (intern ("key-translation-map")); | 4370 Vkey_translation_map = Fmake_sparse_keymap (intern ("key-translation-map")); |