diff options
| author | Jim Blandy | 1992-10-19 18:38:58 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-10-19 18:38:58 +0000 |
| commit | 6569cc8d18b12b197ed27dc9f934c85a0ed035ec (patch) | |
| tree | f589c3577b6abbb67100c17c7eec4a44ea751d93 /src | |
| parent | 3b0182e33a9cb2eb72e69e6b52e745f055a9814e (diff) | |
| download | emacs-6569cc8d18b12b197ed27dc9f934c85a0ed035ec.tar.gz emacs-6569cc8d18b12b197ed27dc9f934c85a0ed035ec.zip | |
* keyboard.c (this_command_keys): Make this a vector, instead of
an array of Lisp_Objects.
(this_command_keys_size): Deleted.
(echo, add_command_key, Fthis_command_keys): Adjusted
appropriately.
(init_keyboard): Don't allocate it here.
(syms_of_keyboard): Allocate it here, and staticpro it.
* keyboard.c (read_char): Call ourselves with the appropriate
number of arguments.
(read_char_menu_prompt): If USED_MOUSE_MENU is zero, don't try to
store things in it.
* keyboard.c (modify_event_symbol): Arrange to set the
click_modifier bit on otherwise unmodified mouse clicks.
* keyboard.c (kbd_buffer_get_event): Remember that
*mouse_position_hook may set *FRAME to 0; don't generate
switch-frame events in this case. Fix fencepost bug in fetching
events from keyboard buffer.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 0ecc56edd5f..63b033b446e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -78,10 +78,13 @@ int recent_keys_index; /* Index for storing next element into recent_keys */ | |||
| 78 | int total_keys; /* Total number of elements stored into recent_keys */ | 78 | int total_keys; /* Total number of elements stored into recent_keys */ |
| 79 | Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */ | 79 | Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */ |
| 80 | 80 | ||
| 81 | /* Buffer holding the key that invoked the current command. */ | 81 | /* Vector holding the key sequence that invoked the current command. |
| 82 | Lisp_Object *this_command_keys; | 82 | It is reused for each command, and it may be longer than the current |
| 83 | int this_command_key_count; /* Size in use. */ | 83 | sequence; this_command_key_count indicates how many elements |
| 84 | int this_command_keys_size; /* Size allocated. */ | 84 | actually mean something. |
| 85 | It's easier to staticpro a single Lisp_Object than an array. */ | ||
| 86 | Lisp_Object this_command_keys; | ||
| 87 | int this_command_key_count; | ||
| 85 | 88 | ||
| 86 | extern int minbuf_level; | 89 | extern int minbuf_level; |
| 87 | 90 | ||
| @@ -472,7 +475,7 @@ echo () | |||
| 472 | immediate_echo = 1; | 475 | immediate_echo = 1; |
| 473 | 476 | ||
| 474 | for (i = 0; i < this_command_key_count; i++) | 477 | for (i = 0; i < this_command_key_count; i++) |
| 475 | echo_char (this_command_keys[i]); | 478 | echo_char (XVECTOR (this_command_keys)->contents[i]); |
| 476 | echo_dash (); | 479 | echo_dash (); |
| 477 | } | 480 | } |
| 478 | 481 | ||
| @@ -518,15 +521,20 @@ static void | |||
| 518 | add_command_key (key) | 521 | add_command_key (key) |
| 519 | Lisp_Object key; | 522 | Lisp_Object key; |
| 520 | { | 523 | { |
| 521 | if (this_command_key_count == this_command_keys_size) | 524 | int size = XVECTOR (this_command_keys)->size; |
| 525 | |||
| 526 | if (this_command_key_count >= size) | ||
| 522 | { | 527 | { |
| 523 | this_command_keys_size *= 2; | 528 | Lisp_Object new_keys = Fmake_vector (make_number (size * 2), Qnil); |
| 524 | this_command_keys | 529 | |
| 525 | = (Lisp_Object *) xrealloc (this_command_keys, | 530 | bcopy (XVECTOR (this_command_keys)->contents, |
| 526 | (this_command_keys_size | 531 | XVECTOR (new_keys)->contents, |
| 527 | * sizeof (Lisp_Object))); | 532 | size); |
| 533 | |||
| 534 | this_command_keys = new_keys; | ||
| 528 | } | 535 | } |
| 529 | this_command_keys[this_command_key_count++] = key; | 536 | |
| 537 | XVECTOR (this_command_keys)->contents[this_command_key_count++] = key; | ||
| 530 | } | 538 | } |
| 531 | 539 | ||
| 532 | Lisp_Object | 540 | Lisp_Object |
| @@ -1095,8 +1103,9 @@ static Lisp_Object kbd_buffer_get_event (); | |||
| 1095 | PREV_EVENT is the previous input event, or nil if we are reading | 1103 | PREV_EVENT is the previous input event, or nil if we are reading |
| 1096 | the first event of a key sequence. | 1104 | the first event of a key sequence. |
| 1097 | 1105 | ||
| 1098 | If we use a mouse menu to read the input, we store 1 into *USED_MOUSE_MENU. | 1106 | If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 |
| 1099 | Otherwise we store 0 there. */ | 1107 | if we used a mouse menu to read the input, or zero otherwise. If |
| 1108 | USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. */ | ||
| 1100 | 1109 | ||
| 1101 | Lisp_Object | 1110 | Lisp_Object |
| 1102 | read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | 1111 | read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) |
| @@ -1359,7 +1368,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1359 | internal_with_output_to_temp_buffer ("*Help*", print_help, tem0); | 1368 | internal_with_output_to_temp_buffer ("*Help*", print_help, tem0); |
| 1360 | 1369 | ||
| 1361 | cancel_echoing (); | 1370 | cancel_echoing (); |
| 1362 | c = read_char (0); | 1371 | c = read_char (0, 0, 0, Qnil, 0); |
| 1363 | /* Remove the help from the frame */ | 1372 | /* Remove the help from the frame */ |
| 1364 | unbind_to (count, Qnil); | 1373 | unbind_to (count, Qnil); |
| 1365 | redisplay (); | 1374 | redisplay (); |
| @@ -2032,8 +2041,7 @@ parse_modifiers_uncached (symbol, modifier_end) | |||
| 2032 | if (! (modifiers & (down_modifier | drag_modifier)) | 2041 | if (! (modifiers & (down_modifier | drag_modifier)) |
| 2033 | && i + 7 == name->size | 2042 | && i + 7 == name->size |
| 2034 | && strncmp (name->data + i, "mouse-", 6) | 2043 | && strncmp (name->data + i, "mouse-", 6) |
| 2035 | && '0' <= name->data[i + 6] | 2044 | && ('0' <= name->data[i + 6] && name->data[i + 6] <= '9')) |
| 2036 | && name->data[i + 6] <= '9') | ||
| 2037 | modifiers |= click_modifier; | 2045 | modifiers |= click_modifier; |
| 2038 | 2046 | ||
| 2039 | if (modifier_end) | 2047 | if (modifier_end) |
| @@ -2297,7 +2305,7 @@ modify_event_symbol (symbol_num, modifiers, symbol_kind, name_table, | |||
| 2297 | /* Fill in the cache entries for this symbol; this also | 2305 | /* Fill in the cache entries for this symbol; this also |
| 2298 | builds the Qevent_symbol_elements property, which the user | 2306 | builds the Qevent_symbol_elements property, which the user |
| 2299 | cares about. */ | 2307 | cares about. */ |
| 2300 | apply_modifiers (0, *slot); | 2308 | apply_modifiers (modifiers & click_modifier, *slot); |
| 2301 | Fput (*slot, Qevent_kind, symbol_kind); | 2309 | Fput (*slot, Qevent_kind, symbol_kind); |
| 2302 | } | 2310 | } |
| 2303 | 2311 | ||
| @@ -2539,8 +2547,9 @@ static int echo_now; | |||
| 2539 | PREV_EVENT is the previous input event, or nil if we are reading | 2547 | PREV_EVENT is the previous input event, or nil if we are reading |
| 2540 | the first event of a key sequence. | 2548 | the first event of a key sequence. |
| 2541 | 2549 | ||
| 2542 | If we use a mouse menu to read the input, we store 1 into *USED_MOUSE_MENU. | 2550 | If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 |
| 2543 | Otherwise we store 0 there. | 2551 | if we used a mouse menu to read the input, or zero otherwise. If |
| 2552 | USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. | ||
| 2544 | 2553 | ||
| 2545 | The prompting is done based on the prompt-string of the map | 2554 | The prompting is done based on the prompt-string of the map |
| 2546 | and the strings associated with various map elements. */ | 2555 | and the strings associated with various map elements. */ |
| @@ -2560,7 +2569,8 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) | |||
| 2560 | int idx = -1; | 2569 | int idx = -1; |
| 2561 | Lisp_Object rest, vector; | 2570 | Lisp_Object rest, vector; |
| 2562 | 2571 | ||
| 2563 | *used_mouse_menu = 0; | 2572 | if (used_mouse_menu) |
| 2573 | *used_mouse_menu = 0; | ||
| 2564 | 2574 | ||
| 2565 | /* Use local over global Menu maps */ | 2575 | /* Use local over global Menu maps */ |
| 2566 | 2576 | ||
| @@ -2599,7 +2609,8 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) | |||
| 2599 | value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps)); | 2609 | value = Fx_popup_menu (prev_event, Flist (nmaps1, realmaps)); |
| 2600 | if (NILP (value)) | 2610 | if (NILP (value)) |
| 2601 | XSET (value, Lisp_Int, quit_char); | 2611 | XSET (value, Lisp_Int, quit_char); |
| 2602 | *used_mouse_menu = 1; | 2612 | if (used_mouse_menu) |
| 2613 | *used_mouse_menu = 1; | ||
| 2603 | return value; | 2614 | return value; |
| 2604 | } | 2615 | } |
| 2605 | #endif /* not NO_X_MENU */ | 2616 | #endif /* not NO_X_MENU */ |
| @@ -3447,7 +3458,8 @@ DEFUN ("this-command-keys", Fthis_command_keys, Sthis_command_keys, 0, 0, 0, | |||
| 3447 | "Return string of the keystrokes that invoked this command.") | 3458 | "Return string of the keystrokes that invoked this command.") |
| 3448 | () | 3459 | () |
| 3449 | { | 3460 | { |
| 3450 | return make_array (this_command_key_count, this_command_keys); | 3461 | return make_array (this_command_key_count, |
| 3462 | XVECTOR (this_command_keys)->contents); | ||
| 3451 | } | 3463 | } |
| 3452 | 3464 | ||
| 3453 | DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, | 3465 | DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0, |
| @@ -3776,10 +3788,6 @@ Optional fourth arg QUIT if non-nil specifies character to use for quitting.") | |||
| 3776 | 3788 | ||
| 3777 | init_keyboard () | 3789 | init_keyboard () |
| 3778 | { | 3790 | { |
| 3779 | this_command_keys_size = 40; | ||
| 3780 | this_command_keys = | ||
| 3781 | (Lisp_Object *) xmalloc (this_command_keys_size * sizeof (Lisp_Object)); | ||
| 3782 | |||
| 3783 | /* This is correct before outermost invocation of the editor loop */ | 3791 | /* This is correct before outermost invocation of the editor loop */ |
| 3784 | command_loop_level = -1; | 3792 | command_loop_level = -1; |
| 3785 | immediate_quit = 0; | 3793 | immediate_quit = 0; |
| @@ -3922,6 +3930,9 @@ syms_of_keyboard () | |||
| 3922 | recent_keys = Fmake_vector (make_number (NUM_RECENT_KEYS), Qnil); | 3930 | recent_keys = Fmake_vector (make_number (NUM_RECENT_KEYS), Qnil); |
| 3923 | staticpro (&recent_keys); | 3931 | staticpro (&recent_keys); |
| 3924 | 3932 | ||
| 3933 | this_command_keys = Fmake_vector (make_number (40), Qnil); | ||
| 3934 | staticpro (&recent_keys); | ||
| 3935 | |||
| 3925 | func_key_syms = Qnil; | 3936 | func_key_syms = Qnil; |
| 3926 | staticpro (&func_key_syms); | 3937 | staticpro (&func_key_syms); |
| 3927 | 3938 | ||