Commit 5af1b825 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Change CurrentMenu to be controlled by the menu stack.

The pager menu is a bit tricky with respect to the menu->menu and
CurrentMenu, so add a few comments.
parent e0634939
......@@ -1271,12 +1271,14 @@ int mutt_index_menu (void)
mutt_sleep (0);
/* Set CurrentMenu to MENU_MAIN before executing any folder
* hooks so that all the index menu functions are available to
* the exec command.
*/
CurrentMenu = MENU_MAIN;
/* Note that menu->menu may be MENU_PAGER if the change folder
* operation originated from the pager.
*
* However, exec commands currently use CurrentMenu to determine what
* functions are available, which is automatically set by the
* mutt_push/pop_current_menu() functions. If that changes, the menu
* would need to be reset here, and the pager cleanup code after the
* switch statement would need to be run. */
mutt_folder_hook (buf);
if ((Context = mx_open_mailbox (buf,
......@@ -1323,12 +1325,21 @@ int mutt_index_menu (void)
if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)))
mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
if ((op = mutt_display_message (CURHDR)) == -1)
/* If we are returning to the pager via an index menu redirection, we
* need to reset the menu->menu. Otherwise mutt_pop_current_menu() will
* set CurrentMenu incorrectly when we return back to the index menu. */
menu->menu = MENU_MAIN;
if ((op = mutt_display_message (CURHDR)) == -1)
{
unset_option (OPTNEEDRESORT);
break;
}
/* This is used to redirect a single operation back here afterwards. If
* mutt_display_message() returns 0, then the menu and pager state will
* be cleaned up after this switch statement. */
menu->menu = MENU_PAGER;
menu->oldcurrent = menu->current;
continue;
......@@ -2042,7 +2053,6 @@ int mutt_index_menu (void)
case OP_ENTER_COMMAND:
CurrentMenu = MENU_MAIN;
mutt_enter_command ();
mutt_check_rescore (Context);
if (option (OPTFORCEREDRAWINDEX))
......@@ -2447,9 +2457,6 @@ int mutt_index_menu (void)
mutt_clear_pager_position ();
menu->menu = MENU_MAIN;
menu->redraw = REDRAW_FULL;
#if 0
set_option (OPTWEED); /* turn header weeding back on. */
#endif
}
if (done) break;
......
......@@ -742,6 +742,7 @@ void mutt_push_current_menu (MUTTMENU *menu)
}
MenuStack[MenuStackCount++] = menu;
CurrentMenu = menu->menu;
}
void mutt_pop_current_menu (MUTTMENU *menu)
......@@ -754,6 +755,14 @@ void mutt_pop_current_menu (MUTTMENU *menu)
}
MenuStackCount--;
if (MenuStackCount)
{
CurrentMenu = MenuStack[MenuStackCount - 1]->menu;
}
else
{
CurrentMenu = MENU_MAIN;
}
}
......@@ -1060,7 +1069,6 @@ int mutt_menuLoop (MUTTMENU *menu)
break;
case OP_ENTER_COMMAND:
CurrentMenu = menu->menu;
mutt_enter_command ();
if (option (OPTFORCEREDRAWINDEX))
{
......
......@@ -2493,7 +2493,6 @@ search_next:
old_markers = option (OPTMARKERS);
old_PagerIndexLines = PagerIndexLines;
CurrentMenu = MENU_PAGER;
mutt_enter_command ();
if (option (OPTNEEDRESORT))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment