diff options
Diffstat (limited to 'src/menu.c')
| -rw-r--r-- | src/menu.c | 74 |
1 files changed, 71 insertions, 3 deletions
diff --git a/src/menu.c b/src/menu.c index e8bc8de1bfc..969225d4c72 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -36,6 +36,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 36 | #include "xterm.h" | 36 | #include "xterm.h" |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | #ifdef HAVE_NS | ||
| 40 | #include "nsterm.h" | ||
| 41 | #endif | ||
| 42 | |||
| 39 | #ifdef USE_GTK | 43 | #ifdef USE_GTK |
| 40 | #include "gtkutil.h" | 44 | #include "gtkutil.h" |
| 41 | #endif | 45 | #endif |
| @@ -440,7 +444,7 @@ single_menu_item (key, item, dummy, skp_v) | |||
| 440 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], | 444 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_SELECTED], |
| 441 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); | 445 | XVECTOR (item_properties)->contents[ITEM_PROPERTY_HELP]); |
| 442 | 446 | ||
| 443 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) | 447 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI) |
| 444 | /* Display a submenu using the toolkit. */ | 448 | /* Display a submenu using the toolkit. */ |
| 445 | if (! (NILP (map) || NILP (enabled))) | 449 | if (! (NILP (map) || NILP (enabled))) |
| 446 | { | 450 | { |
| @@ -580,7 +584,7 @@ parse_single_submenu (item_key, item_name, maps) | |||
| 580 | } | 584 | } |
| 581 | 585 | ||
| 582 | 586 | ||
| 583 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) | 587 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (HAVE_NTGUI) |
| 584 | 588 | ||
| 585 | /* Allocate a widget_value, blocking input. */ | 589 | /* Allocate a widget_value, blocking input. */ |
| 586 | 590 | ||
| @@ -956,7 +960,71 @@ find_and_call_menu_selection (f, menu_bar_items_used, vector, client_data) | |||
| 956 | } | 960 | } |
| 957 | } | 961 | } |
| 958 | 962 | ||
| 959 | #endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NTGUI */ | 963 | #endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || HAVE_NTGUI */ |
| 964 | |||
| 965 | #ifdef HAVE_NS | ||
| 966 | /* As above, but return the menu selection instead of storing in kb buffer. | ||
| 967 | If keymaps==1, return full prefixes to selection. */ | ||
| 968 | Lisp_Object | ||
| 969 | find_and_return_menu_selection (FRAME_PTR f, int keymaps, void *client_data) | ||
| 970 | { | ||
| 971 | Lisp_Object prefix, entry; | ||
| 972 | int i; | ||
| 973 | Lisp_Object *subprefix_stack; | ||
| 974 | int submenu_depth = 0; | ||
| 975 | |||
| 976 | prefix = entry = Qnil; | ||
| 977 | i = 0; | ||
| 978 | subprefix_stack = | ||
| 979 | (Lisp_Object *)alloca(menu_items_used * sizeof (Lisp_Object)); | ||
| 980 | |||
| 981 | while (i < menu_items_used) | ||
| 982 | { | ||
| 983 | if (EQ (XVECTOR (menu_items)->contents[i], Qnil)) | ||
| 984 | { | ||
| 985 | subprefix_stack[submenu_depth++] = prefix; | ||
| 986 | prefix = entry; | ||
| 987 | i++; | ||
| 988 | } | ||
| 989 | else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda)) | ||
| 990 | { | ||
| 991 | prefix = subprefix_stack[--submenu_depth]; | ||
| 992 | i++; | ||
| 993 | } | ||
| 994 | else if (EQ (XVECTOR (menu_items)->contents[i], Qt)) | ||
| 995 | { | ||
| 996 | prefix | ||
| 997 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX]; | ||
| 998 | i += MENU_ITEMS_PANE_LENGTH; | ||
| 999 | } | ||
| 1000 | /* Ignore a nil in the item list. | ||
| 1001 | It's meaningful only for dialog boxes. */ | ||
| 1002 | else if (EQ (XVECTOR (menu_items)->contents[i], Qquote)) | ||
| 1003 | i += 1; | ||
| 1004 | else | ||
| 1005 | { | ||
| 1006 | entry | ||
| 1007 | = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE]; | ||
| 1008 | if ((int) (EMACS_INT)client_data == i) | ||
| 1009 | { | ||
| 1010 | if (keymaps != 0) | ||
| 1011 | { | ||
| 1012 | int j; | ||
| 1013 | |||
| 1014 | entry = Fcons (entry, Qnil); | ||
| 1015 | if (!NILP (prefix)) | ||
| 1016 | entry = Fcons (prefix, entry); | ||
| 1017 | for (j = submenu_depth - 1; j >= 0; j--) | ||
| 1018 | if (!NILP (subprefix_stack[j])) | ||
| 1019 | entry = Fcons (subprefix_stack[j], entry); | ||
| 1020 | } | ||
| 1021 | return entry; | ||
| 1022 | } | ||
| 1023 | i += MENU_ITEMS_ITEM_LENGTH; | ||
| 1024 | } | ||
| 1025 | } | ||
| 1026 | } | ||
| 1027 | #endif | ||
| 960 | 1028 | ||
| 961 | void | 1029 | void |
| 962 | syms_of_menu () | 1030 | syms_of_menu () |