diff options
| author | Jim Blandy | 1992-11-16 00:44:13 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-11-16 00:44:13 +0000 |
| commit | 8f805655d50508e04b80e5cd37b5f4f40b4098c7 (patch) | |
| tree | 73f47c5e6f1362bc8436207bd37173276260fd35 /src | |
| parent | c77d647ec8d6231214e952aeb216190e0cd42266 (diff) | |
| download | emacs-8f805655d50508e04b80e5cd37b5f4f40b4098c7.tar.gz emacs-8f805655d50508e04b80e5cd37b5f4f40b4098c7.zip | |
* keyboard.c (unread_switch_frame): Don't declare this static.
* keyboard.c (Vlast_event_frame): Doc fix.
* keyboard.c (read_char): Write composite events to the dribble
file properly.
* keyboard.c (init_keyboard): Initialize Vlast_event_frame to
Qnil, rather than the selected frame.
* keyboard.c (lispy_modifier_list): Added sanity check before
indexing into modifier_symbols.
* keyboard.c (add_command_key): When copying the contents of the
old this_command_keys to new_keys, remember to multiply size by
sizeof (Lisp_Object) to get the amount we really need to copy.
Rename unread_command_char to unread_command_event; it has
subtly different semantics now, and we should use
`make-obsolete-variable' to warn people.
* keyboard.c (unread_command_char): Rename.
(command_loop_1, read_char, Finput_pending, Fdiscard_input,
quit_throw_to_read_char, init_keyboard, syms_of_keyboard): Change
references.
* keyboard.c (read_key_sequence): Don't use
save_excursion_{save,restore} to protect the caller against buffer
switches; use Fset_buffer and Fcurrent_buffer; redisplay might
change point, and we don't want to undo that.
* keyboard.c (kbd_buffer_get_event): When checking a mouse
movement for a frame switch, don't assume Vlast_event_frame
contains a Lisp_Frame object.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index f816a2b97c6..a9e73d2995c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -153,14 +153,16 @@ Lisp_Object last_nonmenu_event; | |||
| 153 | Lisp_Object last_input_char; | 153 | Lisp_Object last_input_char; |
| 154 | 154 | ||
| 155 | /* If not Qnil, an object to be read as the next command input. */ | 155 | /* If not Qnil, an object to be read as the next command input. */ |
| 156 | Lisp_Object unread_command_char; | 156 | Lisp_Object unread_command_event; |
| 157 | 157 | ||
| 158 | /* If not Qnil, this is a switch-frame event which we decided to put | 158 | /* If not Qnil, this is a switch-frame event which we decided to put |
| 159 | off until the end of a key sequence. This should be read as the | 159 | off until the end of a key sequence. This should be read as the |
| 160 | next command input, after any unread_command_char. Only | 160 | next command input, after any unread_command_event. |
| 161 | read_key_sequence sets this; it uses it to delay switch-frame | 161 | |
| 162 | events until the end of the key sequence. */ | 162 | read_key_sequence uses this to delay switch-frame events until the |
| 163 | static Lisp_Object unread_switch_frame; | 163 | end of the key sequence; Fread_char uses it to put off switch-frame |
| 164 | events until a non-ASCII event is acceptable as input. */ | ||
| 165 | Lisp_Object unread_switch_frame; | ||
| 164 | 166 | ||
| 165 | /* Char to use as prefix when a meta character is typed in. | 167 | /* Char to use as prefix when a meta character is typed in. |
| 166 | This is bound on entry to minibuffer in case ESC is changed there. */ | 168 | This is bound on entry to minibuffer in case ESC is changed there. */ |
| @@ -200,11 +202,7 @@ Lisp_Object this_command; | |||
| 200 | 202 | ||
| 201 | #ifdef MULTI_FRAME | 203 | #ifdef MULTI_FRAME |
| 202 | /* The frame in which the last input event occurred, or Qmacro if the | 204 | /* The frame in which the last input event occurred, or Qmacro if the |
| 203 | last event came from a macro. | 205 | last event came from a macro. */ |
| 204 | command_loop_1 will select this frame before running the | ||
| 205 | command bound to an event sequence, and read_key_sequence will | ||
| 206 | toss the existing prefix if the user starts typing at a | ||
| 207 | new frame. */ | ||
| 208 | Lisp_Object Vlast_event_frame; | 206 | Lisp_Object Vlast_event_frame; |
| 209 | #endif | 207 | #endif |
| 210 | 208 | ||
| @@ -533,7 +531,7 @@ add_command_key (key) | |||
| 533 | 531 | ||
| 534 | bcopy (XVECTOR (this_command_keys)->contents, | 532 | bcopy (XVECTOR (this_command_keys)->contents, |
| 535 | XVECTOR (new_keys)->contents, | 533 | XVECTOR (new_keys)->contents, |
| 536 | size); | 534 | size * sizeof (Lisp_Object)); |
| 537 | 535 | ||
| 538 | this_command_keys = new_keys; | 536 | this_command_keys = new_keys; |
| 539 | } | 537 | } |
| @@ -846,7 +844,7 @@ command_loop_1 () | |||
| 846 | if (!NILP (Vquit_flag)) | 844 | if (!NILP (Vquit_flag)) |
| 847 | { | 845 | { |
| 848 | Vquit_flag = Qnil; | 846 | Vquit_flag = Qnil; |
| 849 | unread_command_char = make_number (quit_char); | 847 | unread_command_event = make_number (quit_char); |
| 850 | } | 848 | } |
| 851 | } | 849 | } |
| 852 | 850 | ||
| @@ -855,20 +853,23 @@ command_loop_1 () | |||
| 855 | /* Since we can free the most stuff here. */ | 853 | /* Since we can free the most stuff here. */ |
| 856 | #endif /* C_ALLOCA */ | 854 | #endif /* C_ALLOCA */ |
| 857 | 855 | ||
| 858 | /* Read next key sequence; i gets its length. */ | 856 | #if 0 |
| 859 | i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0); | ||
| 860 | |||
| 861 | ++num_input_keys; | ||
| 862 | |||
| 863 | #if 0 /* This shouldn't be necessary, now that we have switch-frame events. */ | ||
| 864 | #ifdef MULTI_FRAME | 857 | #ifdef MULTI_FRAME |
| 865 | /* Select the frame that the key sequence came from. */ | 858 | /* Select the frame that the last event came from. Usually, |
| 859 | switch-frame events will take care of this, but if some lisp | ||
| 860 | code swallows a switch-frame event, we'll fix things up here. | ||
| 861 | Is this a good idea? */ | ||
| 866 | if (XTYPE (Vlast_event_frame) == Lisp_Frame | 862 | if (XTYPE (Vlast_event_frame) == Lisp_Frame |
| 867 | && XFRAME (Vlast_event_frame) != selected_frame) | 863 | && XFRAME (Vlast_event_frame) != selected_frame) |
| 868 | Fselect_frame (Vlast_event_frame, Qnil); | 864 | Fselect_frame (Vlast_event_frame, Qnil); |
| 869 | #endif | 865 | #endif |
| 870 | #endif | 866 | #endif |
| 871 | 867 | ||
| 868 | /* Read next key sequence; i gets its length. */ | ||
| 869 | i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), 0); | ||
| 870 | |||
| 871 | ++num_input_keys; | ||
| 872 | |||
| 872 | /* Now we have read a key sequence of length I, | 873 | /* Now we have read a key sequence of length I, |
| 873 | or else I is 0 and we found end of file. */ | 874 | or else I is 0 and we found end of file. */ |
| 874 | 875 | ||
| @@ -1121,10 +1122,10 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1121 | int count; | 1122 | int count; |
| 1122 | jmp_buf save_jump; | 1123 | jmp_buf save_jump; |
| 1123 | 1124 | ||
| 1124 | if (!NILP (unread_command_char)) | 1125 | if (!NILP (unread_command_event)) |
| 1125 | { | 1126 | { |
| 1126 | c = unread_command_char; | 1127 | c = unread_command_event; |
| 1127 | unread_command_char = Qnil; | 1128 | unread_command_event = Qnil; |
| 1128 | 1129 | ||
| 1129 | if (this_command_key_count == 0) | 1130 | if (this_command_key_count == 0) |
| 1130 | goto reread_first; | 1131 | goto reread_first; |
| @@ -1331,11 +1332,11 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1331 | /* If it's a structured event, take the event header. */ | 1332 | /* If it's a structured event, take the event header. */ |
| 1332 | dribblee = EVENT_HEAD (dribblee); | 1333 | dribblee = EVENT_HEAD (dribblee); |
| 1333 | 1334 | ||
| 1334 | if (XTYPE (c) == Lisp_Symbol) | 1335 | if (XTYPE (dribblee) == Lisp_Symbol) |
| 1335 | { | 1336 | { |
| 1336 | putc ('<', dribble); | 1337 | putc ('<', dribble); |
| 1337 | fwrite (XSYMBOL (c)->name->data, sizeof (char), | 1338 | fwrite (XSYMBOL (dribblee)->name->data, sizeof (char), |
| 1338 | XSYMBOL (c)->name->size, | 1339 | XSYMBOL (dribblee)->name->size, |
| 1339 | dribble); | 1340 | dribble); |
| 1340 | putc ('>', dribble); | 1341 | putc ('>', dribble); |
| 1341 | } | 1342 | } |
| @@ -1643,7 +1644,9 @@ kbd_buffer_get_event () | |||
| 1643 | #ifdef MULTI_FRAME | 1644 | #ifdef MULTI_FRAME |
| 1644 | /* Decide if we should generate a switch-frame event. Don't generate | 1645 | /* Decide if we should generate a switch-frame event. Don't generate |
| 1645 | switch-frame events for motion outside of all Emacs frames. */ | 1646 | switch-frame events for motion outside of all Emacs frames. */ |
| 1646 | if (frame && frame != XFRAME (Vlast_event_frame)) | 1647 | if (frame |
| 1648 | && (XTYPE (Vlast_event_frame) != Lisp_Frame | ||
| 1649 | || frame != XFRAME (Vlast_event_frame))) | ||
| 1647 | { | 1650 | { |
| 1648 | XSET (Vlast_event_frame, Lisp_Frame, frame); | 1651 | XSET (Vlast_event_frame, Lisp_Frame, frame); |
| 1649 | obj = make_lispy_switch_frame (Vlast_event_frame); | 1652 | obj = make_lispy_switch_frame (Vlast_event_frame); |
| @@ -2135,8 +2138,12 @@ lispy_modifier_list (modifiers) | |||
| 2135 | modifier_list = Qnil; | 2138 | modifier_list = Qnil; |
| 2136 | for (i = 0; (1<<i) <= modifiers; i++) | 2139 | for (i = 0; (1<<i) <= modifiers; i++) |
| 2137 | if (modifiers & (1<<i)) | 2140 | if (modifiers & (1<<i)) |
| 2138 | modifier_list = Fcons (XVECTOR (modifier_symbols)->contents[i], | 2141 | { |
| 2139 | modifier_list); | 2142 | if (i >= XVECTOR (modifier_symbols)->size) |
| 2143 | abort (); | ||
| 2144 | modifier_list = Fcons (XVECTOR (modifier_symbols)->contents[i], | ||
| 2145 | modifier_list); | ||
| 2146 | } | ||
| 2140 | 2147 | ||
| 2141 | return modifier_list; | 2148 | return modifier_list; |
| 2142 | } | 2149 | } |
| @@ -2945,8 +2952,12 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 2945 | fkey_start = fkey_end = bufsize + 1; | 2952 | fkey_start = fkey_end = bufsize + 1; |
| 2946 | 2953 | ||
| 2947 | /* We need to save the current buffer in case we switch buffers to | 2954 | /* We need to save the current buffer in case we switch buffers to |
| 2948 | find the right binding for a mouse click. */ | 2955 | find the right binding for a mouse click. Note that we can't use |
| 2949 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 2956 | save_excursion_{save,restore} here, because they save point as |
| 2957 | well as the current buffer; we don't want to save point, because | ||
| 2958 | redisplay may change it, to accomodate a Fset_window_start or | ||
| 2959 | something. */ | ||
| 2960 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | ||
| 2950 | 2961 | ||
| 2951 | last_nonmenu_event = Qnil; | 2962 | last_nonmenu_event = Qnil; |
| 2952 | 2963 | ||
| @@ -3490,7 +3501,7 @@ DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, | |||
| 3490 | Actually, the value is nil only if we can be sure that no input is available.") | 3501 | Actually, the value is nil only if we can be sure that no input is available.") |
| 3491 | () | 3502 | () |
| 3492 | { | 3503 | { |
| 3493 | if (!NILP (unread_command_char)) | 3504 | if (!NILP (unread_command_event)) |
| 3494 | return (Qt); | 3505 | return (Qt); |
| 3495 | 3506 | ||
| 3496 | return detect_input_pending () ? Qt : Qnil; | 3507 | return detect_input_pending () ? Qt : Qnil; |
| @@ -3562,7 +3573,7 @@ Also cancel any kbd macro being defined.") | |||
| 3562 | defining_kbd_macro = 0; | 3573 | defining_kbd_macro = 0; |
| 3563 | update_mode_lines++; | 3574 | update_mode_lines++; |
| 3564 | 3575 | ||
| 3565 | unread_command_char = Qnil; | 3576 | unread_command_event = Qnil; |
| 3566 | 3577 | ||
| 3567 | discard_tty_input (); | 3578 | discard_tty_input (); |
| 3568 | 3579 | ||
| @@ -3802,7 +3813,7 @@ quit_throw_to_read_char () | |||
| 3802 | clear_waiting_for_input (); | 3813 | clear_waiting_for_input (); |
| 3803 | input_pending = 0; | 3814 | input_pending = 0; |
| 3804 | 3815 | ||
| 3805 | unread_command_char = Qnil; | 3816 | unread_command_event = Qnil; |
| 3806 | 3817 | ||
| 3807 | _longjmp (getcjmp, 1); | 3818 | _longjmp (getcjmp, 1); |
| 3808 | } | 3819 | } |
| @@ -3856,7 +3867,7 @@ init_keyboard () | |||
| 3856 | command_loop_level = -1; | 3867 | command_loop_level = -1; |
| 3857 | immediate_quit = 0; | 3868 | immediate_quit = 0; |
| 3858 | quit_char = Ctl ('g'); | 3869 | quit_char = Ctl ('g'); |
| 3859 | unread_command_char = Qnil; | 3870 | unread_command_event = Qnil; |
| 3860 | total_keys = 0; | 3871 | total_keys = 0; |
| 3861 | recent_keys_index = 0; | 3872 | recent_keys_index = 0; |
| 3862 | kbd_fetch_ptr = kbd_buffer; | 3873 | kbd_fetch_ptr = kbd_buffer; |
| @@ -3865,9 +3876,9 @@ init_keyboard () | |||
| 3865 | input_pending = 0; | 3876 | input_pending = 0; |
| 3866 | 3877 | ||
| 3867 | #ifdef MULTI_FRAME | 3878 | #ifdef MULTI_FRAME |
| 3868 | /* This means that we don't get a switch-frame event before the first | 3879 | /* This means that command_loop_1 won't try to select anything the first |
| 3869 | character typed. */ | 3880 | time through. */ |
| 3870 | XSET (Vlast_event_frame, Lisp_Frame, selected_frame); | 3881 | Vlast_event_frame = Qnil; |
| 3871 | #endif | 3882 | #endif |
| 3872 | 3883 | ||
| 3873 | if (!noninteractive) | 3884 | if (!noninteractive) |
| @@ -4046,7 +4057,7 @@ so that you can determine whether the command was run by mouse or not."); | |||
| 4046 | DEFVAR_LISP ("last-input-char", &last_input_char, | 4057 | DEFVAR_LISP ("last-input-char", &last_input_char, |
| 4047 | "Last terminal input key."); | 4058 | "Last terminal input key."); |
| 4048 | 4059 | ||
| 4049 | DEFVAR_LISP ("unread-command-char", &unread_command_char, | 4060 | DEFVAR_LISP ("unread-command-event", &unread_command_event, |
| 4050 | "Object to be read as next input from input stream, or nil if none."); | 4061 | "Object to be read as next input from input stream, or nil if none."); |
| 4051 | 4062 | ||
| 4052 | DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, | 4063 | DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, |