aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-11 18:52:33 +0000
committerRichard M. Stallman1994-01-11 18:52:33 +0000
commit8150596afbec8ad31a93f3efd63c4b400855382c (patch)
treefe9ef6a05c64ad31f564820805f7d293c498388d
parente917fa0784c9fdf6cb024a67be72ea1b9657522e (diff)
downloademacs-8150596afbec8ad31a93f3efd63c4b400855382c.tar.gz
emacs-8150596afbec8ad31a93f3efd63c4b400855382c.zip
(read_char_x_menu_prompt, read_char_minibuf_menu_prompt):
New functions made by dividing up read_char_menu_prompt. (read_char): Call read_char_minibuffer_menu_prompt before the sit_for if X menus are not going to be used. (read_char_minibuf_menu_prompt): Correct access to keymaps for menus when not using X menus. Only store character read in a keyboard macro if it is not the menu help character.
-rw-r--r--src/keyboard.c111
1 files changed, 88 insertions, 23 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index f1e049393c7..743bcdfccd2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -450,7 +450,8 @@ void (*keyboard_init_hook) ();
450static int read_avail_input (); 450static int read_avail_input ();
451static void get_input_pending (); 451static void get_input_pending ();
452static int readable_events (); 452static int readable_events ();
453static Lisp_Object read_char_menu_prompt (); 453static Lisp_Object read_char_x_menu_prompt ();
454static Lisp_Object read_char_minibuf_menu_prompt ();
454static Lisp_Object make_lispy_event (); 455static Lisp_Object make_lispy_event ();
455static Lisp_Object make_lispy_movement (); 456static Lisp_Object make_lispy_movement ();
456static Lisp_Object modify_event_symbol (); 457static Lisp_Object modify_event_symbol ();
@@ -1460,6 +1461,19 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1460 /* If already echoing, continue. */ 1461 /* If already echoing, continue. */
1461 echo_dash (); 1462 echo_dash ();
1462 1463
1464 /* Try reading a character via menu prompting in the minibuf.
1465 Try this before the sit-for, because the sit-for
1466 would do the wrong thing if we are supposed to do
1467 menu prompting. If EVENT_HAS_PARAMETERS then we are reading
1468 after a mouse event so don't try a minibuf menu. */
1469 c = Qnil;
1470 if (nmaps > 0 && INTERACTIVE &&
1471 !NILP (prev_event) && ! EVENT_HAS_PARAMETERS (prev_event))
1472 {
1473 c = read_char_minibuf_menu_prompt (commandflag, nmaps, maps);
1474 if ( ! NILP(c) ) return c ;
1475 }
1476
1463 /* If in middle of key sequence and minibuffer not active, 1477 /* If in middle of key sequence and minibuffer not active,
1464 start echoing if enough time elapses. */ 1478 start echoing if enough time elapses. */
1465 if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0 1479 if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0
@@ -1495,13 +1509,13 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
1495 restore_getcjmp (temp); 1509 restore_getcjmp (temp);
1496 } 1510 }
1497 1511
1498 /* Try reading a character via menu prompting. 1512 /* Try reading using an X menu.
1499 Try this before the sit-for, because the sit-for 1513 This is never confused with reading using the minibuf because the recursive
1500 would do the wrong thing if we are supposed to do 1514 call of read_char in read_char_minibuf_menu_prompt does not pass on
1501 menu prompting. */ 1515 any keys maps */
1502 c = Qnil; 1516 if (nmaps > 0 && INTERACTIVE &&
1503 if (INTERACTIVE && !NILP (prev_event)) 1517 !NILP (prev_event) && EVENT_HAS_PARAMETERS (prev_event))
1504 c = read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); 1518 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu);
1505 1519
1506 /* Slow down auto saves logarithmically in size of current buffer, 1520 /* Slow down auto saves logarithmically in size of current buffer,
1507 and garbage collect while we're at it. */ 1521 and garbage collect while we're at it. */
@@ -3573,10 +3587,16 @@ menu_bar_item (key, item_string, def, result)
3573 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone. 3587 USED_MOUSE_MENU is zero, *USED_MOUSE_MENU is left alone.
3574 3588
3575 The prompting is done based on the prompt-string of the map 3589 The prompting is done based on the prompt-string of the map
3576 and the strings associated with various map elements. */ 3590 and the strings associated with various map elements.
3591
3592 This can be done with X menus or with menus put in the minibuf.
3593 These are done in different ways, depending on how the input will be read.
3594 Menus using X are done after auto-saving in read-char, getting the input
3595 event from Fx_popup_menu; menus using the minibuf use read_char recursively
3596 and do auto-saving in the inner call of read_char. */
3577 3597
3578static Lisp_Object 3598static Lisp_Object
3579read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu) 3599read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3580 int nmaps; 3600 int nmaps;
3581 Lisp_Object *maps; 3601 Lisp_Object *maps;
3582 Lisp_Object prev_event; 3602 Lisp_Object prev_event;
@@ -3584,10 +3604,6 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3584{ 3604{
3585 int mapno; 3605 int mapno;
3586 register Lisp_Object name; 3606 register Lisp_Object name;
3587 int nlength;
3588 int width = FRAME_WIDTH (selected_frame) - 4;
3589 char *menu = (char *) alloca (width + 4);
3590 int idx = -1;
3591 Lisp_Object rest, vector; 3607 Lisp_Object rest, vector;
3592 3608
3593 if (used_mouse_menu) 3609 if (used_mouse_menu)
@@ -3645,6 +3661,38 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3645 } 3661 }
3646#endif /* HAVE_X_MENU */ 3662#endif /* HAVE_X_MENU */
3647#endif /* HAVE_X_WINDOWS */ 3663#endif /* HAVE_X_WINDOWS */
3664 return Qnil ;
3665}
3666
3667static Lisp_Object
3668read_char_minibuf_menu_prompt(commandflag, nmaps, maps)
3669 int commandflag ;
3670 int nmaps;
3671 Lisp_Object *maps;
3672{
3673 int mapno;
3674 register Lisp_Object name;
3675 int nlength;
3676 int width = FRAME_WIDTH (selected_frame) - 4;
3677 char *menu = (char *) alloca (width + 4);
3678 int idx = -1;
3679 int nobindings ;
3680 Lisp_Object rest, vector;
3681
3682 if (! menu_prompting)
3683 return Qnil;
3684
3685 /* Get the menu name from the first map that has one (a prompt string). */
3686 for (mapno = 0; mapno < nmaps; mapno++)
3687 {
3688 name = map_prompt (maps[mapno]);
3689 if (!NILP (name))
3690 break;
3691 }
3692
3693 /* If we don't have any menus, just read a character normally. */
3694 if (mapno >= nmaps)
3695 return Qnil;
3648 3696
3649 /* Prompt string always starts with map's prompt, and a space. */ 3697 /* Prompt string always starts with map's prompt, and a space. */
3650 strcpy (menu, XSTRING (name)->data); 3698 strcpy (menu, XSTRING (name)->data);
@@ -3664,6 +3712,7 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3664 int i = nlength; 3712 int i = nlength;
3665 Lisp_Object obj; 3713 Lisp_Object obj;
3666 int ch; 3714 int ch;
3715 int orig_defn_macro ;
3667 3716
3668 /* Loop over elements of map. */ 3717 /* Loop over elements of map. */
3669 while (i < width) 3718 while (i < width)
@@ -3678,10 +3727,8 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3678 or end this line if already have something on it. */ 3727 or end this line if already have something on it. */
3679 if (mapno == nmaps) 3728 if (mapno == nmaps)
3680 { 3729 {
3681 if (notfirst) 3730 mapno = 0;
3682 break; 3731 if ( notfirst || nobindings ) break;
3683 else
3684 mapno = 0;
3685 } 3732 }
3686 rest = maps[mapno]; 3733 rest = maps[mapno];
3687 } 3734 }
@@ -3703,13 +3750,16 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3703 else 3750 else
3704 { 3751 {
3705 /* An ordinary element. */ 3752 /* An ordinary element. */
3706 s = Fcar_safe (Fcdr_safe (elt)); 3753 if ( idx < 0 )
3754 s = Fcar_safe (Fcdr_safe (elt)); /* alist */
3755 else
3756 s = Fcar_safe(elt); /* vector */
3707 if (XTYPE (s) != Lisp_String) 3757 if (XTYPE (s) != Lisp_String)
3708 /* Ignore the element if it has no prompt string. */ 3758 /* Ignore the element if it has no prompt string. */
3709 ; 3759 ;
3710 /* If we have room for the prompt string, add it to this line. 3760 /* If we have room for the prompt string, add it to this line.
3711 If this is the first on the line, always add it. */ 3761 If this is the first on the line, always add it. */
3712 else if (XSTRING (s)->size + i < width 3762 else if (XSTRING (s)->size + i + 2 < width
3713 || !notfirst) 3763 || !notfirst)
3714 { 3764 {
3715 int thiswidth; 3765 int thiswidth;
@@ -3721,6 +3771,7 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3721 i += 2; 3771 i += 2;
3722 } 3772 }
3723 notfirst = 1; 3773 notfirst = 1;
3774 nobindings = 0 ;
3724 3775
3725 /* Add as much of string as fits. */ 3776 /* Add as much of string as fits. */
3726 thiswidth = XSTRING (s)->size; 3777 thiswidth = XSTRING (s)->size;
@@ -3728,6 +3779,7 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3728 thiswidth = width - i; 3779 thiswidth = width - i;
3729 bcopy (XSTRING (s)->data, menu + i, thiswidth); 3780 bcopy (XSTRING (s)->data, menu + i, thiswidth);
3730 i += thiswidth; 3781 i += thiswidth;
3782 menu[i] = 0;
3731 } 3783 }
3732 else 3784 else
3733 { 3785 {
@@ -3738,7 +3790,7 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3738 } 3790 }
3739 3791
3740 /* Move past this element. */ 3792 /* Move past this element. */
3741 if (idx >= 0 && idx + 1 >= XVECTOR (rest)->size) 3793 if (idx >= 0 && idx + 1 >= XVECTOR (vector)->size)
3742 /* Handle reaching end of dense table. */ 3794 /* Handle reaching end of dense table. */
3743 idx = -1; 3795 idx = -1;
3744 if (idx >= 0) 3796 if (idx >= 0)
@@ -3750,7 +3802,15 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3750 3802
3751 /* Prompt with that and read response. */ 3803 /* Prompt with that and read response. */
3752 message1 (menu); 3804 message1 (menu);
3753 obj = read_char (1, 0, 0, Qnil, 0); 3805
3806 /* Make believe its not a keyboard macro in case the help char
3807 is pressed. Help characters are not recorded because menu prompting
3808 is not used on replay.
3809 */
3810 orig_defn_macro = defining_kbd_macro ;
3811 defining_kbd_macro = 0 ;
3812 obj = read_char (commandflag, 0, 0, Qnil, 0);
3813 defining_kbd_macro = orig_defn_macro ;
3754 3814
3755 if (XTYPE (obj) != Lisp_Int) 3815 if (XTYPE (obj) != Lisp_Int)
3756 return obj; 3816 return obj;
@@ -3760,7 +3820,12 @@ read_char_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
3760 if (! EQ (obj, menu_prompt_more_char) 3820 if (! EQ (obj, menu_prompt_more_char)
3761 && (XTYPE (menu_prompt_more_char) != Lisp_Int 3821 && (XTYPE (menu_prompt_more_char) != Lisp_Int
3762 || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char)))))) 3822 || ! EQ (obj, make_number (Ctl (XINT (menu_prompt_more_char))))))
3763 return obj; 3823 {
3824 if ( defining_kbd_macro )
3825 store_kbd_macro_char(obj) ;
3826 return obj;
3827 }
3828 /* Help char - go round again */
3764 } 3829 }
3765} 3830}
3766 3831