menu: enable in ex_menu() is TriState

This commit is contained in:
Jan Edmund Lazo 2018-07-16 02:48:04 -04:00
parent f193b5241f
commit f35df8d697

View File

@ -63,8 +63,8 @@ ex_menu(exarg_T *eap)
char_u *p;
int i;
long pri_tab[MENUDEPTH + 1];
int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu
* disable */
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);
@ -133,10 +133,10 @@ ex_menu(exarg_T *eap)
* Check for "disable" or "enable" argument.
*/
if (STRNCMP(arg, "enable", 6) == 0 && ascii_iswhite(arg[6])) {
enable = TRUE;
enable = kTrue;
arg = skipwhite(arg + 6);
} else if (STRNCMP(arg, "disable", 7) == 0 && ascii_iswhite(arg[7])) {
enable = FALSE;
enable = kFalse;
arg = skipwhite(arg + 7);
}
@ -160,22 +160,21 @@ ex_menu(exarg_T *eap)
/*
* If there is only a menu name, display menus with that name.
*/
if (*map_to == NUL && !unmenu && enable == MAYBE) {
if (*map_to == NUL && !unmenu && enable == kNone) {
show_menus(menu_path, modes);
goto theend;
} else if (*map_to != NUL && (unmenu || enable != MAYBE)) {
} else if (*map_to != NUL && (unmenu || enable != kNone)) {
EMSG(_(e_trailing));
goto theend;
}
if (enable != MAYBE) {
/*
* Change sensitivity of the menu.
* For the PopUp menu, remove a menu for each mode separately.
* Careful: menu_nable_recurse() changes menu_path.
*/
if (STRCMP(menu_path, "*") == 0) /* meaning: do all menus */
if (enable != kNone) {
// Change sensitivity of the menu.
// For the PopUp menu, remove a menu for each mode separately.
// Careful: menu_nable_recurse() changes menu_path.
if (STRCMP(menu_path, "*") == 0) { // meaning: do all menus
menu_path = (char_u *)"";
}
if (menu_is_popup(menu_path)) {
for (i = 0; i < MENU_INDEX_TIP; ++i)