comparison src/keymap.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 6fa9919a9a0b
children b95fe16005fd
comparison
equal deleted inserted replaced
2827:936a6576c655 2828:a25c824ed558
1584 /* if the specifier is an integer such as 27, then it should match 1584 /* if the specifier is an integer such as 27, then it should match
1585 both of the events 'escape' and 'control ['. Calling 1585 both of the events 'escape' and 'control ['. Calling
1586 Fcharacter_to_event() will only match 'escape'. */ 1586 Fcharacter_to_event() will only match 'escape'. */
1587 if (CHAR_OR_CHAR_INTP (key_specifier)) 1587 if (CHAR_OR_CHAR_INTP (key_specifier))
1588 return (XCHAR_OR_CHAR_INT (key_specifier) 1588 return (XCHAR_OR_CHAR_INT (key_specifier)
1589 == event_to_character (event, 0, 0, 0)); 1589 == event_to_character (event, 0, 0));
1590 1590
1591 /* Otherwise, we cannot call event_to_character() because we may 1591 /* Otherwise, we cannot call event_to_character() because we may
1592 be dealing with non-ASCII keystrokes. In any case, if I ask 1592 be dealing with non-ASCII keystrokes. In any case, if I ask
1593 for 'control [' then I should get exactly that, and not 1593 for 'control [' then I should get exactly that, and not
1594 'escape'. 1594 'escape'.
1607 retval = 0; 1607 retval = 0;
1608 else if (CONSOLE_TTY_P (XCONSOLE (XEVENT_CHANNEL (event)))) 1608 else if (CONSOLE_TTY_P (XCONSOLE (XEVENT_CHANNEL (event))))
1609 { 1609 {
1610 int ch1, ch2; 1610 int ch1, ch2;
1611 1611
1612 ch1 = event_to_character (event, 0, 0, 0); 1612 ch1 = event_to_character (event, 0, 0);
1613 ch2 = event_to_character (event2, 0, 0, 0); 1613 ch2 = event_to_character (event2, 0, 0);
1614 retval = (ch1 >= 0 && ch2 >= 0 && ch1 == ch2); 1614 retval = (ch1 >= 0 && ch2 >= 0 && ch1 == ch2);
1615 } 1615 }
1616 else if (EQ (XEVENT_KEY_KEYSYM (event), XEVENT_KEY_KEYSYM (event2)) && 1616 else if (EQ (XEVENT_KEY_KEYSYM (event), XEVENT_KEY_KEYSYM (event2)) &&
1617 XEVENT_KEY_MODIFIERS (event) == XEVENT_KEY_MODIFIERS (event2)) 1617 XEVENT_KEY_MODIFIERS (event) == XEVENT_KEY_MODIFIERS (event2))
1618 retval = 1; 1618 retval = 1;
1808 A `key sequence' is a set of keystrokes. A `keystroke' is a keysym and some 1808 A `key sequence' is a set of keystrokes. A `keystroke' is a keysym and some
1809 set of modifiers (such as control and meta). A `keysym' is what is printed 1809 set of modifiers (such as control and meta). A `keysym' is what is printed
1810 on the keys on your keyboard. 1810 on the keys on your keyboard.
1811 1811
1812 A keysym may be represented by a symbol, or (if and only if it is equivalent 1812 A keysym may be represented by a symbol, or (if and only if it is equivalent
1813 to an ASCII character in the range 32 - 255) by a character or its equivalent 1813 to a character with a code in the range 32 - 255) by a character or its
1814 ASCII code. The `A' key may be represented by the symbol `A', the character 1814 equivalent code. The `A' key may be represented by the symbol `A', the
1815 `?A', or by the number 65. The `break' key may be represented only by the 1815 character `?A', or by the number 65. The `break' key may be represented
1816 symbol `break'. 1816 only by the symbol `break'.
1817 1817
1818 A keystroke may be represented by a list: the last element of the list 1818 A keystroke may be represented by a list: the last element of the list
1819 is the key (a symbol, character, or number, as above) and the 1819 is the key (a symbol, character, or number, as above) and the
1820 preceding elements are the symbolic names of modifier keys (control, 1820 preceding elements are the symbolic names of modifier keys (control,
1821 meta, super, hyper, alt, and shift). Thus, the sequence control-b is 1821 meta, super, hyper, alt, and shift). Thus, the sequence control-b is
2910 /* obj1 and obj2 are conses with keysyms in their cars. Cdrs are ignored. 2910 /* obj1 and obj2 are conses with keysyms in their cars. Cdrs are ignored.
2911 */ 2911 */
2912 int bit1, bit2; 2912 int bit1, bit2;
2913 int sym1_p = 0; 2913 int sym1_p = 0;
2914 int sym2_p = 0; 2914 int sym2_p = 0;
2915 extern Lisp_Object Qcharacter_of_keysym;
2916
2915 obj1 = XCAR (obj1); 2917 obj1 = XCAR (obj1);
2916 obj2 = XCAR (obj2); 2918 obj2 = XCAR (obj2);
2917 2919
2918 if (EQ (obj1, obj2)) 2920 if (EQ (obj1, obj2))
2919 return -1; 2921 return -1;
2920 bit1 = MODIFIER_HASH_KEY_BITS (obj1); 2922 bit1 = MODIFIER_HASH_KEY_BITS (obj1);
2921 bit2 = MODIFIER_HASH_KEY_BITS (obj2); 2923 bit2 = MODIFIER_HASH_KEY_BITS (obj2);
2922 2924
2923 /* If either is a symbol with a character-set-property, then sort it by 2925 /* If either is a symbol with a Qcharacter_of_keysym property, then sort it by
2924 that code instead of alphabetically. 2926 that code instead of alphabetically.
2925 */ 2927 */
2926 if (! bit1 && SYMBOLP (obj1)) 2928 if (! bit1 && SYMBOLP (obj1))
2927 { 2929 {
2928 Lisp_Object code = Fget (obj1, Vcharacter_set_property, Qnil); 2930 Lisp_Object code = Fget (obj1, Qcharacter_of_keysym, Qnil);
2929 if (CHAR_OR_CHAR_INTP (code)) 2931 if (CHAR_OR_CHAR_INTP (code))
2930 { 2932 {
2931 obj1 = code; 2933 obj1 = code;
2932 CHECK_CHAR_COERCE_INT (obj1); 2934 CHECK_CHAR_COERCE_INT (obj1);
2933 sym1_p = 1; 2935 sym1_p = 1;
2934 } 2936 }
2935 } 2937 }
2936 if (! bit2 && SYMBOLP (obj2)) 2938 if (! bit2 && SYMBOLP (obj2))
2937 { 2939 {
2938 Lisp_Object code = Fget (obj2, Vcharacter_set_property, Qnil); 2940 Lisp_Object code = Fget (obj2, Qcharacter_of_keysym, Qnil);
2939 if (CHAR_OR_CHAR_INTP (code)) 2941 if (CHAR_OR_CHAR_INTP (code))
2940 { 2942 {
2941 obj2 = code; 2943 obj2 = code;
2942 CHECK_CHAR_COERCE_INT (obj2); 2944 CHECK_CHAR_COERCE_INT (obj2);
2943 sym2_p = 1; 2945 sym2_p = 1;
3395 : ((EQ (ctl_arrow, Qt) || NILP (ctl_arrow)) 3397 : ((EQ (ctl_arrow, Qt) || NILP (ctl_arrow))
3396 ? 256 : 160)); 3398 ? 256 : 160));
3397 3399
3398 if (EVENTP (chr)) 3400 if (EVENTP (chr))
3399 { 3401 {
3400 Lisp_Object ch = Fevent_to_character (chr, Qnil, Qnil, Qt); 3402 Lisp_Object ch = Fevent_to_character (chr, Qnil, Qnil);
3401 if (NILP (ch)) 3403 if (NILP (ch))
3402 return 3404 return
3403 signal_continuable_error 3405 signal_continuable_error
3404 (Qinvalid_argument, 3406 (Qinvalid_argument,
3405 "character has no ASCII equivalent", Fcopy_event (chr, Qnil)); 3407 "key has no character equivalent (that we know of)",
3408 Fcopy_event (chr, Qnil));
3406 chr = ch; 3409 chr = ch;
3407 } 3410 }
3408 3411
3409 CHECK_CHAR_COERCE_INT (chr); 3412 CHECK_CHAR_COERCE_INT (chr);
3410 3413
4122 */ 4125 */
4123 static int 4126 static int
4124 elide_next_two_p (Lisp_Object list) 4127 elide_next_two_p (Lisp_Object list)
4125 { 4128 {
4126 Lisp_Object s1, s2; 4129 Lisp_Object s1, s2;
4130 extern Lisp_Object Qcharacter_of_keysym;
4127 4131
4128 if (NILP (XCDR (list))) 4132 if (NILP (XCDR (list)))
4129 return 0; 4133 return 0;
4130 4134
4131 /* next two bindings differ */ 4135 /* next two bindings differ */
4141 s1 = XCAR (XCAR (XCAR (list))); 4145 s1 = XCAR (XCAR (XCAR (list)));
4142 s2 = XCAR (XCAR (XCAR (XCDR (list)))); 4146 s2 = XCAR (XCAR (XCAR (XCDR (list))));
4143 4147
4144 if (SYMBOLP (s1)) 4148 if (SYMBOLP (s1))
4145 { 4149 {
4146 Lisp_Object code = Fget (s1, Vcharacter_set_property, Qnil); 4150 Lisp_Object code = Fget (s1, Qcharacter_of_keysym, Qnil);
4147 if (CHAR_OR_CHAR_INTP (code)) 4151 if (CHAR_OR_CHAR_INTP (code))
4148 { 4152 {
4149 s1 = code; 4153 s1 = code;
4150 CHECK_CHAR_COERCE_INT (s1); 4154 CHECK_CHAR_COERCE_INT (s1);
4151 } 4155 }
4152 else return 0; 4156 else return 0;
4153 } 4157 }
4154 if (SYMBOLP (s2)) 4158 if (SYMBOLP (s2))
4155 { 4159 {
4156 Lisp_Object code = Fget (s2, Vcharacter_set_property, Qnil); 4160 Lisp_Object code = Fget (s2, Qcharacter_of_keysym, Qnil);
4157 if (CHAR_OR_CHAR_INTP (code)) 4161 if (CHAR_OR_CHAR_INTP (code))
4158 { 4162 {
4159 s2 = code; 4163 s2 = code;
4160 CHECK_CHAR_COERCE_INT (s2); 4164 CHECK_CHAR_COERCE_INT (s2);
4161 } 4165 }
4202 : ((EQ (buf->ctl_arrow, Qt) 4206 : ((EQ (buf->ctl_arrow, Qt)
4203 || EQ (buf->ctl_arrow, Qnil)) 4207 || EQ (buf->ctl_arrow, Qnil))
4204 ? 256 : 160)); 4208 ? 256 : 160));
4205 int elided = 0; 4209 int elided = 0;
4206 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4210 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4211 extern Lisp_Object Qcharacter_of_keysym;
4207 4212
4208 keymap = get_keymap (keymap, 1, 1); 4213 keymap = get_keymap (keymap, 1, 1);
4209 describe_map_closure.partial = (partial ? Qsuppress_keymap : Qnil); 4214 describe_map_closure.partial = (partial ? Qsuppress_keymap : Qnil);
4210 describe_map_closure.shadow = shadow; 4215 describe_map_closure.shadow = shadow;
4211 describe_map_closure.list = &list; 4216 describe_map_closure.list = &list;
4242 buffer_insert_c_string (buf, "Alt-"); 4247 buffer_insert_c_string (buf, "Alt-");
4243 if (modifiers & XEMACS_MOD_SHIFT) 4248 if (modifiers & XEMACS_MOD_SHIFT)
4244 buffer_insert_c_string (buf, "Sh-"); 4249 buffer_insert_c_string (buf, "Sh-");
4245 if (SYMBOLP (keysym)) 4250 if (SYMBOLP (keysym))
4246 { 4251 {
4247 Lisp_Object code = Fget (keysym, Vcharacter_set_property, Qnil); 4252 Lisp_Object code = Fget (keysym, Qcharacter_of_keysym, Qnil);
4248 Ichar c = (CHAR_OR_CHAR_INTP (code) 4253 Ichar c = (CHAR_OR_CHAR_INTP (code)
4249 ? XCHAR_OR_CHAR_INT (code) : (Ichar) -1); 4254 ? XCHAR_OR_CHAR_INT (code) : (Ichar) -1);
4250 /* Calling Fsingle_key_description() would cons more */ 4255 /* Calling Fsingle_key_description() would cons more */
4251 #if 0 /* This is bogus */ 4256 #if 0 /* This is bogus */
4252 if (EQ (keysym, QKlinefeed)) 4257 if (EQ (keysym, QKlinefeed))