aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-03-12 21:30:35 +0000
committerRichard M. Stallman1995-03-12 21:30:35 +0000
commit3d31316fe55586af79c5a110d5e3b817ec816b98 (patch)
tree268290c2c026fc8c90b4043cf6e012f6856d8d1a /src
parent534a0de54b2eaf6afac6a29cdd2f171b1d0fba13 (diff)
downloademacs-3d31316fe55586af79c5a110d5e3b817ec816b98.tar.gz
emacs-3d31316fe55586af79c5a110d5e3b817ec816b98.zip
(parse_modifiers_uncached): Delete the code for
multi-character modifiers and for recognizing a modifier alone. (parse_solitary_modifier): New function. (convert_event_type_list): Use parse_solitary_modifier. Also convert symbol A to character A. Handle shift modifier with lower-case letters.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c156
1 files changed, 98 insertions, 58 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index fb6ab2d5c8b..0740632c58d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -493,6 +493,7 @@ static Lisp_Object make_lispy_event ();
493static Lisp_Object make_lispy_movement (); 493static Lisp_Object make_lispy_movement ();
494static Lisp_Object modify_event_symbol (); 494static Lisp_Object modify_event_symbol ();
495static Lisp_Object make_lispy_switch_frame (); 495static Lisp_Object make_lispy_switch_frame ();
496static int parse_solitary_modifier ();
496 497
497/* > 0 if we are to echo keystrokes. */ 498/* > 0 if we are to echo keystrokes. */
498static int echo_keystrokes; 499static int echo_keystrokes;
@@ -3228,9 +3229,6 @@ make_lispy_switch_frame (frame)
3228 SYMBOL's name of the end of the modifiers; the string from this 3229 SYMBOL's name of the end of the modifiers; the string from this
3229 position is the unmodified symbol name. 3230 position is the unmodified symbol name.
3230 3231
3231 If MODIFIER_END is -1, parse *only* a modifier; expect
3232 the symbol name to be just one modifier, with no dash.
3233
3234 This doesn't use any caches. */ 3232 This doesn't use any caches. */
3235 3233
3236static int 3234static int
@@ -3241,7 +3239,6 @@ parse_modifiers_uncached (symbol, modifier_end)
3241 struct Lisp_String *name; 3239 struct Lisp_String *name;
3242 int i; 3240 int i;
3243 int modifiers; 3241 int modifiers;
3244 int just_one = ((int *) (-1) == modifier_end);
3245 3242
3246 CHECK_SYMBOL (symbol, 1); 3243 CHECK_SYMBOL (symbol, 1);
3247 3244
@@ -3262,81 +3259,31 @@ parse_modifiers_uncached (symbol, modifier_end)
3262#define SINGLE_LETTER_MOD(BIT) \ 3259#define SINGLE_LETTER_MOD(BIT) \
3263 (this_mod_end = i + 1, this_mod = BIT) 3260 (this_mod_end = i + 1, this_mod = BIT)
3264 3261
3265#define MULTI_LETTER_MOD(BIT, NAME, LEN) \
3266 if (i + LEN <= name->size \
3267 && ! strncmp (name->data + i, NAME, LEN)) \
3268 { \
3269 this_mod_end = i + LEN; \
3270 this_mod = BIT; \
3271 break; \
3272 }
3273
3274 case 'A': 3262 case 'A':
3275 SINGLE_LETTER_MOD (alt_modifier); 3263 SINGLE_LETTER_MOD (alt_modifier);
3276 break; 3264 break;
3277 3265
3278 case 'a':
3279 MULTI_LETTER_MOD (alt_modifier, "alt", 3);
3280 break;
3281
3282 case 'C': 3266 case 'C':
3283 SINGLE_LETTER_MOD (ctrl_modifier); 3267 SINGLE_LETTER_MOD (ctrl_modifier);
3284 break; 3268 break;
3285 3269
3286 case 'c':
3287 MULTI_LETTER_MOD (ctrl_modifier, "ctrl", 4);
3288 MULTI_LETTER_MOD (ctrl_modifier, "control", 7);
3289 break;
3290
3291 case 'H': 3270 case 'H':
3292 SINGLE_LETTER_MOD (hyper_modifier); 3271 SINGLE_LETTER_MOD (hyper_modifier);
3293 break; 3272 break;
3294 3273
3295 case 'h':
3296 MULTI_LETTER_MOD (hyper_modifier, "hyper", 5);
3297 break;
3298
3299 case 'M': 3274 case 'M':
3300 SINGLE_LETTER_MOD (meta_modifier); 3275 SINGLE_LETTER_MOD (meta_modifier);
3301 break; 3276 break;
3302 3277
3303 case 'm':
3304 MULTI_LETTER_MOD (meta_modifier, "meta", 4);
3305 break;
3306
3307 case 'S': 3278 case 'S':
3308 SINGLE_LETTER_MOD (shift_modifier); 3279 SINGLE_LETTER_MOD (shift_modifier);
3309 break; 3280 break;
3310 3281
3311 case 's': 3282 case 's':
3312 MULTI_LETTER_MOD (shift_modifier, "shift", 5);
3313 MULTI_LETTER_MOD (super_modifier, "super", 5);
3314 SINGLE_LETTER_MOD (super_modifier); 3283 SINGLE_LETTER_MOD (super_modifier);
3315 break; 3284 break;
3316 3285
3317 case 'd':
3318 MULTI_LETTER_MOD (drag_modifier, "drag", 4);
3319 MULTI_LETTER_MOD (down_modifier, "down", 4);
3320 MULTI_LETTER_MOD (double_modifier, "double", 6);
3321 break;
3322
3323 case 't':
3324 MULTI_LETTER_MOD (triple_modifier, "triple", 6);
3325 break;
3326
3327#undef SINGLE_LETTER_MOD 3286#undef SINGLE_LETTER_MOD
3328#undef MULTI_LETTER_MOD
3329 }
3330
3331 /* If we are looking for just a modifier, return now.
3332 Return 0 if we didn't find one; return the
3333 modifier bit if we did find one. */
3334 if (just_one)
3335 {
3336 if (this_mod_end == name->size)
3337 return this_mod;
3338 else
3339 return 0;
3340 } 3287 }
3341 3288
3342 /* If we found no modifier, stop looking for them. */ 3289 /* If we found no modifier, stop looking for them. */
@@ -3454,6 +3401,7 @@ lispy_modifier_list (modifiers)
3454 This is similar to parse_modifiers_uncached, but uses the cache in 3401 This is similar to parse_modifiers_uncached, but uses the cache in
3455 SYMBOL's Qevent_symbol_element_mask property, and maintains the 3402 SYMBOL's Qevent_symbol_element_mask property, and maintains the
3456 Qevent_symbol_elements property. */ 3403 Qevent_symbol_elements property. */
3404
3457static Lisp_Object 3405static Lisp_Object
3458parse_modifiers (symbol) 3406parse_modifiers (symbol)
3459 Lisp_Object symbol; 3407 Lisp_Object symbol;
@@ -3704,8 +3652,9 @@ convert_event_type_list (event)
3704 3652
3705 elt = XCONS (rest)->car; 3653 elt = XCONS (rest)->car;
3706 3654
3655 /* Given a symbol, see if it is a modifier name. */
3707 if (SYMBOLP (elt)) 3656 if (SYMBOLP (elt))
3708 this = parse_modifiers_uncached (elt, -1); 3657 this = parse_solitary_modifier (elt);
3709 3658
3710 if (this != 0) 3659 if (this != 0)
3711 modifiers |= this; 3660 modifiers |= this;
@@ -3717,10 +3666,23 @@ convert_event_type_list (event)
3717 rest = XCONS (rest)->cdr; 3666 rest = XCONS (rest)->cdr;
3718 } 3667 }
3719 3668
3669 /* Let the symbol A refer to the character A. */
3670 if (SYMBOLP (base) && XSYMBOL (base)->name->size == 1)
3671 XSETINT (base, XSYMBOL (base)->name->data[0]);
3672
3720 if (INTEGERP (base)) 3673 if (INTEGERP (base))
3721 { 3674 {
3675 /* Turn (shift a) into A. */
3676 if ((modifiers & shift_modifier) != 0
3677 && (XINT (base) >= 'a' && XINT (base) <= 'z'))
3678 {
3679 XSETINT (base, XINT (base) - ('a' - 'A'));
3680 modifiers &= ~shift_modifier;
3681 }
3682
3683 /* Turn (control a) into C-a. */
3722 if (modifiers & ctrl_modifier) 3684 if (modifiers & ctrl_modifier)
3723 return make_number ((modifiers & ~ ctrl_modifier) 3685 return make_number ((modifiers & ~ctrl_modifier)
3724 | make_ctrl_char (XINT (base))); 3686 | make_ctrl_char (XINT (base)));
3725 else 3687 else
3726 return make_number (modifiers | XINT (base)); 3688 return make_number (modifiers | XINT (base));
@@ -3731,6 +3693,86 @@ convert_event_type_list (event)
3731 error ("Invalid base event"); 3693 error ("Invalid base event");
3732} 3694}
3733 3695
3696/* Try to recognize SYMBOL as a modifier name.
3697 Return the modifier flag bit, or 0 if not recognized. */
3698
3699static int
3700parse_solitary_modifier (symbol)
3701 Lisp_Object symbol;
3702{
3703 struct Lisp_String *name = XSYMBOL (symbol)->name;
3704
3705 switch (name->data[0])
3706 {
3707#define SINGLE_LETTER_MOD(BIT) \
3708 if (name->size == 1) \
3709 return BIT;
3710
3711#define MULTI_LETTER_MOD(BIT, NAME, LEN) \
3712 if (LEN == name->size \
3713 && ! strncmp (name->data, NAME, LEN)) \
3714 return BIT;
3715
3716 case 'A':
3717 SINGLE_LETTER_MOD (alt_modifier);
3718 break;
3719
3720 case 'a':
3721 MULTI_LETTER_MOD (alt_modifier, "alt", 3);
3722 break;
3723
3724 case 'C':
3725 SINGLE_LETTER_MOD (ctrl_modifier);
3726 break;
3727
3728 case 'c':
3729 MULTI_LETTER_MOD (ctrl_modifier, "ctrl", 4);
3730 MULTI_LETTER_MOD (ctrl_modifier, "control", 7);
3731 break;
3732
3733 case 'H':
3734 SINGLE_LETTER_MOD (hyper_modifier);
3735 break;
3736
3737 case 'h':
3738 MULTI_LETTER_MOD (hyper_modifier, "hyper", 5);
3739 break;
3740
3741 case 'M':
3742 SINGLE_LETTER_MOD (meta_modifier);
3743 break;
3744
3745 case 'm':
3746 MULTI_LETTER_MOD (meta_modifier, "meta", 4);
3747 break;
3748
3749 case 'S':
3750 SINGLE_LETTER_MOD (shift_modifier);
3751 break;
3752
3753 case 's':
3754 MULTI_LETTER_MOD (shift_modifier, "shift", 5);
3755 MULTI_LETTER_MOD (super_modifier, "super", 5);
3756 SINGLE_LETTER_MOD (super_modifier);
3757 break;
3758
3759 case 'd':
3760 MULTI_LETTER_MOD (drag_modifier, "drag", 4);
3761 MULTI_LETTER_MOD (down_modifier, "down", 4);
3762 MULTI_LETTER_MOD (double_modifier, "double", 6);
3763 break;
3764
3765 case 't':
3766 MULTI_LETTER_MOD (triple_modifier, "triple", 6);
3767 break;
3768
3769#undef SINGLE_LETTER_MOD
3770#undef MULTI_LETTER_MOD
3771 }
3772
3773 return 0;
3774}
3775
3734/* Return 1 if EVENT is a list whose elements are all integers or symbols. 3776/* Return 1 if EVENT is a list whose elements are all integers or symbols.
3735 Such a list is not valid as an event, 3777 Such a list is not valid as an event,
3736 but it can be a Lucid-style event type list. */ 3778 but it can be a Lucid-style event type list. */
@@ -3754,8 +3796,6 @@ lucid_event_type_list_p (object)
3754 3796
3755 return NILP (tail); 3797 return NILP (tail);
3756} 3798}
3757
3758
3759 3799
3760/* Store into *addr a value nonzero if terminal input chars are available. 3800/* Store into *addr a value nonzero if terminal input chars are available.
3761 Serves the purpose of ioctl (0, FIONREAD, addr) 3801 Serves the purpose of ioctl (0, FIONREAD, addr)