patch 8.0.1570: can't use :popup for a menu in the terminal

Problem:    Can't use :popup for a menu in the terminal. (Wei Zhang)
Solution:   Make :popup work in the terminal.  Also fix that entries were
            included that don't work in the current state.
diff --git a/src/menu.c b/src/menu.c
index 107cabc..c04cd49 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1891,6 +1891,16 @@
     return MENU_INDEX_INVALID;
 }
 
+    int
+get_menu_mode_flag(void)
+{
+    int mode = get_menu_mode();
+
+    if (mode == MENU_INDEX_INVALID)
+	return 0;
+    return 1 << mode;
+}
+
 /*
  * Display the Special "PopUp" menu as a pop-up at the current mouse
  * position.  The "PopUpn" menu is for Normal mode, "PopUpi" for Insert mode,
@@ -2044,13 +2054,7 @@
     if (modes != 0x0)
 	mode = modes;
     else
-    {
-	mode = get_menu_mode();
-	if (mode == MENU_INDEX_INVALID)
-	    mode = 0;
-	else
-	    mode = (1 << mode);
-    }
+	mode = get_menu_mode_flag();
 
     if (force_menu_update || mode != prev_mode)
     {