Commit e0634939 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Add a menu stack to track current and past menus.

Change the pager to use a MENU, right now just to hold the refresh
state.
parent 26331cb7
......@@ -154,6 +154,7 @@ void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases)
menu->tag = alias_tag;
menu->title = _("Aliases");
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ALIAS, AliasHelp);
mutt_push_current_menu (menu);
new_aliases:
......@@ -237,6 +238,7 @@ new_aliases:
rfc822_write_address (buf, buflen, AliasTable[t]->addr, 1);
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
FREE (&AliasTable);
......
......@@ -611,7 +611,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
char helpstr[LONG_STRING];
char title[STRING];
struct browser_state state;
MUTTMENU *menu;
MUTTMENU *menu = NULL;
struct stat st;
int i, killPrefix = 0;
int multiple = (flags & MUTT_SEL_MULTI) ? 1 : 0;
......@@ -722,6 +722,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_FOLDER,
FolderHelp);
mutt_push_current_menu (menu);
init_menu (&state, menu, title, sizeof (title), buffy);
......@@ -908,7 +909,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
}
destroy_state (&state);
mutt_menuDestroy (&menu);
goto bail;
case OP_BROWSER_TELL:
......@@ -1080,7 +1080,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
mutt_error _("Error scanning directory.");
if (examine_directory (menu, &state, LastDir, prefix) == -1)
{
mutt_menuDestroy (&menu);
goto bail;
}
}
......@@ -1151,7 +1150,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
else
{
mutt_error _("Error scanning directory.");
mutt_menuDestroy (&menu);
goto bail;
}
killPrefix = 0;
......@@ -1246,7 +1244,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
{
strfcpy (f, buf, flen);
destroy_state (&state);
mutt_menuDestroy (&menu);
goto bail;
}
MAYBE_REDRAW (menu->redraw);
......@@ -1264,7 +1261,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
{
strfcpy (f, state.entry[menu->current].name, flen);
destroy_state (&state);
mutt_menuDestroy (&menu);
goto bail;
}
else
......@@ -1296,7 +1292,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
}
bail:
if (menu)
{
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
}
if (!folder)
strfcpy (LastDir, LastDirBackup, sizeof (LastDir));
......
......@@ -516,6 +516,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
menu->tag = mutt_tag_attach;
menu->data = idx;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp);
mutt_push_current_menu (menu);
while (loop)
{
......@@ -1348,6 +1349,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
if (idxlen)
......
......@@ -4031,6 +4031,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys,
menu->make_entry = crypt_entry;
menu->help = helpstr;
menu->data = key_table;
mutt_push_current_menu (menu);
{
const char *ts;
......@@ -4139,6 +4140,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys,
}
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
FREE (&key_table);
......
......@@ -519,6 +519,7 @@ int mutt_index_menu (void)
menu->color = index_color;
menu->current = ci_first_message ();
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MAIN, IndexHelp);
mutt_push_current_menu (menu);
if (!attach_msg)
mutt_buffy_check(1); /* force the buffy check after we enter the folder */
......@@ -2454,6 +2455,7 @@ int mutt_index_menu (void)
if (done) break;
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
return (close);
}
......
......@@ -30,6 +30,11 @@
char* SearchBuffers[MENU_MAX];
/* These are used to track the active menus, for redraw operations. */
static size_t MenuStackCount = 0;
static size_t MenuStackLen = 0;
static MUTTMENU **MenuStack = NULL;
static void print_enriched_string (int attr, unsigned char *s, int do_color)
{
wchar_t wc;
......@@ -709,6 +714,7 @@ MUTTMENU *mutt_new_menu (int menu)
p->messagewin = MuttMessageWindow;
p->color = default_color;
p->search = menu_search_generic;
return (p);
}
......@@ -727,6 +733,30 @@ void mutt_menuDestroy (MUTTMENU **p)
FREE (p); /* __FREE_CHECKED__ */
}
void mutt_push_current_menu (MUTTMENU *menu)
{
if (MenuStackCount >= MenuStackLen)
{
MenuStackLen += 5;
safe_realloc (&MenuStack, MenuStackLen * sizeof(MUTTMENU *));
}
MenuStack[MenuStackCount++] = menu;
}
void mutt_pop_current_menu (MUTTMENU *menu)
{
if (!MenuStackCount ||
(MenuStack[MenuStackCount - 1] != menu))
{
dprint (1, (debugfile, "mutt_pop_current_menu() called with inactive menu\n"));
return;
}
MenuStackCount--;
}
#define MUTT_SEARCH_UP 1
#define MUTT_SEARCH_DOWN 2
......
......@@ -120,6 +120,8 @@ void mutt_ts_icon (char *);
MUTTMENU *mutt_new_menu (int);
void mutt_menuDestroy (MUTTMENU **);
void mutt_push_current_menu (MUTTMENU *);
void mutt_pop_current_menu (MUTTMENU *);
int mutt_menuLoop (MUTTMENU *);
/* used in both the index and pager index to make an entry. */
......
......@@ -1170,6 +1170,8 @@ static int interactive_check_cert (X509 *cert, int idx, int len, SSL *ssl, int a
FILE *fp;
int allow_skip = 0;
mutt_push_current_menu (menu);
menu->max = mutt_array_size (part) * 2 + 10;
menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
for (i = 0; i < menu->max; i++)
......@@ -1302,6 +1304,7 @@ static int interactive_check_cert (X509 *cert, int idx, int len, SSL *ssl, int a
}
}
unset_option(OPTIGNOREMACROEVENTS);
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
set_option (OPTNEEDREDRAW);
dprint (2, (debugfile, "ssl interactive_check_cert: done=%d\n", done));
......
......@@ -862,6 +862,7 @@ static int tls_check_one_certificate (const gnutls_datum_t *certdata,
menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
for (i = 0; i < menu->max; i++)
menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char));
mutt_push_current_menu (menu);
row = 0;
strfcpy (menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING);
......@@ -1065,6 +1066,7 @@ static int tls_check_one_certificate (const gnutls_datum_t *certdata,
}
}
unset_option (OPTIGNOREMACROEVENTS);
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
gnutls_x509_crt_deinit (cert);
......
This diff is collapsed.
......@@ -527,6 +527,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys,
menu->make_entry = pgp_entry;
menu->help = helpstr;
menu->data = KeyTable;
mutt_push_current_menu (menu);
if (p)
snprintf (buf, sizeof (buf), _("PGP keys matching <%s>."), p->mailbox);
......@@ -650,6 +651,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys,
}
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
FREE (&KeyTable);
......
......@@ -165,6 +165,7 @@ static HEADER *select_msg (void)
menu->title = _("Postponed Messages");
menu->data = PostContext;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_POST, PostponeHelp);
mutt_push_current_menu (menu);
/* The postponed mailbox is setup to have sorting disabled, but the global
* Sort variable may indicate something different. Sorting has to be
......@@ -209,6 +210,7 @@ static HEADER *select_msg (void)
}
Sort = orig_sort;
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
return (r > -1 ? PostContext->hdrs[r] : NULL);
}
......
......@@ -326,6 +326,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
menu->tag = query_tag;
menu->title = title;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
mutt_push_current_menu (menu);
if (results == NULL)
{
......@@ -382,6 +383,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
menu->current = 0;
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
menu = mutt_new_menu (MENU_QUERY);
menu->make_entry = query_entry;
......@@ -389,6 +391,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
menu->tag = query_tag;
menu->title = title;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
mutt_push_current_menu (menu);
/* count the number of results */
for (queryp = results; queryp; queryp = queryp->next)
......@@ -538,5 +541,6 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf)
set_option (OPTNEEDREDRAW);
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
}
......@@ -1041,6 +1041,7 @@ void mutt_view_attachments (HEADER *hdr)
menu->make_entry = attach_entry;
menu->tag = mutt_tag_attach;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ATTACH, AttachHelp);
mutt_push_current_menu (menu);
mutt_attach_init (cur);
attach_collapse (cur, 0, 1, 0);
......@@ -1281,6 +1282,7 @@ void mutt_view_attachments (HEADER *hdr)
mutt_free_body (&cur);
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
return;
}
......
......@@ -538,6 +538,7 @@ void mix_make_chain (LIST **chainp, int *redraw)
menu->data = type2_list;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_MIX, RemailerHelp);
menu->pagelen = MIX_VOFFSET - 1;
mutt_push_current_menu (menu);
while (loop)
{
......@@ -673,6 +674,7 @@ void mix_make_chain (LIST **chainp, int *redraw)
}
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
/* construct the remailer list */
......
......@@ -447,6 +447,7 @@ static smime_key_t *smime_select_key (smime_key_t *keys, char *query)
menu->help = helpstr;
menu->data = table;
menu->title = title;
mutt_push_current_menu (menu);
/* sorting keys might be done later - TODO */
mutt_clear_error();
......@@ -493,6 +494,7 @@ static smime_key_t *smime_select_key (smime_key_t *keys, char *query)
}
}
mutt_pop_current_menu (menu);
mutt_menuDestroy (&menu);
FREE (&table);
set_option (OPTNEEDREDRAW);
......
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