changeset 7098:9e9d5db094b5

(menu_bar_item): Put a list of keymaps into the third slot of an item in menu_bar_items_vector. (kbd_buffer_get_event): Handle menu_bar_event.
author Richard M. Stallman <rms@gnu.org>
date Mon, 25 Apr 1994 22:22:31 +0000
parents 34c94047f8f9
children 59c3c3a1b571
files src/keyboard.c
diffstat 1 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Mon Apr 25 22:21:43 1994 +0000
+++ b/src/keyboard.c	Mon Apr 25 22:22:31 1994 +0000
@@ -2008,6 +2008,12 @@
 	  kbd_fetch_ptr = event + 1;
 	}
 #endif
+      else if (event->kind == menu_bar_event)
+	{
+	  /* The event value is in the frame_or_window slot.  */
+	  obj = event->frame_or_window;
+	  kbd_fetch_ptr = event + 1;
+	}
       else if (event->kind == buffer_switch_event)
 	{
 	  /* The value doesn't matter here; only the type is tested.  */
@@ -3507,7 +3513,7 @@
 
 /* Return a vector of menu items for a menu bar, appropriate
    to the current buffer.  Each item has three elements in the vector:
-   KEY STRING nil.
+   KEY STRING MAPLIST.
 
    OLD is an old vector we can optionally reuse, or nil.  */
 
@@ -3645,9 +3651,7 @@
 }
 
 /* Scan one map KEYMAP, accumulating any menu items it defines
-   that have not yet been seen in RESULT.  Return the updated RESULT.
-   *OLD is the frame's old menu bar list; we swipe elts from that
-   to avoid consing.  */
+   in menu_bar_items_vector.  */
 
 static void
 menu_bar_one_keymap (keymap)
@@ -3704,6 +3708,9 @@
   return Qnil;
 }
 
+/* Add one item to menu_bar_items_vector, for KEY, ITEM_STRING and DEF.
+   If there's already an item for KEY, add this DEF to it.  */
+
 static void
 menu_bar_item (key, item_string, def)
      Lisp_Object key, item_string, def;
@@ -3714,7 +3721,7 @@
 
   if (EQ (def, Qundefined))
     {
-      /* If a map has an explicit nil as definition,
+      /* If a map has an explicit `undefined' as definition,
 	 discard any previously made menu bar item.  */
 
       for (i = 0; i < menu_bar_items_index; i += 3)
@@ -3748,12 +3755,12 @@
   if (NILP (enabled))
     return;
 
-  /* If there's already such an item, don't make another.  */
+  /* Find any existing item for this KEY.  */
   for (i = 0; i < menu_bar_items_index; i += 3)
     if (EQ (key, XVECTOR (menu_bar_items_vector)->contents[i]))
       break;
 
-  /* If we did not find this item, add it at the end.  */
+  /* If we did not find this KEY, add it at the end.  */
   if (i == menu_bar_items_index)
     {
       /* If vector is too small, get a bigger one.  */
@@ -3769,9 +3776,16 @@
       /* Add this item.  */
       XVECTOR (menu_bar_items_vector)->contents[i++] = key;
       XVECTOR (menu_bar_items_vector)->contents[i++] = item_string;
-      XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil;
+      XVECTOR (menu_bar_items_vector)->contents[i++] = Fcons (def, Qnil);
       menu_bar_items_index = i;
     }
+  /* We did find an item for this KEY.  Add DEF to its list of maps.  */
+  else
+    {
+      Lisp_Object old;
+      old = XVECTOR (menu_bar_items_vector)->contents[i + 2];
+      XVECTOR (menu_bar_items_vector)->contents[i + 2] = Fcons (def, old);
+    }
 }
 
 /* Read a character using menus based on maps in the array MAPS.