diff options
| author | Richard M. Stallman | 1993-07-15 06:56:17 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-15 06:56:17 +0000 |
| commit | dcc408a053ec3e094a52f30a7f502c561209ae7b (patch) | |
| tree | b47f657a07a4ac3ef9bc52d1d81e8748aaf75392 /src | |
| parent | e3a39644f2221d86803f4d1cb72c1011315837c2 (diff) | |
| download | emacs-dcc408a053ec3e094a52f30a7f502c561209ae7b.tar.gz emacs-dcc408a053ec3e094a52f30a7f502c561209ae7b.zip | |
(read_char_menu_prompt): If the user rejects a menu,
return t. This makes read_char also return t.
(read_key_sequence): If read_char returned t, return -1.
(Fread_key_sequence): If read_key_sequence returned -1, quit.
(command_loop_1): If read_key_sequence returned -1, loop around.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index c840979c88f..60c44d55f89 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -990,6 +990,14 @@ command_loop_1 () | |||
| 990 | 990 | ||
| 991 | if (i == 0) /* End of file -- happens only in */ | 991 | if (i == 0) /* End of file -- happens only in */ |
| 992 | return Qnil; /* a kbd macro, at the end. */ | 992 | return Qnil; /* a kbd macro, at the end. */ |
| 993 | /* -1 means read_key_sequence got a menu that was rejected. | ||
| 994 | Just loop around and read another command. */ | ||
| 995 | if (i == -1) | ||
| 996 | { | ||
| 997 | cancel_echoing (); | ||
| 998 | this_command_key_count = 0; | ||
| 999 | continue; | ||
| 1000 | } | ||
| 993 | 1001 | ||
| 994 | last_command_char = keybuf[i - 1]; | 1002 | last_command_char = keybuf[i - 1]; |
| 995 | 1003 | ||
| @@ -1296,7 +1304,9 @@ static Lisp_Object kbd_buffer_get_event (); | |||
| 1296 | 1304 | ||
| 1297 | If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 | 1305 | If USED_MOUSE_MENU is non-zero, then we set *USED_MOUSE_MENU to 1 |
| 1298 | if we used a mouse menu to read the input, or zero otherwise. If | 1306 | if we used a mouse menu to read the input, or zero otherwise. If |
| 1299 | USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. */ | 1307 | USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. |
| 1308 | |||
| 1309 | Value is t if we showed a menu and the user rejected it. */ | ||
| 1300 | 1310 | ||
| 1301 | Lisp_Object | 1311 | Lisp_Object |
| 1302 | read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | 1312 | read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) |
| @@ -3303,10 +3313,9 @@ menu_bar_item (key, item_string, def, result) | |||
| 3303 | static int echo_flag; | 3313 | static int echo_flag; |
| 3304 | static int echo_now; | 3314 | static int echo_now; |
| 3305 | 3315 | ||
| 3306 | /* Read a character like read_char but optionally prompt based on maps | 3316 | /* Read a character using menus based on maps in the array MAPS. |
| 3307 | in the array MAPS. NMAPS is the length of MAPS. Return nil if we | 3317 | NMAPS is the length of MAPS. Return nil if there are no menus in the maps. |
| 3308 | decided not to read a character, because there are no menu items in | 3318 | Return t if we displayed a menu but the user rejected it. |
| 3309 | MAPS. | ||
| 3310 | 3319 | ||
| 3311 | PREV_EVENT is the previous input event, or nil if we are reading | 3320 | PREV_EVENT is the previous input event, or nil if we are reading |
| 3312 | the first event of a key sequence. | 3321 | the first event of a key sequence. |
| @@ -3381,7 +3390,7 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) | |||
| 3381 | value = XCONS (value)->car; | 3390 | value = XCONS (value)->car; |
| 3382 | } | 3391 | } |
| 3383 | if (NILP (value)) | 3392 | if (NILP (value)) |
| 3384 | XSET (value, Lisp_Int, quit_char); | 3393 | value = Qt; |
| 3385 | if (used_mouse_menu) | 3394 | if (used_mouse_menu) |
| 3386 | *used_mouse_menu = 1; | 3395 | *used_mouse_menu = 1; |
| 3387 | return value; | 3396 | return value; |
| @@ -3612,6 +3621,7 @@ follow_key (key, nmaps, current, defs, next) | |||
| 3612 | storing it in KEYBUF, a buffer of size BUFSIZE. | 3621 | storing it in KEYBUF, a buffer of size BUFSIZE. |
| 3613 | Prompt with PROMPT. | 3622 | Prompt with PROMPT. |
| 3614 | Return the length of the key sequence stored. | 3623 | Return the length of the key sequence stored. |
| 3624 | Return -1 if the user rejected a command menu. | ||
| 3615 | 3625 | ||
| 3616 | Echo starting immediately unless `prompt' is 0. | 3626 | Echo starting immediately unless `prompt' is 0. |
| 3617 | 3627 | ||
| @@ -3850,6 +3860,11 @@ read_key_sequence (keybuf, bufsize, prompt) | |||
| 3850 | key = read_char (!prompt, nmaps, submaps, last_nonmenu_event, | 3860 | key = read_char (!prompt, nmaps, submaps, last_nonmenu_event, |
| 3851 | &used_mouse_menu); | 3861 | &used_mouse_menu); |
| 3852 | 3862 | ||
| 3863 | /* read_char returns t when it shows a menu and the user rejects it. | ||
| 3864 | Just return -1. */ | ||
| 3865 | if (EQ (key, Qt)) | ||
| 3866 | return -1; | ||
| 3867 | |||
| 3853 | /* read_char returns -1 at the end of a macro. | 3868 | /* read_char returns -1 at the end of a macro. |
| 3854 | Emacs 18 handles this by returning immediately with a | 3869 | Emacs 18 handles this by returning immediately with a |
| 3855 | zero, so that's what we'll do. */ | 3870 | zero, so that's what we'll do. */ |
| @@ -4257,6 +4272,11 @@ sequences, where they wouldn't conflict with ordinary bindings. See\n\ | |||
| 4257 | i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), | 4272 | i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])), |
| 4258 | NILP (prompt) ? 0 : XSTRING (prompt)->data); | 4273 | NILP (prompt) ? 0 : XSTRING (prompt)->data); |
| 4259 | 4274 | ||
| 4275 | if (i == -1) | ||
| 4276 | { | ||
| 4277 | Vquit_flag = Qt; | ||
| 4278 | QUIT; | ||
| 4279 | } | ||
| 4260 | UNGCPRO; | 4280 | UNGCPRO; |
| 4261 | return make_event_array (i, keybuf); | 4281 | return make_event_array (i, keybuf); |
| 4262 | } | 4282 | } |