Mercurial > emacs
comparison src/keyboard.c @ 7168:82bb839ac5c6
(Vunread_command_events): Renamed from unread_command_events.
All uses changed.
(read_char): Don't use menus if we have events waiting.
(syms_of_keyboard): Init and staticpro accent_key_syms.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 28 Apr 1994 07:49:45 +0000 |
parents | 9e9d5db094b5 |
children | a96533ce8122 |
comparison
equal
deleted
inserted
replaced
7167:2fa74c48e4e5 | 7168:82bb839ac5c6 |
---|---|
177 | 177 |
178 /* Last input character read for any purpose. */ | 178 /* Last input character read for any purpose. */ |
179 Lisp_Object last_input_char; | 179 Lisp_Object last_input_char; |
180 | 180 |
181 /* If not Qnil, a list of objects to be read as subsequent command input. */ | 181 /* If not Qnil, a list of objects to be read as subsequent command input. */ |
182 Lisp_Object unread_command_events; | 182 Lisp_Object Vunread_command_events; |
183 | 183 |
184 /* If not -1, an event to be read as subsequent command input. */ | 184 /* If not -1, an event to be read as subsequent command input. */ |
185 int unread_command_char; | 185 int unread_command_char; |
186 | 186 |
187 /* If not Qnil, this is a switch-frame event which we decided to put | 187 /* If not Qnil, this is a switch-frame event which we decided to put |
963 echo_area_glyphs = 0; | 963 echo_area_glyphs = 0; |
964 no_direct = 1; | 964 no_direct = 1; |
965 if (!NILP (Vquit_flag)) | 965 if (!NILP (Vquit_flag)) |
966 { | 966 { |
967 Vquit_flag = Qnil; | 967 Vquit_flag = Qnil; |
968 unread_command_events = Fcons (make_number (quit_char), Qnil); | 968 Vunread_command_events = Fcons (make_number (quit_char), Qnil); |
969 } | 969 } |
970 } | 970 } |
971 | 971 |
972 #ifdef C_ALLOCA | 972 #ifdef C_ALLOCA |
973 alloca (0); /* Cause a garbage collection now */ | 973 alloca (0); /* Cause a garbage collection now */ |
1373 { | 1373 { |
1374 register Lisp_Object c; | 1374 register Lisp_Object c; |
1375 int count; | 1375 int count; |
1376 jmp_buf save_jump; | 1376 jmp_buf save_jump; |
1377 | 1377 |
1378 if (CONSP (unread_command_events)) | 1378 if (CONSP (Vunread_command_events)) |
1379 { | 1379 { |
1380 c = XCONS (unread_command_events)->car; | 1380 c = XCONS (Vunread_command_events)->car; |
1381 unread_command_events = XCONS (unread_command_events)->cdr; | 1381 Vunread_command_events = XCONS (Vunread_command_events)->cdr; |
1382 | 1382 |
1383 if (this_command_key_count == 0) | 1383 if (this_command_key_count == 0) |
1384 goto reread_first; | 1384 goto reread_first; |
1385 else | 1385 else |
1386 goto reread; | 1386 goto reread; |
1480 Try this before the sit-for, because the sit-for | 1480 Try this before the sit-for, because the sit-for |
1481 would do the wrong thing if we are supposed to do | 1481 would do the wrong thing if we are supposed to do |
1482 menu prompting. If EVENT_HAS_PARAMETERS then we are reading | 1482 menu prompting. If EVENT_HAS_PARAMETERS then we are reading |
1483 after a mouse event so don't try a minibuf menu. */ | 1483 after a mouse event so don't try a minibuf menu. */ |
1484 c = Qnil; | 1484 c = Qnil; |
1485 if (nmaps > 0 && INTERACTIVE && | 1485 if (nmaps > 0 && INTERACTIVE |
1486 !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event)) | 1486 && !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event) |
1487 /* Don't bring up a menu if we already have another event. */ | |
1488 && NILP (Vunread_command_events) | |
1489 && unread_command_char < 0 | |
1490 && EVENT_QUEUES_EMPTY) | |
1487 { | 1491 { |
1488 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); | 1492 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps); |
1489 if ( ! NILP(c) ) return c ; | 1493 if (! NILP (c)) |
1494 return c; | |
1490 } | 1495 } |
1491 | 1496 |
1492 /* If in middle of key sequence and minibuffer not active, | 1497 /* If in middle of key sequence and minibuffer not active, |
1493 start echoing if enough time elapses. */ | 1498 start echoing if enough time elapses. */ |
1494 if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0 | 1499 if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0 |
1523 Fdo_auto_save (Qnil, Qnil); | 1528 Fdo_auto_save (Qnil, Qnil); |
1524 restore_getcjmp (temp); | 1529 restore_getcjmp (temp); |
1525 } | 1530 } |
1526 | 1531 |
1527 /* Try reading using an X menu. | 1532 /* Try reading using an X menu. |
1528 This is never confused with reading using the minibuf because the recursive | 1533 This is never confused with reading using the minibuf |
1529 call of read_char in read_char_minibuf_menu_prompt does not pass on | 1534 because the recursive call of read_char in read_char_minibuf_menu_prompt |
1530 any keys maps */ | 1535 does not pass on any keymaps. */ |
1531 if (nmaps > 0 && INTERACTIVE && | 1536 if (nmaps > 0 && INTERACTIVE |
1532 !NILP (prev_event) && EVENT_HAS_PARAMETERS (prev_event)) | 1537 && !NILP (prev_event) && EVENT_HAS_PARAMETERS (prev_event) |
1538 /* Don't bring up a menu if we already have another event. */ | |
1539 && NILP (Vunread_command_events) | |
1540 && unread_command_char < 0 | |
1541 && EVENT_QUEUES_EMPTY) | |
1533 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); | 1542 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); |
1534 | 1543 |
1535 /* Slow down auto saves logarithmically in size of current buffer, | 1544 /* Slow down auto saves logarithmically in size of current buffer, |
1536 and garbage collect while we're at it. */ | 1545 and garbage collect while we're at it. */ |
1537 if (INTERACTIVE && NILP (c)) | 1546 if (INTERACTIVE && NILP (c)) |
3860 if (CONSP (value)) | 3869 if (CONSP (value)) |
3861 { | 3870 { |
3862 /* If we got more than one event, put all but the first | 3871 /* If we got more than one event, put all but the first |
3863 onto this list to be read later. | 3872 onto this list to be read later. |
3864 Return just the first event now. */ | 3873 Return just the first event now. */ |
3865 unread_command_events | 3874 Vunread_command_events |
3866 = nconc2 (XCONS (value)->cdr, unread_command_events); | 3875 = nconc2 (XCONS (value)->cdr, Vunread_command_events); |
3867 value = XCONS (value)->car; | 3876 value = XCONS (value)->car; |
3868 } | 3877 } |
3869 else if (NILP (value)) | 3878 else if (NILP (value)) |
3870 value = Qt; | 3879 value = Qt; |
3871 if (used_mouse_menu) | 3880 if (used_mouse_menu) |
3876 #endif /* HAVE_X_WINDOWS */ | 3885 #endif /* HAVE_X_WINDOWS */ |
3877 return Qnil ; | 3886 return Qnil ; |
3878 } | 3887 } |
3879 | 3888 |
3880 static Lisp_Object | 3889 static Lisp_Object |
3881 read_char_minibuf_menu_prompt(commandflag, nmaps, maps) | 3890 read_char_minibuf_menu_prompt (commandflag, nmaps, maps) |
3882 int commandflag ; | 3891 int commandflag ; |
3883 int nmaps; | 3892 int nmaps; |
3884 Lisp_Object *maps; | 3893 Lisp_Object *maps; |
3885 { | 3894 { |
3886 int mapno; | 3895 int mapno; |
5195 DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, | 5204 DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, |
5196 "T if command input is currently available with no waiting.\n\ | 5205 "T if command input is currently available with no waiting.\n\ |
5197 Actually, the value is nil only if we can be sure that no input is available.") | 5206 Actually, the value is nil only if we can be sure that no input is available.") |
5198 () | 5207 () |
5199 { | 5208 { |
5200 if (!NILP (unread_command_events) || unread_command_char != -1) | 5209 if (!NILP (Vunread_command_events) || unread_command_char != -1) |
5201 return (Qt); | 5210 return (Qt); |
5202 | 5211 |
5203 return detect_input_pending () ? Qt : Qnil; | 5212 return detect_input_pending () ? Qt : Qnil; |
5204 } | 5213 } |
5205 | 5214 |
5269 () | 5278 () |
5270 { | 5279 { |
5271 defining_kbd_macro = 0; | 5280 defining_kbd_macro = 0; |
5272 update_mode_lines++; | 5281 update_mode_lines++; |
5273 | 5282 |
5274 unread_command_events = Qnil; | 5283 Vunread_command_events = Qnil; |
5275 unread_command_char = -1; | 5284 unread_command_char = -1; |
5276 | 5285 |
5277 discard_tty_input (); | 5286 discard_tty_input (); |
5278 | 5287 |
5279 /* Without the cast, GCC complains that this assignment loses the | 5288 /* Without the cast, GCC complains that this assignment loses the |
5530 sigfree (); | 5539 sigfree (); |
5531 /* Prevent another signal from doing this before we finish. */ | 5540 /* Prevent another signal from doing this before we finish. */ |
5532 clear_waiting_for_input (); | 5541 clear_waiting_for_input (); |
5533 input_pending = 0; | 5542 input_pending = 0; |
5534 | 5543 |
5535 unread_command_events = Qnil; | 5544 Vunread_command_events = Qnil; |
5536 unread_command_char = -1; | 5545 unread_command_char = -1; |
5537 | 5546 |
5538 #ifdef POLL_FOR_INPUT | 5547 #ifdef POLL_FOR_INPUT |
5539 /* May be > 1 if in recursive minibuffer. */ | 5548 /* May be > 1 if in recursive minibuffer. */ |
5540 if (poll_suppress_count == 0) | 5549 if (poll_suppress_count == 0) |
5639 { | 5648 { |
5640 /* This is correct before outermost invocation of the editor loop */ | 5649 /* This is correct before outermost invocation of the editor loop */ |
5641 command_loop_level = -1; | 5650 command_loop_level = -1; |
5642 immediate_quit = 0; | 5651 immediate_quit = 0; |
5643 quit_char = Ctl ('g'); | 5652 quit_char = Ctl ('g'); |
5644 unread_command_events = Qnil; | 5653 Vunread_command_events = Qnil; |
5645 unread_command_char = -1; | 5654 unread_command_char = -1; |
5646 total_keys = 0; | 5655 total_keys = 0; |
5647 recent_keys_index = 0; | 5656 recent_keys_index = 0; |
5648 kbd_fetch_ptr = kbd_buffer; | 5657 kbd_fetch_ptr = kbd_buffer; |
5649 kbd_store_ptr = kbd_buffer; | 5658 kbd_store_ptr = kbd_buffer; |
5826 staticpro (&Qextended_command_history); | 5835 staticpro (&Qextended_command_history); |
5827 | 5836 |
5828 kbd_buffer_frame_or_window | 5837 kbd_buffer_frame_or_window |
5829 = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil); | 5838 = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil); |
5830 staticpro (&kbd_buffer_frame_or_window); | 5839 staticpro (&kbd_buffer_frame_or_window); |
5840 | |
5841 accent_key_syms = Qnil; | |
5842 staticpro (&accent_key_syms); | |
5831 | 5843 |
5832 func_key_syms = Qnil; | 5844 func_key_syms = Qnil; |
5833 staticpro (&func_key_syms); | 5845 staticpro (&func_key_syms); |
5834 | 5846 |
5835 system_key_syms = Qnil; | 5847 system_key_syms = Qnil; |
5875 "Last input event."); | 5887 "Last input event."); |
5876 | 5888 |
5877 DEFVAR_LISP ("last-input-event", &last_input_char, | 5889 DEFVAR_LISP ("last-input-event", &last_input_char, |
5878 "Last input event."); | 5890 "Last input event."); |
5879 | 5891 |
5880 DEFVAR_LISP ("unread-command-events", &unread_command_events, | 5892 DEFVAR_LISP ("unread-command-events", &Vunread_command_events, |
5881 "List of objects to be read as next command input events."); | 5893 "List of objects to be read as next command input events."); |
5882 | 5894 |
5883 DEFVAR_INT ("unread-command-char", &unread_command_char, | 5895 DEFVAR_INT ("unread-command-char", &unread_command_char, |
5884 "If not -1, an object to be read as next command input event."); | 5896 "If not -1, an object to be read as next command input event."); |
5885 | 5897 |