comparison src/keyboard.c @ 38674:8e0b0d76380a

(read_key_sequence): Check that key is an integer before comparing it with quit_char. (add_command_key): Use larger_vector. (read_char_x_menu_prompt): Instead of converting symbol and integer events into conses (EVENT . nil), use (EVENT . disabled) which cannot be confused with legal events. (read_char): When reading from Vunread_command_events, check for events of the form (EVENT . disabled) instead of (EVENT . nil).
author Gerd Moellmann <gerd@gnu.org>
date Fri, 03 Aug 2001 11:36:48 +0000
parents 61636b8db232
children ea3e88f0c205
comparison
equal deleted inserted replaced
38673:fb0d03516662 38674:8e0b0d76380a
883 /* Functions for manipulating this_command_keys. */ 883 /* Functions for manipulating this_command_keys. */
884 static void 884 static void
885 add_command_key (key) 885 add_command_key (key)
886 Lisp_Object key; 886 Lisp_Object key;
887 { 887 {
888 int size = XVECTOR (this_command_keys)->size;
889
890 /* If reset-this-command-length was called recently, obey it now. 888 /* If reset-this-command-length was called recently, obey it now.
891 See the doc string of that function for an explanation of why. */ 889 See the doc string of that function for an explanation of why. */
892 if (before_command_restore_flag) 890 if (before_command_restore_flag)
893 { 891 {
894 this_command_key_count = before_command_key_count_1; 892 this_command_key_count = before_command_key_count_1;
896 this_single_command_key_start = this_command_key_count; 894 this_single_command_key_start = this_command_key_count;
897 echo_truncate (before_command_echo_length_1); 895 echo_truncate (before_command_echo_length_1);
898 before_command_restore_flag = 0; 896 before_command_restore_flag = 0;
899 } 897 }
900 898
901 if (this_command_key_count >= size) 899 if (this_command_key_count >= ASIZE (this_command_keys))
902 { 900 this_command_keys = larger_vector (this_command_keys,
903 Lisp_Object new_keys; 901 2 * ASIZE (this_command_keys),
904 902 Qnil);
905 new_keys = Fmake_vector (make_number (size * 2), Qnil); 903
906 bcopy (XVECTOR (this_command_keys)->contents, 904 AREF (this_command_keys, this_command_key_count) = key;
907 XVECTOR (new_keys)->contents, 905 ++this_command_key_count;
908 size * sizeof (Lisp_Object)); 906 }
909 907
910 this_command_keys = new_keys;
911 }
912
913 XVECTOR (this_command_keys)->contents[this_command_key_count++] = key;
914 }
915 908
916 Lisp_Object 909 Lisp_Object
917 recursive_edit_1 () 910 recursive_edit_1 ()
918 { 911 {
919 int count = specpdl_ptr - specpdl; 912 int count = specpdl_ptr - specpdl;
2147 Vunread_command_events = XCDR (Vunread_command_events); 2140 Vunread_command_events = XCDR (Vunread_command_events);
2148 2141
2149 /* Undo what read_char_x_menu_prompt did when it unread 2142 /* Undo what read_char_x_menu_prompt did when it unread
2150 additional keys returned by Fx_popup_menu. */ 2143 additional keys returned by Fx_popup_menu. */
2151 if (CONSP (c) 2144 if (CONSP (c)
2152 && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c))) 2145 && EQ (XCDR (c), Qdisabled)
2153 && NILP (XCDR (c))) 2146 && (SYMBOLP (XCAR (c)) || INTEGERP (XCAR (c))))
2154 c = XCAR (c); 2147 c = XCAR (c);
2155 2148
2156 /* If the queued event is something that used the mouse, 2149 /* If the queued event is something that used the mouse,
2157 set used_mouse_menu accordingly. */ 2150 set used_mouse_menu accordingly. */
2158 if (used_mouse_menu 2151 if (used_mouse_menu
2159 && (EQ (c, Qtool_bar) || EQ (c, Qmenu_bar))) 2152 && (EQ (c, Qtool_bar) || EQ (c, Qmenu_bar)))
2160 *used_mouse_menu = 1; 2153 *used_mouse_menu = 1;
7419 from showing up later in last_nonmenu_event. 7412 from showing up later in last_nonmenu_event.
7420 So turn symbol and integer events into lists, 7413 So turn symbol and integer events into lists,
7421 to indicate that they came from a mouse menu, 7414 to indicate that they came from a mouse menu,
7422 so that when present in last_nonmenu_event 7415 so that when present in last_nonmenu_event
7423 they won't confuse things. */ 7416 they won't confuse things. */
7424 for (tem = XCDR (value); !NILP (tem); 7417 for (tem = XCDR (value); !NILP (tem); tem = XCDR (tem))
7425 tem = XCDR (tem))
7426 { 7418 {
7427 record_menu_key (XCAR (tem)); 7419 record_menu_key (XCAR (tem));
7428 if (SYMBOLP (XCAR (tem)) 7420 if (SYMBOLP (XCAR (tem))
7429 || INTEGERP (XCAR (tem))) 7421 || INTEGERP (XCAR (tem)))
7430 XCAR (tem) 7422 XCAR (tem) = Fcons (XCAR (tem), Qdisabled);
7431 = Fcons (XCAR (tem), Qnil);
7432 } 7423 }
7433 7424
7434 /* If we got more than one event, put all but the first 7425 /* If we got more than one event, put all but the first
7435 onto this list to be read later. 7426 onto this list to be read later.
7436 Return just the first event now. */ 7427 Return just the first event now. */
8181 } 8172 }
8182 8173
8183 /* If we have a quit that was typed in another frame, and 8174 /* If we have a quit that was typed in another frame, and
8184 quit_throw_to_read_char switched buffers, 8175 quit_throw_to_read_char switched buffers,
8185 replay to get the right keymap. */ 8176 replay to get the right keymap. */
8186 if (XINT (key) == quit_char && current_buffer != starting_buffer) 8177 if (INTEGERP (key)
8178 && XINT (key) == quit_char
8179 && current_buffer != starting_buffer)
8187 { 8180 {
8188 GROW_RAW_KEYBUF; 8181 GROW_RAW_KEYBUF;
8189 XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; 8182 XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key;
8190 keybuf[t++] = key; 8183 keybuf[t++] = key;
8191 mock_input = t; 8184 mock_input = t;