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; char_u *p;
int i; int i;
long pri_tab[MENUDEPTH + 1]; long pri_tab[MENUDEPTH + 1];
int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu TriState enable = kNone; // kTrue for "menu enable",
* disable */ // kFalse for "menu disable
vimmenu_T menuarg; vimmenu_T menuarg;
modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu); 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. * Check for "disable" or "enable" argument.
*/ */
if (STRNCMP(arg, "enable", 6) == 0 && ascii_iswhite(arg[6])) { if (STRNCMP(arg, "enable", 6) == 0 && ascii_iswhite(arg[6])) {
enable = TRUE; enable = kTrue;
arg = skipwhite(arg + 6); arg = skipwhite(arg + 6);
} else if (STRNCMP(arg, "disable", 7) == 0 && ascii_iswhite(arg[7])) { } else if (STRNCMP(arg, "disable", 7) == 0 && ascii_iswhite(arg[7])) {
enable = FALSE; enable = kFalse;
arg = skipwhite(arg + 7); 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 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); show_menus(menu_path, modes);
goto theend; goto theend;
} else if (*map_to != NUL && (unmenu || enable != MAYBE)) { } else if (*map_to != NUL && (unmenu || enable != kNone)) {
EMSG(_(e_trailing)); EMSG(_(e_trailing));
goto theend; goto theend;
} }
if (enable != MAYBE) { if (enable != kNone) {
/* // Change sensitivity of the menu.
* Change sensitivity of the menu. // For the PopUp menu, remove a menu for each mode separately.
* For the PopUp menu, remove a menu for each mode separately. // Careful: menu_nable_recurse() changes menu_path.
* Careful: menu_nable_recurse() changes menu_path. if (STRCMP(menu_path, "*") == 0) { // meaning: do all menus
*/
if (STRCMP(menu_path, "*") == 0) /* meaning: do all menus */
menu_path = (char_u *)""; menu_path = (char_u *)"";
}
if (menu_is_popup(menu_path)) { if (menu_is_popup(menu_path)) {
for (i = 0; i < MENU_INDEX_TIP; ++i) for (i = 0; i < MENU_INDEX_TIP; ++i)