// Code for menus. Used for the GUI and 'wildmenu'. // GUI/Motif support by Robert Webb #include #include #include #include #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" #include "nvim/autocmd_defs.h" #include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cmdexpand_defs.h" #include "nvim/cursor.h" #include "nvim/errors.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/ex_docmd.h" #include "nvim/garray.h" #include "nvim/garray_defs.h" #include "nvim/getchar.h" #include "nvim/getchar_defs.h" #include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/highlight_defs.h" #include "nvim/keycodes.h" #include "nvim/macros_defs.h" #include "nvim/mbyte.h" #include "nvim/mbyte_defs.h" #include "nvim/memory.h" #include "nvim/menu.h" #include "nvim/menu_defs.h" #include "nvim/message.h" #include "nvim/option_vars.h" #include "nvim/popupmenu.h" #include "nvim/pos_defs.h" #include "nvim/state.h" #include "nvim/state_defs.h" #include "nvim/strings.h" #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/vim_defs.h" #define MENUDEPTH 10 // maximum depth of menus #ifdef INCLUDE_GENERATED_DECLARATIONS # include "menu.c.generated.h" #endif /// The character for each menu mode static char *menu_mode_chars[] = { "n", "v", "s", "o", "i", "c", "tl", "t" }; static const char e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu"); static const char e_nomenu[] = N_("E329: No menu \"%s\""); // Return true if "name" is a window toolbar menu name. static bool menu_is_winbar(const char *const name) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { return (strncmp(name, "WinBar", 6) == 0); } static vimmenu_T **get_root_menu(const char *const name) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { return &root_menu; } /// Do the :menu command and relatives. /// @param eap Ex command arguments void ex_menu(exarg_T *eap) { char *map_to; // command mapped to the menu entry int noremap; bool silent = false; bool unmenu; char *map_buf; char *p; int i; int pri_tab[MENUDEPTH + 1]; TriState enable = kNone; // kTrue for "menu enable", // kFalse for "menu disable vimmenu_T menuarg; int modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu); char *arg = eap->arg; while (true) { if (strncmp(arg, "