// This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com // Code for menus. Used for the GUI and 'wildmenu'. // GUI/Motif support by Robert Webb #include #include #include #include "nvim/ascii.h" #include "nvim/autocmd.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/ex_docmd.h" #include "nvim/garray.h" #include "nvim/getchar.h" #include "nvim/keycodes.h" #include "nvim/memory.h" #include "nvim/menu.h" #include "nvim/message.h" #include "nvim/popupmenu.h" #include "nvim/screen.h" #include "nvim/state.h" #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/vim.h" #include "nvim/window.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 char e_notsubmenu[] = N_("E327: Part of menu-item path is not sub-menu"); static 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 *menu_path; int modes; char *map_to; // command mapped to the menu entry int noremap; bool silent = false; int unmenu; char *map_buf; char *arg; char *p; int i; long pri_tab[MENUDEPTH + 1]; TriState enable = kNone; // kTrue for "menu enable", // kFalse for "menu disable vimmenu_T menuarg; modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu); arg = eap->arg; for (;;) { if (STRNCMP(arg, "