[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/menu.c,v
From: |
Adrian Robert |
Subject: |
[Emacs-diffs] Changes to emacs/src/menu.c,v |
Date: |
Tue, 15 Jul 2008 18:15:47 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Adrian Robert <arobert> 08/07/15 18:15:19
Index: src/menu.c
===================================================================
RCS file: /sources/emacs/emacs/src/menu.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- src/menu.c 11 Jul 2008 11:20:21 -0000 1.7
+++ src/menu.c 15 Jul 2008 18:15:15 -0000 1.8
@@ -36,6 +36,10 @@
#include "xterm.h"
#endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
#ifdef USE_GTK
#include "gtkutil.h"
#endif
@@ -440,7 +444,7 @@
XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED],
XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]);
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) ||
defined (HAVE_NTGUI)
/* Display a submenu using the toolkit. */
if (! (NILP (map) || NILP (enabled)))
{
@@ -580,7 +584,7 @@
}
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI)
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) ||
defined (HAVE_NTGUI)
/* Allocate a widget_value, blocking input. */
@@ -956,7 +960,71 @@
}
}
-#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NTGUI */
+#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || HAVE_NTGUI */
+
+#ifdef HAVE_NS
+/* As above, but return the menu selection instead of storing in kb buffer.
+ If keymaps==1, return full prefixes to selection. */
+Lisp_Object
+find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data)
+{
+ Lisp_Object prefix, entry;
+ int i;
+ Lisp_Object *subprefix_stack;
+ int submenu_depth = 0;
+
+ prefix = entry = Qnil;
+ i = 0;
+ subprefix_stack =
+ (Lisp_Object *)alloca(menu_items_used * sizeof (Lisp_Object));
+
+ while (i < menu_items_used)
+ {
+ if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
+ {
+ subprefix_stack[submenu_depth++] = prefix;
+ prefix = entry;
+ i++;
+ }
+ else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
+ {
+ prefix = subprefix_stack[--submenu_depth];
+ i++;
+ }
+ else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
+ {
+ prefix
+ = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
+ i += MENU_ITEMS_PANE_LENGTH;
+ }
+ /* Ignore a nil in the item list.
+ It's meaningful only for dialog boxes. */
+ else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
+ i += 1;
+ else
+ {
+ entry
+ = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
+ if ((int) (EMACS_INT)client_data == i)
+ {
+ if (keymaps != 0)
+ {
+ int j;
+
+ entry = Fcons (entry, Qnil);
+ if (!NILP (prefix))
+ entry = Fcons (prefix, entry);
+ for (j = submenu_depth - 1; j >= 0; j--)
+ if (!NILP (subprefix_stack[j]))
+ entry = Fcons (subprefix_stack[j], entry);
+ }
+ return entry;
+ }
+ i += MENU_ITEMS_ITEM_LENGTH;
+ }
+ }
+}
+#endif
void
syms_of_menu ()