// 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/vim.h" #include "nvim/ascii.h" #include "nvim/menu.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/eval.h" #include "nvim/ex_docmd.h" #include "nvim/getchar.h" #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/misc1.h" #include "nvim/keymap.h" #include "nvim/garray.h" #include "nvim/state.h" #include "nvim/strings.h" #include "nvim/ui.h" #include "nvim/eval/typval.h" #include "nvim/screen.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_u menu_mode_chars[] = { 'n', 'v', 's', 'o', 'i', 'c', 't' }; static char_u e_notsubmenu[] = N_( "E327: Part of menu-item path is not sub-menu"); static char_u e_othermode[] = N_("E328: Menu only exists in another mode"); static char_u e_nomenu[] = N_("E329: No menu \"%s\""); // Return true if "name" is a window toolbar menu name. static bool menu_is_winbar(const char_u *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_u *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_u *menu_path; int modes; char_u *map_to; // command mapped to the menu entry int noremap; bool silent = false; int unmenu; char_u *map_buf; char_u *arg; char_u *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((char *)eap->cmd, eap->forceit, &noremap, &unmenu); arg = eap->arg; for (;; ) { if (STRNCMP(arg, "