diff options
| author | Chong Yidong | 2006-07-26 18:13:33 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-07-26 18:13:33 +0000 |
| commit | 179f689c0ad607687b6d2d9a4bce58bf251aabcc (patch) | |
| tree | 78c3b5efe798cb53bcf95478ad00e1a746b74cd8 /src | |
| parent | 76a47494979a5d169608d2f91eb89233257133e8 (diff) | |
| download | emacs-179f689c0ad607687b6d2d9a4bce58bf251aabcc.tar.gz emacs-179f689c0ad607687b6d2d9a4bce58bf251aabcc.zip | |
* keyboard.c (read_char): New arg END_TIME specifying timeout.
All callers changed. Turn off echoing if END_TIME is non-NULL.
(kbd_buffer_get_event): New arg END_TIME.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index f6e8eadcf8c..23e10aefac1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2385,15 +2385,20 @@ do { if (polling_stopped_here) start_polling (); \ | |||
| 2385 | if we used a mouse menu to read the input, or zero otherwise. If | 2385 | if we used a mouse menu to read the input, or zero otherwise. If |
| 2386 | USED_MOUSE_MENU is null, we don't dereference it. | 2386 | USED_MOUSE_MENU is null, we don't dereference it. |
| 2387 | 2387 | ||
| 2388 | If END_TIME is non-null, it is a pointer to an EMACS_TIME | ||
| 2389 | specifying the maximum time to wait until. If no input arrives by | ||
| 2390 | that time, stop waiting and return nil. | ||
| 2391 | |||
| 2388 | Value is t if we showed a menu and the user rejected it. */ | 2392 | Value is t if we showed a menu and the user rejected it. */ |
| 2389 | 2393 | ||
| 2390 | Lisp_Object | 2394 | Lisp_Object |
| 2391 | read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | 2395 | read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, end_time) |
| 2392 | int commandflag; | 2396 | int commandflag; |
| 2393 | int nmaps; | 2397 | int nmaps; |
| 2394 | Lisp_Object *maps; | 2398 | Lisp_Object *maps; |
| 2395 | Lisp_Object prev_event; | 2399 | Lisp_Object prev_event; |
| 2396 | int *used_mouse_menu; | 2400 | int *used_mouse_menu; |
| 2401 | EMACS_TIME *end_time; | ||
| 2397 | { | 2402 | { |
| 2398 | volatile Lisp_Object c; | 2403 | volatile Lisp_Object c; |
| 2399 | int count; | 2404 | int count; |
| @@ -2673,6 +2678,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2673 | start echoing if enough time elapses. */ | 2678 | start echoing if enough time elapses. */ |
| 2674 | 2679 | ||
| 2675 | if (minibuf_level == 0 | 2680 | if (minibuf_level == 0 |
| 2681 | && !end_time | ||
| 2676 | && !current_kboard->immediate_echo | 2682 | && !current_kboard->immediate_echo |
| 2677 | && this_command_key_count > 0 | 2683 | && this_command_key_count > 0 |
| 2678 | && ! noninteractive | 2684 | && ! noninteractive |
| @@ -2855,11 +2861,19 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2855 | { | 2861 | { |
| 2856 | KBOARD *kb; | 2862 | KBOARD *kb; |
| 2857 | 2863 | ||
| 2864 | if (end_time) | ||
| 2865 | { | ||
| 2866 | EMACS_TIME now; | ||
| 2867 | EMACS_GET_TIME (now); | ||
| 2868 | if (EMACS_TIME_GE (now, *end_time)) | ||
| 2869 | goto exit; | ||
| 2870 | } | ||
| 2871 | |||
| 2858 | /* Actually read a character, waiting if necessary. */ | 2872 | /* Actually read a character, waiting if necessary. */ |
| 2859 | save_getcjmp (save_jump); | 2873 | save_getcjmp (save_jump); |
| 2860 | restore_getcjmp (local_getcjmp); | 2874 | restore_getcjmp (local_getcjmp); |
| 2861 | timer_start_idle (); | 2875 | timer_start_idle (); |
| 2862 | c = kbd_buffer_get_event (&kb, used_mouse_menu); | 2876 | c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); |
| 2863 | restore_getcjmp (save_jump); | 2877 | restore_getcjmp (save_jump); |
| 2864 | 2878 | ||
| 2865 | #ifdef MULTI_KBOARD | 2879 | #ifdef MULTI_KBOARD |
| @@ -3196,7 +3210,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 3196 | 3210 | ||
| 3197 | cancel_echoing (); | 3211 | cancel_echoing (); |
| 3198 | do | 3212 | do |
| 3199 | c = read_char (0, 0, 0, Qnil, 0); | 3213 | c = read_char (0, 0, 0, Qnil, 0, NULL); |
| 3200 | while (BUFFERP (c)); | 3214 | while (BUFFERP (c)); |
| 3201 | /* Remove the help from the frame */ | 3215 | /* Remove the help from the frame */ |
| 3202 | unbind_to (count, Qnil); | 3216 | unbind_to (count, Qnil); |
| @@ -3206,7 +3220,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 3206 | { | 3220 | { |
| 3207 | cancel_echoing (); | 3221 | cancel_echoing (); |
| 3208 | do | 3222 | do |
| 3209 | c = read_char (0, 0, 0, Qnil, 0); | 3223 | c = read_char (0, 0, 0, Qnil, 0, NULL); |
| 3210 | while (BUFFERP (c)); | 3224 | while (BUFFERP (c)); |
| 3211 | } | 3225 | } |
| 3212 | } | 3226 | } |
| @@ -3885,9 +3899,10 @@ clear_event (event) | |||
| 3885 | We always read and discard one event. */ | 3899 | We always read and discard one event. */ |
| 3886 | 3900 | ||
| 3887 | static Lisp_Object | 3901 | static Lisp_Object |
| 3888 | kbd_buffer_get_event (kbp, used_mouse_menu) | 3902 | kbd_buffer_get_event (kbp, used_mouse_menu, end_time) |
| 3889 | KBOARD **kbp; | 3903 | KBOARD **kbp; |
| 3890 | int *used_mouse_menu; | 3904 | int *used_mouse_menu; |
| 3905 | EMACS_TIME *end_time; | ||
| 3891 | { | 3906 | { |
| 3892 | register int c; | 3907 | register int c; |
| 3893 | Lisp_Object obj; | 3908 | Lisp_Object obj; |
| @@ -3931,13 +3946,24 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 3931 | if (!NILP (do_mouse_tracking) && some_mouse_moved ()) | 3946 | if (!NILP (do_mouse_tracking) && some_mouse_moved ()) |
| 3932 | break; | 3947 | break; |
| 3933 | #endif | 3948 | #endif |
| 3934 | { | 3949 | if (end_time) |
| 3950 | { | ||
| 3951 | EMACS_TIME duration; | ||
| 3952 | EMACS_GET_TIME (duration); | ||
| 3953 | EMACS_SUB_TIME (duration, *end_time, duration); | ||
| 3954 | if (EMACS_TIME_NEG_P (duration)) | ||
| 3955 | return Qnil; | ||
| 3956 | else | ||
| 3957 | wait_reading_process_output (EMACS_SECS (duration), | ||
| 3958 | EMACS_USECS (duration), | ||
| 3959 | -1, 1, Qnil, NULL, 0); | ||
| 3960 | } | ||
| 3961 | else | ||
| 3935 | wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); | 3962 | wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); |
| 3936 | 3963 | ||
| 3937 | if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) | 3964 | if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) |
| 3938 | /* Pass 1 for EXPECT since we just waited to have input. */ | 3965 | /* Pass 1 for EXPECT since we just waited to have input. */ |
| 3939 | read_avail_input (1); | 3966 | read_avail_input (1); |
| 3940 | } | ||
| 3941 | #endif /* not VMS */ | 3967 | #endif /* not VMS */ |
| 3942 | } | 3968 | } |
| 3943 | 3969 | ||
| @@ -8282,7 +8308,7 @@ read_char_minibuf_menu_prompt (commandflag, nmaps, maps) | |||
| 8282 | orig_defn_macro = current_kboard->defining_kbd_macro; | 8308 | orig_defn_macro = current_kboard->defining_kbd_macro; |
| 8283 | current_kboard->defining_kbd_macro = Qnil; | 8309 | current_kboard->defining_kbd_macro = Qnil; |
| 8284 | do | 8310 | do |
| 8285 | obj = read_char (commandflag, 0, 0, Qt, 0); | 8311 | obj = read_char (commandflag, 0, 0, Qt, 0, NULL); |
| 8286 | while (BUFFERP (obj)); | 8312 | while (BUFFERP (obj)); |
| 8287 | current_kboard->defining_kbd_macro = orig_defn_macro; | 8313 | current_kboard->defining_kbd_macro = orig_defn_macro; |
| 8288 | 8314 | ||
| @@ -8655,7 +8681,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8655 | /* Read the first char of the sequence specially, before setting | 8681 | /* Read the first char of the sequence specially, before setting |
| 8656 | up any keymaps, in case a filter runs and switches buffers on us. */ | 8682 | up any keymaps, in case a filter runs and switches buffers on us. */ |
| 8657 | first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, | 8683 | first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, |
| 8658 | &junk); | 8684 | &junk, NULL); |
| 8659 | #endif /* GOBBLE_FIRST_EVENT */ | 8685 | #endif /* GOBBLE_FIRST_EVENT */ |
| 8660 | 8686 | ||
| 8661 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); | 8687 | orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); |
| @@ -8858,7 +8884,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 8858 | #endif | 8884 | #endif |
| 8859 | key = read_char (NILP (prompt), nmaps, | 8885 | key = read_char (NILP (prompt), nmaps, |
| 8860 | (Lisp_Object *) submaps, last_nonmenu_event, | 8886 | (Lisp_Object *) submaps, last_nonmenu_event, |
| 8861 | &used_mouse_menu); | 8887 | &used_mouse_menu, NULL); |
| 8862 | } | 8888 | } |
| 8863 | 8889 | ||
| 8864 | /* read_char returns t when it shows a menu and the user rejects it. | 8890 | /* read_char returns t when it shows a menu and the user rejects it. |