diff --git a/addrbook.c b/addrbook.c index 50e19fadb6d..8afd16a8a20 100644 --- a/addrbook.c +++ b/addrbook.c @@ -143,14 +143,12 @@ void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases) return; } - /* tell whoever called me to redraw the screen when I return */ - set_option (OPTNEEDREDRAW); - menu = mutt_new_menu (MENU_ALIAS); menu->make_entry = alias_entry; 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: @@ -234,6 +232,7 @@ void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases) rfc822_write_address (buf, buflen, AliasTable[t]->addr, 1); } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); FREE (&AliasTable); diff --git a/browser.c b/browser.c index 12075c7b62f..0b072cfa969 100644 --- a/browser.c +++ b/browser.c @@ -1258,6 +1258,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num option (OPTNEWS) ? FolderNewsHelp : #endif FolderHelp); + mutt_push_current_menu (menu); init_menu (&state, menu, title, sizeof (title), buffy); @@ -1451,7 +1452,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num } destroy_state (&state); - mutt_menu_destroy (&menu); goto bail; case OP_BROWSER_TELL: @@ -1488,7 +1488,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num menu->data = state.entry; browser_highlight_default (&state, menu); init_menu (&state, menu, title, sizeof (title), buffy); - MAYBE_REDRAW (menu->redraw); } /* else leave error on screen */ break; @@ -1510,7 +1509,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num menu->data = state.entry; browser_highlight_default (&state, menu); init_menu (&state, menu, title, sizeof (title), buffy); - MAYBE_REDRAW (menu->redraw); } } break; @@ -1548,7 +1546,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num state.entrylen--; mutt_message (_("Mailbox deleted.")); init_menu (&state, menu, title, sizeof (title), buffy); - MAYBE_REDRAW (menu->redraw); } } else @@ -1620,7 +1617,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_menu_destroy (&menu); goto bail; } } @@ -1634,7 +1630,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num mutt_perror (buf); } } - MAYBE_REDRAW (menu->redraw); break; case OP_ENTER_MASK: @@ -1690,7 +1685,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num else { mutt_error (_("Error scanning directory.")); - mutt_menu_destroy (&menu); goto bail; } killPrefix = 0; @@ -1701,7 +1695,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num } } } - MAYBE_REDRAW (menu->redraw); break; case OP_SORT: @@ -1827,10 +1820,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num { strfcpy (f, buf, flen); destroy_state (&state); - mutt_menu_destroy (&menu); goto bail; } - MAYBE_REDRAW (menu->redraw); break; case OP_BROWSER_VIEW_FILE: @@ -1845,7 +1836,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_menu_destroy (&menu); goto bail; } else @@ -2052,6 +2042,12 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num bail: + if (menu) + { + mutt_pop_current_menu (menu); + mutt_menu_destroy (&menu); + } + if (GotoSwapper[0]) GotoSwapper[0] = '\0'; } diff --git a/buffy.c b/buffy.c index 4da236330bd..74dddde4ed8 100644 --- a/buffy.c +++ b/buffy.c @@ -24,6 +24,7 @@ #include "mx.h" #include "mutt_curses.h" +#include "mutt_menu.h" #ifdef USE_SIDEBAR #include "sidebar.h" @@ -420,7 +421,7 @@ static void buffy_check (BUFFY *tmp, struct stat *contex_sb, int check_stats) (orig_count != tmp->msg_count) || (orig_unread != tmp->msg_unread) || (orig_flagged != tmp->msg_flagged)) - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); #endif if (!tmp->new) diff --git a/color.c b/color.c index abec4ee8064..7a503d51b1b 100644 --- a/color.c +++ b/color.c @@ -19,6 +19,7 @@ #include "mutt.h" #include "mutt_curses.h" +#include "mutt_menu.h" #include "mapping.h" #include @@ -459,7 +460,7 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, if (object > MT_COLOR_INDEX_SUBJECT) { /* uncolor index column */ ColorDefs[object] = 0; - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); return 0; } @@ -524,7 +525,7 @@ static int _mutt_parse_uncolor (BUFFER *buf, BUFFER *s, unsigned long data, if (do_cache && !option (OPTNOCURSES)) { int i; - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); /* force re-caching of index colors */ for (i = 0; Context && i < Context->msgcount; i++) Context->hdrs[i]->pair = 0; @@ -856,32 +857,32 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, { r = add_pattern (&ColorIndexList, buf->data, 1, fg, bg, attr, err, 1, match); - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); } else if (object == MT_COLOR_INDEX_AUTHOR) { r = add_pattern (&ColorIndexAuthorList, buf->data, 1, fg, bg, attr, err, 1, match); - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); } else if (object == MT_COLOR_INDEX_FLAGS) { r = add_pattern (&ColorIndexFlagsList, buf->data, 1, fg, bg, attr, err, 1, match); - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); } else if (object == MT_COLOR_INDEX_SUBJECT) { r = add_pattern (&ColorIndexSubjectList, buf->data, 1, fg, bg, attr, err, 1, match); - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); } #ifdef USE_NOTMUCH else if (object == MT_COLOR_INDEX_TAG) { r = add_pattern (&ColorIndexTagList, buf->data, 1, fg, bg, attr, err, 1, match); - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); } #endif else if (object == MT_COLOR_QUOTED) @@ -912,7 +913,7 @@ _mutt_parse_color (BUFFER *buf, BUFFER *s, BUFFER *err, { ColorDefs[object] = fgbgattr_to_color(fg, bg, attr); if (object > MT_COLOR_INDEX_AUTHOR) - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); } return r; diff --git a/commands.c b/commands.c index e7d4339cdd8..b6db0130696 100644 --- a/commands.c +++ b/commands.c @@ -246,7 +246,7 @@ int mutt_display_message (HEADER *cur) return rc; } -void ci_bounce_message (HEADER *h, int *redraw) +void ci_bounce_message (HEADER *h) { char prompt[SHORT_STRING]; char scratch[SHORT_STRING]; @@ -284,13 +284,6 @@ void ci_bounce_message (HEADER *h, int *redraw) strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); rc = mutt_get_field (prompt, buf, sizeof (buf), MUTT_ALIAS); - - if (option (OPTNEEDREDRAW)) - { - unset_option (OPTNEEDREDRAW); - *redraw = REDRAW_FULL; - } - if (rc || !buf[0]) return; @@ -735,8 +728,7 @@ int _mutt_save_message (HEADER *h, CONTEXT *ctx, int delete, int decode, int dec } /* returns 0 if the copy/save was successful, or -1 on error/abort */ -int mutt_save_message (HEADER *h, int delete, - int decode, int decrypt, int *redraw) +int mutt_save_message (HEADER *h, int delete, int decode, int decrypt) { int i, need_buffy_cleanup; int need_passphrase = 0, app=0; @@ -744,9 +736,6 @@ int mutt_save_message (HEADER *h, int delete, CONTEXT ctx; struct stat st; - *redraw = 0; - - snprintf (prompt, sizeof (prompt), decode ? (delete ? _("Decode-save%s to mailbox") : _("Decode-copy%s to mailbox")) : @@ -794,17 +783,9 @@ int mutt_save_message (HEADER *h, int delete, } mutt_pretty_mailbox (buf, sizeof (buf)); - if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1) + if (mutt_enter_fname (prompt, buf, sizeof (buf), 0) == -1) return -1; - if (*redraw != REDRAW_FULL) - { - if (!h) - *redraw = REDRAW_INDEX | REDRAW_STATUS; - else - *redraw = REDRAW_STATUS; - } - if (!buf[0]) return -1; diff --git a/compose.c b/compose.c index ab6120297fa..4b472959240 100644 --- a/compose.c +++ b/compose.c @@ -323,7 +323,7 @@ static void draw_envelope (HEADER *msg, char *fcc) NORMAL_COLOR; } -static int edit_address_list (int line, ADDRESS **addr) +static void edit_address_list (int line, ADDRESS **addr) { char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */ char *err = NULL; @@ -337,12 +337,6 @@ static int edit_address_list (int line, ADDRESS **addr) *addr = mutt_expand_aliases (*addr); } - if (option (OPTNEEDREDRAW)) - { - unset_option (OPTNEEDREDRAW); - return REDRAW_FULL; - } - if (mutt_addrlist_to_intl (*addr, &err) != 0) { mutt_error (_("Warning: '%s' is a bad IDN."), err); @@ -355,8 +349,6 @@ static int edit_address_list (int line, ADDRESS **addr) rfc822_write_address (buf, sizeof (buf), *addr, 1); mutt_window_move (MuttIndexWindow, line, HDR_XOFFSET); mutt_paddstr (W, buf); - - return 0; } static int delete_attachment (MUTTMENU *menu, short *idxlen, int x) @@ -573,6 +565,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ else #endif menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); + mutt_push_current_menu (menu); while (loop) { @@ -587,7 +580,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ menu->pagelen = MuttIndexWindow->rows - HDR_ATTACH; break; case OP_COMPOSE_EDIT_FROM: - menu->redraw = edit_address_list (HDR_FROM, &msg->env->from); + edit_address_list (HDR_FROM, &msg->env->from); mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_TO: @@ -595,7 +588,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (news) break; #endif - menu->redraw = edit_address_list (HDR_TO, &msg->env->to); + edit_address_list (HDR_TO, &msg->env->to); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) { crypt_opportunistic_encrypt (msg); @@ -608,7 +601,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (news) break; #endif - menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); + edit_address_list (HDR_BCC, &msg->env->bcc); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) { crypt_opportunistic_encrypt (msg); @@ -621,7 +614,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (news) break; #endif - menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); + edit_address_list (HDR_CC, &msg->env->cc); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) { crypt_opportunistic_encrypt (msg); @@ -702,7 +695,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_REPLY_TO: - menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to); + edit_address_list (HDR_REPLYTO, &msg->env->reply_to); mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_FCC: @@ -715,7 +708,6 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ mutt_paddstr (W, fcc); fccSet = 1; } - MAYBE_REDRAW (menu->redraw); mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_MESSAGE: @@ -795,12 +787,6 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ menu->redraw |= REDRAW_STATUS; - if (option(OPTNEEDREDRAW)) - { - menu->redraw = REDRAW_FULL; - unset_option(OPTNEEDREDRAW); - } - mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; @@ -815,8 +801,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ numfiles = 0; files = NULL; - if (_mutt_enter_fname (prompt, fname, sizeof (fname), - &menu->redraw, 0, 1, &files, &numfiles, MUTT_SEL_MULTI) == -1 || + if (_mutt_enter_fname (prompt, fname, sizeof (fname), 0, 1, &files, &numfiles, MUTT_SEL_MULTI) == -1 || *fname == '\0') break; @@ -885,7 +870,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ mutt_pretty_mailbox (fname, sizeof (fname)); } - if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) + if (mutt_enter_fname (prompt, fname, sizeof (fname), 1) == -1 || !fname[0]) break; #ifdef USE_NNTP @@ -1309,7 +1294,6 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ case OP_SAVE: CHECK_COUNT; mutt_save_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, NULL, menu); - MAYBE_REDRAW (menu->redraw); /* no send2hook, since this doesn't modify the message */ break; @@ -1395,7 +1379,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (idxlen) msg->content = idx[0]->content; if (mutt_enter_fname (_("Write message to mailbox"), fname, sizeof (fname), - &menu->redraw, 1) != -1 && fname[0]) + 1) != -1 && fname[0]) { mutt_message (_("Writing message to %s ..."), fname); mutt_expand_path (fname, sizeof (fname)); @@ -1433,7 +1417,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } - msg->security = crypt_pgp_send_menu (msg, &menu->redraw); + msg->security = crypt_pgp_send_menu (msg); redraw_crypt_lines (msg); mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; @@ -1466,7 +1450,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } - msg->security = crypt_smime_send_menu(msg, &menu->redraw); + msg->security = crypt_smime_send_menu(msg); redraw_crypt_lines (msg); mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; @@ -1475,7 +1459,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ #ifdef MIXMASTER case OP_COMPOSE_MIX: - mix_make_chain (&msg->chain, &menu->redraw); + mix_make_chain (&msg->chain); mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; #endif @@ -1494,6 +1478,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); if (idxlen) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 789d67e53aa..68409625b93 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4007,6 +4007,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 = NULL; @@ -4115,11 +4116,10 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); FREE (&key_table); - set_option (OPTNEEDREDRAW); - return k; } @@ -4661,7 +4661,7 @@ void smime_gpgme_init (void) init_smime (); } -static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime) +static int gpgme_send_menu (HEADER *msg, int is_smime) { crypt_key_t *p = NULL; char input_signas[SHORT_STRING]; @@ -4780,7 +4780,6 @@ static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime) msg->security |= SIGN; } - *redraw = REDRAW_FULL; break; case 'b': /* (b)oth */ @@ -4827,14 +4826,14 @@ static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime) return msg->security; } -int pgp_gpgme_send_menu (HEADER *msg, int *redraw) +int pgp_gpgme_send_menu (HEADER *msg) { - return gpgme_send_menu (msg, redraw, 0); + return gpgme_send_menu (msg, 0); } -int smime_gpgme_send_menu (HEADER *msg, int *redraw) +int smime_gpgme_send_menu (HEADER *msg) { - return gpgme_send_menu (msg, redraw, 1); + return gpgme_send_menu (msg, 1); } static int verify_sender (HEADER *h, gpgme_protocol_t protocol) diff --git a/crypt-gpgme.h b/crypt-gpgme.h index f9c174f756a..8bf1418c8bd 100644 --- a/crypt-gpgme.h +++ b/crypt-gpgme.h @@ -47,8 +47,8 @@ BODY *smime_gpgme_sign_message (BODY *a); int pgp_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile); int smime_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile); -int pgp_gpgme_send_menu (HEADER *msg, int *redraw); -int smime_gpgme_send_menu (HEADER *msg, int *redraw); +int pgp_gpgme_send_menu (HEADER *msg); +int smime_gpgme_send_menu (HEADER *msg); int smime_gpgme_verify_sender (HEADER *h); diff --git a/crypt-mod-pgp-classic.c b/crypt-mod-pgp-classic.c index 57c5be8ca25..3ab0d4d5d35 100644 --- a/crypt-mod-pgp-classic.c +++ b/crypt-mod-pgp-classic.c @@ -58,9 +58,9 @@ static int crypt_mod_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf) return pgp_verify_one (sigbdy, s, tempf); } -static int crypt_mod_pgp_send_menu (HEADER *msg, int *redraw) +static int crypt_mod_pgp_send_menu (HEADER *msg) { - return pgp_send_menu (msg, redraw); + return pgp_send_menu (msg); } static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign) diff --git a/crypt-mod-pgp-gpgme.c b/crypt-mod-pgp-gpgme.c index 44dffa49cc9..43fa9055e36 100644 --- a/crypt-mod-pgp-gpgme.c +++ b/crypt-mod-pgp-gpgme.c @@ -80,9 +80,9 @@ static int crypt_mod_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf) return pgp_gpgme_verify_one (sigbdy, s, tempf); } -static int crypt_mod_pgp_send_menu (HEADER *msg, int *redraw) +static int crypt_mod_pgp_send_menu (HEADER *msg) { - return pgp_gpgme_send_menu (msg, redraw); + return pgp_gpgme_send_menu (msg); } static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign) diff --git a/crypt-mod-smime-classic.c b/crypt-mod-smime-classic.c index 2f9615adc80..fa260994bae 100644 --- a/crypt-mod-smime-classic.c +++ b/crypt-mod-smime-classic.c @@ -58,9 +58,9 @@ static int crypt_mod_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf return smime_verify_one (sigbdy, s, tempf); } -static int crypt_mod_smime_send_menu (HEADER *msg, int *redraw) +static int crypt_mod_smime_send_menu (HEADER *msg) { - return smime_send_menu (msg, redraw); + return smime_send_menu (msg); } static void crypt_mod_smime_getkeys (ENVELOPE *env) diff --git a/crypt-mod-smime-gpgme.c b/crypt-mod-smime-gpgme.c index b2c19bb0ba5..9f8fb80fc7d 100644 --- a/crypt-mod-smime-gpgme.c +++ b/crypt-mod-smime-gpgme.c @@ -65,9 +65,9 @@ static int crypt_mod_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf return smime_gpgme_verify_one (sigbdy, s, tempf); } -static int crypt_mod_smime_send_menu (HEADER *msg, int *redraw) +static int crypt_mod_smime_send_menu (HEADER *msg) { - return smime_gpgme_send_menu (msg, redraw); + return smime_gpgme_send_menu (msg); } static BODY *crypt_mod_smime_build_smime_entity (BODY *a, char *certlist) diff --git a/crypt-mod.h b/crypt-mod.h index 61149a3096c..0594d68cd0f 100644 --- a/crypt-mod.h +++ b/crypt-mod.h @@ -52,7 +52,7 @@ typedef int (*crypt_func_verify_one_t) (BODY *sigbdy, STATE *s, typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t) (FILE *fp, int tag, BODY *top); -typedef int (*crypt_func_send_menu_t) (HEADER *msg, int *redraw); +typedef int (*crypt_func_send_menu_t) (HEADER *msg); /* (SMIME) */ typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE *env); diff --git a/cryptglue.c b/cryptglue.c index 9f355815b92..6653af93114 100644 --- a/cryptglue.c +++ b/cryptglue.c @@ -242,10 +242,10 @@ int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf) } -int crypt_pgp_send_menu (HEADER *msg, int *redraw) +int crypt_pgp_send_menu (HEADER *msg) { if (CRYPT_MOD_CALL_CHECK (PGP, send_menu)) - return (CRYPT_MOD_CALL (PGP, send_menu)) (msg, redraw); + return (CRYPT_MOD_CALL (PGP, send_menu)) (msg); return 0; } @@ -375,10 +375,10 @@ int crypt_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf) return -1; } -int crypt_smime_send_menu (HEADER *msg, int *redraw) +int crypt_smime_send_menu (HEADER *msg) { if (CRYPT_MOD_CALL_CHECK (SMIME, send_menu)) - return (CRYPT_MOD_CALL (SMIME, send_menu)) (msg, redraw); + return (CRYPT_MOD_CALL (SMIME, send_menu)) (msg); return 0; } diff --git a/curs_lib.c b/curs_lib.c index 87c5822cbda..9b540066a10 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -82,7 +82,8 @@ void mutt_refresh (void) return; /* don't refresh in the middle of macros unless necessary */ - if (UngetCount && !option (OPTFORCEREFRESH)) + if (MacroBufferCount && !option (OPTFORCEREFRESH) && + !option (OPTIGNOREMACROEVENTS)) return; /* else */ @@ -97,7 +98,7 @@ void mutt_need_hard_redraw (void) { keypad (stdscr, true); clearok (stdscr, true); - set_option (OPTNEEDREDRAW); + mutt_set_current_menu_redraw_full (); } event_t mutt_getch (void) @@ -616,6 +617,8 @@ void mutt_reflow_windows (void) } } #endif + + mutt_set_current_menu_redraw_full (); } int mutt_window_move (mutt_window_t *win, int row, int col) @@ -802,8 +805,7 @@ int mutt_do_pager (const char *banner, } int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, - int *redraw, int buffy, int multiple, - char ***files, int *numfiles, int flags) + int buffy, int multiple, char ***files, int *numfiles, int flags) { event_t ch; @@ -830,7 +832,6 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, flags = MUTT_SEL_FOLDER | (multiple ? MUTT_SEL_MULTI : 0); _mutt_select_file (buf, blen, flags, files, numfiles); - *redraw = REDRAW_FULL; } else { @@ -841,7 +842,6 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, if (_mutt_get_field (pc, buf, blen, (buffy ? MUTT_EFILE : MUTT_FILE) | MUTT_CLEAR, multiple, files, numfiles) != 0) buf[0] = 0; - MAYBE_REDRAW (*redraw); FREE (&pc); #ifdef USE_NOTMUCH if ((flags & MUTT_SEL_VFOLDER) && buf[0] && (strncmp(buf, "notmuch://", 10) != 0)) diff --git a/curs_main.c b/curs_main.c index 592c3a81d4b..c56490f1a83 100644 --- a/curs_main.c +++ b/curs_main.c @@ -459,12 +459,14 @@ static int main_change_folder(MUTTMENU *menu, int op, char *buf, size_t bufsz, 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, @@ -842,6 +844,7 @@ int mutt_index_menu (void) (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp : #endif IndexHelp); + mutt_push_current_menu (menu); if (!attach_msg) mutt_buffy_check(1); /* force the buffy check after we enter the folder */ @@ -966,16 +969,16 @@ int mutt_index_menu (void) if (op != -1) mutt_curs_set (0); - if (menu->redraw & REDRAW_FULL) - { - menu_redraw_full (menu); - mutt_show_error (); - } - if (menu->menu == MENU_MAIN) { + if (menu->redraw & REDRAW_FULL) + { + menu_redraw_full (menu); + mutt_show_error (); + } + #ifdef USE_SIDEBAR - if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw) + if (menu->redraw & REDRAW_SIDEBAR) { mutt_sb_set_buffystats (Context); menu_redraw_sidebar (menu); @@ -1988,7 +1991,7 @@ int mutt_index_menu (void) strfcpy(buf, Context->path, sizeof (buf)); mutt_buffy_vfolder (buf, sizeof (buf)); } - mutt_enter_vfolder (cp, buf, sizeof (buf), &menu->redraw, 1); + mutt_enter_vfolder (cp, buf, sizeof (buf), 1); if (!buf[0]) { mutt_window_clearline (MuttMessageWindow, 0); @@ -2018,7 +2021,7 @@ int mutt_index_menu (void) * mail */ mutt_buffy (buf, sizeof (buf)); - if (mutt_enter_fname (cp, buf, sizeof (buf), &menu->redraw, 1) == -1) + if (mutt_enter_fname (cp, buf, sizeof (buf), 1) == -1) { if (menu->menu == MENU_PAGER) { @@ -2076,12 +2079,21 @@ int mutt_index_menu (void) if (option (OPTPGPAUTODEC) && (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED))) mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw); int index_hint = Context->hdrs[Context->v2r[menu->current]]->index; - 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; if (Context) @@ -2307,11 +2319,11 @@ int mutt_index_menu (void) (op == OP_SAVE) || (op == OP_DECODE_SAVE), (op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY), (op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) || - 0, - &menu->redraw) == 0 && + 0) == 0 && (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE) ) { + menu->redraw |= REDRAW_STATUS; if (tag) menu->redraw |= REDRAW_INDEX; else if (option (OPTRESOLVE)) @@ -2662,20 +2674,18 @@ int mutt_index_menu (void) CHECK_ATTACH; CHECK_MSGCOUNT; CHECK_VISIBLE; - ci_bounce_message (tag ? NULL : CURHDR, &menu->redraw); + ci_bounce_message (tag ? NULL : CURHDR); break; case OP_CREATE_ALIAS: mutt_create_alias (Context && Context->vcount ? CURHDR->env : NULL, NULL); - MAYBE_REDRAW (menu->redraw); menu->redraw |= REDRAW_CURRENT; break; case OP_QUERY: CHECK_ATTACH; mutt_query_menu (NULL, 0); - MAYBE_REDRAW (menu->redraw); break; case OP_PURGE_MESSAGE: @@ -2776,13 +2786,8 @@ int mutt_index_menu (void) case OP_ENTER_COMMAND: - CurrentMenu = MENU_MAIN; mutt_enter_command (); mutt_check_rescore (Context); - if (option (OPTFORCEREDRAWINDEX)) - menu->redraw = REDRAW_FULL; - unset_option (OPTFORCEREDRAWINDEX); - unset_option (OPTFORCEREDRAWPAGER); break; case OP_EDIT_MESSAGE: @@ -2917,7 +2922,6 @@ int mutt_index_menu (void) } #endif - MAYBE_REDRAW (menu->redraw); break; case OP_PRINT: @@ -3079,7 +3083,6 @@ int mutt_index_menu (void) case OP_SHELL_ESCAPE: mutt_shell_escape (); - MAYBE_REDRAW (menu->redraw); break; case OP_TAG_THREAD: @@ -3202,7 +3205,6 @@ int mutt_index_menu (void) case OP_SIDEBAR_TOGGLE_VISIBLE: toggle_option (OPTSIDEBAR); mutt_reflow_windows(); - menu->redraw = REDRAW_FULL; break; case OP_SIDEBAR_TOGGLE_VIRTUAL: @@ -3229,6 +3231,7 @@ int mutt_index_menu (void) if (done) break; } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); return close; } diff --git a/enter.c b/enter.c index 3678817dcde..28c3650164e 100644 --- a/enter.c +++ b/enter.c @@ -527,7 +527,6 @@ int _mutt_enter_string (char *buf, size_t buflen, int col, !memcmp (tempbuf, state->wbuf + i, (state->lastchar - i) * sizeof (wchar_t))) { mutt_select_file (buf, buflen, (flags & MUTT_EFILE) ? MUTT_SEL_FOLDER : 0); - set_option (OPTNEEDREDRAW); if (*buf) replace_part (state, i, buf); rv = 1; @@ -637,7 +636,6 @@ int _mutt_enter_string (char *buf, size_t buflen, int col, _mutt_select_file (buf, buflen, ((flags & MUTT_EFILE) ? MUTT_SEL_FOLDER : 0) | (multiple ? MUTT_SEL_MULTI : 0), files, numfiles); - set_option (OPTNEEDREDRAW); if (*buf) { mutt_pretty_mailbox (buf, buflen); diff --git a/flags.c b/flags.c index 709f7589d34..0f6398fd442 100644 --- a/flags.c +++ b/flags.c @@ -19,6 +19,7 @@ #include "mutt.h" #include "mutt_curses.h" +#include "mutt_menu.h" #include "sort.h" #include "mx.h" @@ -273,7 +274,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) { mutt_set_header_color(ctx, h); #ifdef USE_SIDEBAR - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); #endif } diff --git a/globals.h b/globals.h index 96467138c75..2d3594642e7 100644 --- a/globals.h +++ b/globals.h @@ -257,7 +257,6 @@ WHERE short ScoreThresholdFlag; #ifdef USE_SIDEBAR WHERE short SidebarWidth INITVAL(0); WHERE LIST *SidebarWhitelist INITVAL(0); -WHERE int SidebarNeedsRedraw INITVAL (0); #endif #ifdef USE_IMAP diff --git a/imap/command.c b/imap/command.c index cd6a8ceb220..cd103aa0d9e 100644 --- a/imap/command.c +++ b/imap/command.c @@ -23,6 +23,7 @@ #include "config.h" #include "mutt.h" +#include "mutt_menu.h" #include "imap_private.h" #include "mx.h" #include "buffy.h" @@ -622,7 +623,7 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s) if ((inc->new != new) || (inc->msg_count != status->messages) || (inc->msg_unread != status->unseen)) - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); #endif inc->new = new; if (new_msg_count) diff --git a/init.c b/init.c index c62f8dad511..7915ab7da43 100644 --- a/init.c +++ b/init.c @@ -1524,8 +1524,8 @@ static int parse_attachments (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER print_attach_list(AttachExclude, '-', "A"); print_attach_list(InlineAllow, '+', "I"); print_attach_list(InlineExclude, '-', "I"); - set_option (OPTFORCEREDRAWINDEX); - set_option (OPTFORCEREDRAWPAGER); + mutt_set_menu_redraw_full (MENU_MAIN); + mutt_set_menu_redraw_full (MENU_PAGER); mutt_any_key_to_continue (NULL); return 0; } @@ -1669,7 +1669,7 @@ static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er { for (tmp = Aliases; tmp ; tmp = tmp->next) tmp->del = 1; - set_option (OPTFORCEREDRAWINDEX); + mutt_set_current_menu_redraw_full (); } else mutt_free_alias (&Aliases); @@ -1683,7 +1683,7 @@ static int parse_unalias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *er if (CurrentMenu == MENU_ALIAS) { tmp->del = 1; - set_option (OPTFORCEREDRAWINDEX); + mutt_set_current_menu_redraw_full (); break; } @@ -1744,7 +1744,7 @@ static int parse_alias (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err) /* override the previous value */ rfc822_free_address (&tmp->addr); if (CurrentMenu == MENU_ALIAS) - set_option (OPTFORCEREDRAWINDEX); + mutt_set_current_menu_redraw_full (); } mutt_extract_token (buf, s, MUTT_TOKEN_QUOTE | MUTT_TOKEN_SPACE | MUTT_TOKEN_SEMICOLON); @@ -1998,9 +1998,9 @@ static void restore_default (struct option_t *p) } if (p->flags & R_INDEX) - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); if (p->flags & R_PAGER) - set_option (OPTFORCEREDRAWPAGER); + mutt_set_menu_redraw_full (MENU_PAGER); if (p->flags & R_RESORT_SUB) set_option (OPTSORTSUBTHREADS); if (p->flags & R_RESORT) @@ -2013,8 +2013,10 @@ static void restore_default (struct option_t *p) mutt_reflow_windows (); #ifdef USE_SIDEBAR if (p->flags & R_SIDEBAR) - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); #endif + if (p->flags & R_MENU) + mutt_set_current_menu_redraw_full (); } static size_t escape_string (char *dst, size_t len, const char* src) @@ -2188,8 +2190,7 @@ static int parse_setenv(BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) if (found) { - set_option (OPTFORCEREDRAWINDEX); - set_option (OPTFORCEREDRAWPAGER); + mutt_set_current_menu_redraw_full (); mutt_any_key_to_continue (NULL); return 0; } @@ -2318,8 +2319,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) } for (idx = 0; MuttVars[idx].option; idx++) restore_default (&MuttVars[idx]); - set_option (OPTFORCEREDRAWINDEX); - set_option (OPTFORCEREDRAWPAGER); + mutt_set_current_menu_redraw_full (); set_option (OPTSORTSUBTHREADS); set_option (OPTNEEDRESORT); set_option (OPTRESORTINIT); @@ -2779,9 +2779,9 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) if (!myvar) { if (MuttVars[idx].flags & R_INDEX) - set_option (OPTFORCEREDRAWINDEX); + mutt_set_menu_redraw_full (MENU_MAIN); if (MuttVars[idx].flags & R_PAGER) - set_option (OPTFORCEREDRAWPAGER); + mutt_set_menu_redraw_full (MENU_PAGER); if (MuttVars[idx].flags & R_RESORT_SUB) set_option (OPTSORTSUBTHREADS); if (MuttVars[idx].flags & R_RESORT) @@ -2794,8 +2794,10 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) mutt_reflow_windows (); #ifdef USE_SIDEBAR if (MuttVars[idx].flags & R_SIDEBAR) - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); #endif + if (MuttVars[idx].flags & R_MENU) + mutt_set_current_menu_redraw_full (); } } return r; diff --git a/init.h b/init.h index 8581fd8e1ed..e6ac77158c3 100644 --- a/init.h +++ b/init.h @@ -44,14 +44,15 @@ /* forced redraw/resort types + other flags */ #define R_NONE 0 -#define R_INDEX (1<<0) -#define R_PAGER (1<<1) +#define R_INDEX (1<<0) /* redraw the index menu (MENU_MAIN) */ +#define R_PAGER (1<<1) /* redraw the pager menu */ #define R_RESORT (1<<2) /* resort the mailbox */ #define R_RESORT_SUB (1<<3) /* resort subthreads */ #define R_RESORT_INIT (1<<4) /* resort from scratch */ #define R_TREE (1<<5) /* redraw the thread tree */ -#define R_REFLOW (1<<6) /* reflow window layout */ +#define R_REFLOW (1<<6) /* reflow window layout and full redraw */ #define R_SIDEBAR (1<<7) /* redraw the sidebar */ +#define R_MENU (1<<8) /* redraw all menus */ #define R_BOTH (R_INDEX | R_PAGER) #define R_RESORT_BOTH (R_RESORT | R_RESORT_SUB) @@ -149,7 +150,7 @@ struct option_t MuttVars[] = { ** and give it the same color as your attachment color (see also ** $$crypt_timestamp). */ - { "arrow_cursor", DT_BOOL, R_BOTH, OPTARROWCURSOR, 0 }, + { "arrow_cursor", DT_BOOL, R_MENU, OPTARROWCURSOR, 0 }, /* ** .pp ** When \fIset\fP, an arrow (``->'') will be used to indicate the current entry @@ -431,7 +432,7 @@ struct option_t MuttVars[] = { ** When \fIunset\fP, Mutt will not collapse a thread if it contains any ** unread messages. */ - { "compose_format", DT_STR, R_BOTH, UL &ComposeFormat, UL "-- NeoMutt: Compose [Approx. msg size: %l Atts: %a]%>-" }, + { "compose_format", DT_STR, R_MENU, UL &ComposeFormat, UL "-- NeoMutt: Compose [Approx. msg size: %l Atts: %a]%>-" }, /* ** .pp ** Controls the format of the status line displayed in the ``compose'' @@ -636,7 +637,7 @@ struct option_t MuttVars[] = { ** If \fI``no''\fP, never attempt to verify cryptographic signatures. ** (Crypto only) */ - { "date_format", DT_STR, R_BOTH, UL &DateFmt, UL "!%a, %b %d, %Y at %I:%M:%S%p %Z" }, + { "date_format", DT_STR, R_MENU, UL &DateFmt, UL "!%a, %b %d, %Y at %I:%M:%S%p %Z" }, /* ** .pp ** This variable controls the format of the date printed by the ``%d'' @@ -852,7 +853,7 @@ struct option_t MuttVars[] = { ** you use ``+'' or ``='' for any other variables since expansion takes place ** when handling the ``$mailboxes'' command. */ - { "folder_format", DT_STR, R_INDEX, UL &FolderFormat, UL "%2C %t %N %F %2l %-8.8u %-8.8g %8s %d %f" }, + { "folder_format", DT_STR, R_MENU, UL &FolderFormat, UL "%2C %t %N %F %2l %-8.8u %-8.8g %8s %d %f" }, /* ** .pp ** This variable allows you to customize the file browser display to your @@ -1112,7 +1113,7 @@ struct option_t MuttVars[] = { */ #endif /* HAVE_GDBM || HAVE_BDB */ #endif /* USE_HCACHE */ - { "help", DT_BOOL, R_BOTH|R_REFLOW, OPTHELP, 1 }, + { "help", DT_BOOL, R_REFLOW, OPTHELP, 1 }, /* ** .pp ** When \fIset\fP, help lines describing the bindings for the major functions @@ -1213,14 +1214,14 @@ struct option_t MuttVars[] = { ** Also see $$use_domain and $$hidden_host. */ #ifdef HAVE_LIBIDN - { "idn_decode", DT_BOOL, R_BOTH, OPTIDNDECODE, 1}, + { "idn_decode", DT_BOOL, R_MENU, OPTIDNDECODE, 1}, /* ** .pp ** When \fIset\fP, Mutt will show you international domain names decoded. ** Note: You can use IDNs for addresses even if this is \fIunset\fP. ** This variable only affects decoding. (IDN only) */ - { "idn_encode", DT_BOOL, R_BOTH, OPTIDNENCODE, 1}, + { "idn_encode", DT_BOOL, R_MENU, OPTIDNENCODE, 1}, /* ** .pp ** When \fIset\fP, Mutt will encode international domain names using @@ -3245,7 +3246,7 @@ struct option_t MuttVars[] = { ** You may optionally use the ``reverse-'' prefix to specify reverse sorting ** order (example: ``\fCset sort_browser=reverse-date\fP''). */ - { "sidebar_visible", DT_BOOL, R_BOTH|R_REFLOW, OPTSIDEBAR, 0 }, + { "sidebar_visible", DT_BOOL, R_REFLOW, OPTSIDEBAR, 0 }, /* ** .pp ** This specifies whether or not to show sidebar. The sidebar shows a list of @@ -3253,7 +3254,7 @@ struct option_t MuttVars[] = { ** .pp ** \fBSee also:\fP $$sidebar_format, $$sidebar_width */ - { "sidebar_width", DT_NUM, R_BOTH|R_REFLOW, UL &SidebarWidth, 30 }, + { "sidebar_width", DT_NUM, R_REFLOW, UL &SidebarWidth, 30 }, /* ** .pp ** This controls the width of the sidebar. It is measured in screen columns. @@ -3925,7 +3926,7 @@ struct option_t MuttVars[] = { ** will replace any dots in the expansion by underscores. This might be helpful ** with IMAP folders that don't like dots in folder names. */ - { "status_on_top", DT_BOOL, R_BOTH|R_REFLOW, OPTSTATUSONTOP, 0 }, + { "status_on_top", DT_BOOL, R_REFLOW, OPTSTATUSONTOP, 0 }, /* ** .pp ** Setting this variable causes the ``status bar'' to be displayed on diff --git a/mbyte.c b/mbyte.c index 478fcdc5412..cef56e1f468 100644 --- a/mbyte.c +++ b/mbyte.c @@ -530,6 +530,8 @@ int is_display_corrupting_utf8 (wchar_t wc) wc == (wchar_t)0x200e || wc == (wchar_t)0x00ad || /* soft hyphen: #3848 */ wc == (wchar_t)0xfeff || /* zero width no-break space */ + (wc >= (wchar_t)0x2066 && /* misc directional markers */ + wc <= (wchar_t)0x2069) || (wc >= (wchar_t)0x202a && /* misc directional markers: #3854 */ wc <= (wchar_t)0x202e)) return 1; diff --git a/menu.c b/menu.c index 3679d423beb..82682859bef 100644 --- a/menu.c +++ b/menu.c @@ -27,6 +27,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 int get_color (int index, unsigned char *s) { @@ -302,7 +307,7 @@ void menu_redraw_status (MUTTMENU *menu) #ifdef USE_SIDEBAR void menu_redraw_sidebar (MUTTMENU *menu) { - SidebarNeedsRedraw = 0; + menu->redraw &= ~REDRAW_SIDEBAR; mutt_sb_draw (); } #endif @@ -454,7 +459,7 @@ void menu_check_recenter (MUTTMENU *menu) if (menu->top != 0) { menu->top = 0; - set_option (OPTNEEDREDRAW); + menu->redraw |= REDRAW_INDEX; } } else @@ -774,6 +779,7 @@ MUTTMENU *mutt_new_menu (int menu) p->messagewin = MuttMessageWindow; p->color = default_color; p->search = menu_search_generic; + return p; } @@ -792,6 +798,72 @@ void mutt_menu_destroy (MUTTMENU **p) FREE (p); /* __FREE_CHECKED__ */ } +static MUTTMENU *get_current_menu (void) +{ + return MenuStackCount ? MenuStack[MenuStackCount - 1] : NULL; +} + +void mutt_push_current_menu (MUTTMENU *menu) +{ + if (MenuStackCount >= MenuStackLen) + { + MenuStackLen += 5; + safe_realloc (&MenuStack, MenuStackLen * sizeof(MUTTMENU *)); + } + + MenuStack[MenuStackCount++] = menu; + CurrentMenu = menu->menu; +} + +void mutt_pop_current_menu (MUTTMENU *menu) +{ + MUTTMENU *prev_menu; + + if (!MenuStackCount || + (MenuStack[MenuStackCount - 1] != menu)) + { + mutt_debug (1, "mutt_pop_current_menu() called with inactive menu\n"); + return; + } + + MenuStackCount--; + prev_menu = get_current_menu (); + if (prev_menu) + { + CurrentMenu = prev_menu->menu; + prev_menu->redraw = REDRAW_FULL; + } + else + { + CurrentMenu = MENU_MAIN; + } +} + +void mutt_set_current_menu_redraw (int redraw) +{ + MUTTMENU *current_menu; + + current_menu = get_current_menu (); + if (current_menu) + current_menu->redraw |= redraw; +} + +void mutt_set_current_menu_redraw_full (void) +{ + MUTTMENU *current_menu; + + current_menu = get_current_menu (); + if (current_menu) + current_menu->redraw = REDRAW_FULL; +} + +void mutt_set_menu_redraw_full (int menu_type) +{ + if (CurrentMenu == menu_type) + mutt_set_current_menu_redraw_full (); +} + + #define MUTT_SEARCH_UP 1 #define MUTT_SEARCH_DOWN 2 @@ -917,7 +989,7 @@ int menu_redraw (MUTTMENU *menu) if (menu->redraw & REDRAW_STATUS) menu_redraw_status (menu); #ifdef USE_SIDEBAR - if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw) + if (menu->redraw & REDRAW_SIDEBAR) menu_redraw_sidebar (menu); #endif if (menu->redraw & REDRAW_INDEX) @@ -1104,14 +1176,7 @@ int mutt_menu_loop (MUTTMENU *menu) break; case OP_ENTER_COMMAND: - CurrentMenu = menu->menu; mutt_enter_command (); - if (option (OPTFORCEREDRAWINDEX)) - { - menu->redraw = REDRAW_FULL; - unset_option (OPTFORCEREDRAWINDEX); - unset_option (OPTFORCEREDRAWPAGER); - } break; case OP_TAG: @@ -1144,7 +1209,6 @@ int mutt_menu_loop (MUTTMENU *menu) case OP_SHELL_ESCAPE: mutt_shell_escape (); - MAYBE_REDRAW (menu->redraw); break; case OP_WHAT_KEY: diff --git a/mutt.h b/mutt.h index 48ba7c67392..8030a530ba0 100644 --- a/mutt.h +++ b/mutt.h @@ -565,7 +565,6 @@ enum OPTFORCEREFRESH, /* (pseudo) refresh even during macros */ OPTLOCALES, /* (pseudo) set if user has valid locale definition */ OPTNOCURSES, /* (pseudo) when sending in batch mode */ - OPTNEEDREDRAW, /* (pseudo) to notify caller of a submenu */ OPTSEARCHREVERSE, /* (pseudo) used by ci_search_command */ OPTMSGERR, /* (pseudo) used by mutt_error/mutt_message */ OPTSEARCHINVALID, /* (pseudo) used to invalidate the search pat */ @@ -574,8 +573,6 @@ enum OPTNEEDRESORT, /* (pseudo) used to force a re-sort */ OPTRESORTINIT, /* (pseudo) used to force the next resort to be from scratch */ OPTVIEWATTACH, /* (pseudo) signals that we are viewing attachments */ - OPTFORCEREDRAWINDEX, /* (pseudo) used to force a redraw in the main index */ - OPTFORCEREDRAWPAGER, /* (pseudo) used to force a redraw in the pager */ OPTSORTSUBTHREADS, /* (pseudo) used when $sort_aux changes */ OPTNEEDRESCORE, /* (pseudo) set when the `score' command is used */ OPTATTACHMSG, /* (pseudo) used by attach-message */ diff --git a/mutt_crypt.h b/mutt_crypt.h index 08bd3e463c9..7d36c17189a 100644 --- a/mutt_crypt.h +++ b/mutt_crypt.h @@ -230,7 +230,7 @@ BODY *crypt_pgp_encrypt_message (BODY *a, char *keylist, int sign); /* Invoke the PGP command to import a key. */ void crypt_pgp_invoke_import (const char *fname); -int crypt_pgp_send_menu (HEADER *msg, int *redraw); +int crypt_pgp_send_menu (HEADER *msg); /* fixme: needs documentation */ int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf); @@ -276,7 +276,7 @@ BODY *crypt_smime_build_smime_entity (BODY *a, char *certlist); /* Add a certificate and update index file (externally). */ void crypt_smime_invoke_import (char *infile, char *mailbox); -int crypt_smime_send_menu (HEADER *msg, int *redraw); +int crypt_smime_send_menu (HEADER *msg); void crypt_smime_set_sender (const char *sender); diff --git a/mutt_curses.h b/mutt_curses.h index 766078a4ce7..21e9c65326b 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -256,6 +256,4 @@ void ci_start_color (void); /* reset the color to the normal terminal color as defined by 'color normal ...' */ #define NORMAL_COLOR SETCOLOR(MT_COLOR_NORMAL) -#define MAYBE_REDRAW(x) if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); x = REDRAW_FULL; } - #endif /* _MUTT_CURSES_H */ diff --git a/mutt_menu.h b/mutt_menu.h index 606183d75b1..74755ccc3c9 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -119,6 +119,11 @@ void mutt_ts_icon(char *str); MUTTMENU *mutt_new_menu(int menu); void mutt_menu_destroy(MUTTMENU **p); +void mutt_push_current_menu (MUTTMENU *); +void mutt_pop_current_menu (MUTTMENU *); +void mutt_set_current_menu_redraw (int redraw); +void mutt_set_current_menu_redraw_full (); +void mutt_set_menu_redraw_full (int); int mutt_menu_loop(MUTTMENU *menu); /* used in both the index and pager index to make an entry. */ diff --git a/mutt_ssl.c b/mutt_ssl.c index 3670b19a4a5..ba40dcec668 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -765,6 +765,8 @@ static int interactive_check_cert (X509 *cert, int idx, int len, SSL *ssl, int a FILE *fp = NULL; int allow_skip = 0; + mutt_push_current_menu (menu); + menu->max = mutt_array_size (part) * 2 + 10; menu->dialog = safe_calloc (1, menu->max * sizeof (char *)); for (i = 0; i < menu->max; i++) @@ -897,8 +899,8 @@ static int interactive_check_cert (X509 *cert, int idx, int len, SSL *ssl, int a } } unset_option(OPTIGNOREMACROEVENTS); + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); - set_option (OPTNEEDREDRAW); mutt_debug (2, "ssl interactive_check_cert: done=%d\n", done); return (done == 2); } diff --git a/mutt_ssl_gnutls.c b/mutt_ssl_gnutls.c index 2b31b499c1f..57e96233a2f 100644 --- a/mutt_ssl_gnutls.c +++ b/mutt_ssl_gnutls.c @@ -570,6 +570,7 @@ static int tls_check_one_certificate (const gnutls_datum_t *certdata, menu->dialog = safe_calloc (1, menu->max * sizeof (char *)); for (i = 0; i < menu->max; i++) menu->dialog[i] = safe_calloc (1, SHORT_STRING * sizeof (char)); + mutt_push_current_menu (menu); row = 0; strfcpy (menu->dialog[row], _("This certificate belongs to:"), SHORT_STRING); @@ -773,6 +774,7 @@ static int tls_check_one_certificate (const gnutls_datum_t *certdata, } } unset_option (OPTIGNOREMACROEVENTS); + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); gnutls_x509_crt_deinit (cert); diff --git a/pager.c b/pager.c index 9330d0ca308..3453b26ef5c 100644 --- a/pager.c +++ b/pager.c @@ -1661,7 +1661,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) int i, j, ch = 0, rc = -1, hideQuoted = 0, q_level = 0, force_redraw = 0; int lines = 0, curline = 0, topline = 0, oldtopline = 0, err, first = 1; int r = -1, wrapped = 0, searchctx = 0; - int redraw = REDRAW_FULL; FILE *fp = NULL; LOFF_T last_pos = 0, last_offset = 0; int old_smart_wrap, old_markers; @@ -1675,6 +1674,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_window_t *pager_status_window = NULL; mutt_window_t *pager_window = NULL; + MUTTMENU *pager_menu = NULL; MUTTMENU *index = NULL; /* the Pager Index (PI) */ int indexlen = PagerIndexLines; /* indexlen not always == PIL */ int indicator = indexlen / 3; /* the indicator line of the PI */ @@ -1746,11 +1746,14 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) pager_status_window = safe_calloc (1, sizeof (mutt_window_t)); pager_window = safe_calloc (1, sizeof (mutt_window_t)); + pager_menu = mutt_new_menu (MENU_PAGER); + mutt_push_current_menu (pager_menu); + while (ch != -1) { mutt_curs_set (0); - if (redraw & REDRAW_FULL) + if (pager_menu->redraw & REDRAW_FULL) { #if ! (defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)) mutt_reflow_windows (); @@ -1817,7 +1820,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) SearchBack = Resize->SearchBack; } lines = Resize->line; - redraw |= REDRAW_SIGWINCH; + pager_menu->redraw |= REDRAW_SIGWINCH; FREE (&Resize); } @@ -1852,14 +1855,14 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) menu_redraw_index(index); } - redraw |= REDRAW_BODY | REDRAW_INDEX | REDRAW_STATUS; + pager_menu->redraw |= REDRAW_BODY | REDRAW_INDEX | REDRAW_STATUS; #ifdef USE_SIDEBAR - redraw |= REDRAW_SIDEBAR; + pager_menu->redraw |= REDRAW_SIDEBAR; #endif mutt_show_error (); } - if (redraw & REDRAW_SIGWINCH) + if (pager_menu->redraw & REDRAW_SIGWINCH) { i = -1; j = -1; @@ -1875,14 +1878,13 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } #ifdef USE_SIDEBAR - if ((redraw & REDRAW_SIDEBAR) || SidebarNeedsRedraw) + if (pager_menu->redraw & REDRAW_SIDEBAR) { - SidebarNeedsRedraw = 0; - mutt_sb_draw (); + menu_redraw_sidebar (pager_menu); } #endif - if ((redraw & REDRAW_BODY) || topline != oldtopline) + if ((pager_menu->redraw & REDRAW_BODY) || topline != oldtopline) { do { mutt_window_move (pager_window, 0, 0); @@ -1918,10 +1920,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) /* We are going to update the pager status bar, so it isn't * necessary to reset to normal color now. */ - redraw |= REDRAW_STATUS; /* need to update the % seen */ + pager_menu->redraw |= REDRAW_STATUS; /* need to update the % seen */ } - if (redraw & REDRAW_STATUS) + if (pager_menu->redraw & REDRAW_STATUS) { struct hdr_format_info hfi; char pager_progress_str[4]; @@ -1968,7 +1970,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) /* redraw the pager_index indicator, because the * flags for this message might have changed. */ - if ((redraw & REDRAW_INDEX) && index && (index_window->rows > 0)) + if ((pager_menu->redraw & REDRAW_INDEX) && index && (index_window->rows > 0)) { menu_redraw_current (index); @@ -1981,7 +1983,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) NORMAL_COLOR; } - redraw = 0; + pager_menu->redraw = 0; if (option(OPTBRAILLEFRIENDLY)) { if (brailleLine!=-1) { @@ -2024,7 +2026,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) { /* fatal error occurred */ FREE (&Context); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; ch = -1; break; } @@ -2071,7 +2073,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } } - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; set_option (OPTSEARCHINVALID); } } @@ -2136,7 +2138,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) lastLine = 0; topline = 0; - redraw = REDRAW_FULL | REDRAW_SIGWINCH; + pager_menu->redraw = REDRAW_FULL | REDRAW_SIGWINCH; ch = 0; } @@ -2434,14 +2436,14 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } } - redraw = REDRAW_BODY; + pager_menu->redraw = REDRAW_BODY; break; case OP_SEARCH_TOGGLE: if (SearchCompiled) { SearchFlag ^= MUTT_SEARCH; - redraw = REDRAW_BODY; + pager_menu->redraw = REDRAW_BODY; } break; @@ -2451,7 +2453,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) { InHelp = 1; mutt_help (MENU_PAGER); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; InHelp = 0; } else @@ -2465,7 +2467,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) if (hideQuoted && lineInfo[topline].type == MT_COLOR_QUOTED) topline = up_n_lines (1, lineInfo, topline, hideQuoted); else - redraw = REDRAW_BODY; + pager_menu->redraw = REDRAW_BODY; } break; @@ -2537,7 +2539,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) case OP_REDRAW: clearok (stdscr, true); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_NULL: @@ -2557,7 +2559,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) extra->idx, extra->idxlen, extra->bdy); else - ci_bounce_message (extra->hdr, &redraw); + ci_bounce_message (extra->hdr); break; case OP_RESEND: @@ -2569,12 +2571,12 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) extra->bdy); else mutt_resend_message (NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_COMPOSE_TO_SENDER: mutt_compose_to_sender (extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_CHECK_TRADITIONAL: @@ -2594,7 +2596,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_create_alias (extra->bdy->hdr->env, NULL); else mutt_create_alias (extra->hdr->env, NULL); - MAYBE_REDRAW (redraw); break; case OP_PURGE_MESSAGE: @@ -2608,7 +2609,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_set_flag (Context, extra->hdr, MUTT_PURGE, (ch == OP_PURGE_MESSAGE)); if (option (OPTDELETEUNTAG)) mutt_set_flag (Context, extra->hdr, MUTT_TAG, 0); - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { ch = -1; @@ -2622,7 +2623,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) CHECK_READONLY; if (mutt_change_flag (extra->hdr, (ch == OP_MAIN_SET_FLAG)) == 0) - redraw |= REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX; if (extra->hdr->deleted && option (OPTRESOLVE)) { ch = -1; @@ -2659,9 +2660,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } if (!option (OPTRESOLVE) && PagerIndexLines) - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; else - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; } break; @@ -2678,7 +2679,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) old_markers = option (OPTMARKERS); old_PagerIndexLines = PagerIndexLines; - CurrentMenu = MENU_PAGER; mutt_enter_command (); if (option (OPTNEEDRESORT)) @@ -2753,10 +2753,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) ch = 0; } - if (option (OPTFORCEREDRAWPAGER)) - redraw = REDRAW_FULL; - unset_option (OPTFORCEREDRAWINDEX); - unset_option (OPTFORCEREDRAWPAGER); break; case OP_FLAG_MESSAGE: @@ -2766,7 +2762,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) CHECK_ACL(MUTT_ACL_WRITE, "Cannot flag message"); mutt_set_flag (Context, extra->hdr, MUTT_FLAG, !extra->hdr->flagged); - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { ch = -1; @@ -2780,7 +2776,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_pipe_attachment_list (extra->fp, 0, extra->bdy, 0); else mutt_pipe_message (extra->hdr); - MAYBE_REDRAW (redraw); break; case OP_PRINT: @@ -2795,7 +2790,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) CHECK_MODE(IsHeader (extra) && !IsAttach (extra)); CHECK_ATTACH; ci_send_message (0, NULL, NULL, extra->ctx, NULL); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; #ifdef USE_NNTP @@ -2807,7 +2802,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) query_quadoption (OPT_TOMODERATED,_("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES) break; ci_send_message (SENDNEWS, NULL, NULL, extra->ctx, NULL); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_FORWARD_TO_GROUP: @@ -2822,7 +2817,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) extra->idxlen, extra->bdy, SENDNEWS); else ci_send_message (SENDNEWS|SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_FOLLOWUP: @@ -2847,7 +2842,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) else ci_send_message (SENDNEWS|SENDREPLY, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; } #endif @@ -2861,14 +2856,14 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) SENDREPLY); else ci_send_message (SENDREPLY, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_RECALL_MESSAGE: CHECK_MODE(IsHeader (extra) && !IsAttach(extra)); CHECK_ATTACH; ci_send_message (SENDPOSTPONED, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_GROUP_REPLY: @@ -2879,7 +2874,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) extra->idxlen, extra->bdy, SENDREPLY|SENDGROUPREPLY); else ci_send_message (SENDREPLY | SENDGROUPREPLY, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_LIST_REPLY: @@ -2890,7 +2885,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) extra->idxlen, extra->bdy, SENDREPLY|SENDLISTREPLY); else ci_send_message (SENDREPLY | SENDLISTREPLY, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_FORWARD_MESSAGE: @@ -2901,7 +2896,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) extra->idxlen, extra->bdy, 0); else ci_send_message (SENDFORWARD, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_DECRYPT_SAVE: @@ -2933,8 +2928,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) (ch == OP_SAVE) || (ch == OP_DECODE_SAVE), (ch == OP_DECODE_SAVE) || (ch == OP_DECODE_COPY), (ch == OP_DECRYPT_SAVE) || (ch == OP_DECRYPT_COPY) || - 0, - &redraw) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE + 0) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE || ch == OP_DECRYPT_SAVE )) { @@ -2944,14 +2938,12 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) rc = OP_MAIN_NEXT_UNDELETED; } else - redraw |= REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX; } - MAYBE_REDRAW (redraw); break; case OP_SHELL_ESCAPE: mutt_shell_escape (); - MAYBE_REDRAW (redraw); break; case OP_TAG: @@ -2965,7 +2957,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) ? NULL : Context->last_tag); } - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { ch = -1; @@ -2985,7 +2977,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_set_flag (Context, extra->hdr, MUTT_READ, 1); first = 0; Context->msgnotreadyet = -1; - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { ch = -1; @@ -3001,7 +2993,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_set_flag (Context, extra->hdr, MUTT_DELETE, 0); mutt_set_flag (Context, extra->hdr, MUTT_PURGE, 0); - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { ch = -1; @@ -3031,9 +3023,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } if (!option (OPTRESOLVE) && PagerIndexLines) - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; else - redraw = REDRAW_STATUS | REDRAW_INDEX; + pager_menu->redraw = REDRAW_STATUS | REDRAW_INDEX; } break; @@ -3056,7 +3048,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) mutt_view_attachments (extra->hdr); if (Context && extra->hdr->attach_del) Context->changed = 1; - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_MAIL_KEY: @@ -3068,7 +3060,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) CHECK_MODE(IsHeader(extra)); CHECK_ATTACH; ci_send_message (SENDKEY, NULL, NULL, extra->ctx, extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_EDIT_LABEL: @@ -3076,7 +3068,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) rc = mutt_label_message(extra->hdr); if (rc > 0) { Context->changed = 1; - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; mutt_message (_("%d labels changed."), rc); } else { @@ -3096,7 +3088,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } CHECK_MODE(IsHeader(extra)); crypt_extract_keys_from_messages(extra->hdr); - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; break; case OP_WHAT_KEY: @@ -3116,7 +3108,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) case OP_SIDEBAR_TOGGLE_VISIBLE: toggle_option (OPTSIDEBAR); mutt_reflow_windows(); - redraw = REDRAW_FULL; break; #endif @@ -3158,6 +3149,8 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) SearchCompiled = 0; } FREE (&lineInfo); + mutt_pop_current_menu (pager_menu); + mutt_menu_destroy (&pager_menu); if (index) mutt_menu_destroy(&index); diff --git a/pgp.c b/pgp.c index 83991744969..ee64616e74d 100644 --- a/pgp.c +++ b/pgp.c @@ -1614,7 +1614,7 @@ BODY *pgp_traditional_encryptsign (BODY *a, int flags, char *keylist) return b; } -int pgp_send_menu (HEADER *msg, int *redraw) +int pgp_send_menu (HEADER *msg) { pgp_key_t p; char input_signas[SHORT_STRING]; @@ -1769,7 +1769,6 @@ int pgp_send_menu (HEADER *msg, int *redraw) crypt_pgp_void_passphrase (); /* probably need a different passphrase */ } - *redraw = REDRAW_FULL; break; case 'b': /* (b)oth */ diff --git a/pgp.h b/pgp.h index b31bec2441a..5236bf692d5 100644 --- a/pgp.h +++ b/pgp.h @@ -90,7 +90,7 @@ BODY *pgp_traditional_encryptsign(BODY *a, int flags, char *keylist); BODY *pgp_encrypt_message(BODY *a, char *keylist, int sign); BODY *pgp_sign_message(BODY *a); -int pgp_send_menu(HEADER *msg, int *redraw); +int pgp_send_menu(HEADER *msg); #endif /* CRYPT_BACKEND_CLASSIC_PGP */ diff --git a/pgpkey.c b/pgpkey.c index 00e4347e861..e6686b7c874 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -520,6 +520,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); @@ -639,11 +640,10 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); FREE (&KeyTable); - set_option (OPTNEEDREDRAW); - return kp; } diff --git a/postpone.c b/postpone.c index b6746001aa7..8e10c837b70 100644 --- a/postpone.c +++ b/postpone.c @@ -174,6 +174,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 @@ -218,6 +219,7 @@ static HEADER *select_msg (void) } Sort = orig_sort; + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); return (r > -1 ? PostContext->hdrs[r] : NULL); } diff --git a/protos.h b/protos.h index 7aebc7028a4..2c980ca5f01 100644 --- a/protos.h +++ b/protos.h @@ -315,9 +315,9 @@ int mutt_parent_message(CONTEXT *ctx, HEADER *hdr, int find_root); int mutt_prepare_template(FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr, short resend); int mutt_resend_message(FILE *fp, CONTEXT *ctx, HEADER *cur); int mutt_compose_to_sender(HEADER *hdr); -#define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL,0) -#define mutt_enter_vfolder(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL,MUTT_SEL_VFOLDER) -int _mutt_enter_fname(const char *prompt, char *buf, size_t blen, int *redraw, int buffy, +#define mutt_enter_fname(A,B,C,D) _mutt_enter_fname(A,B,C,D,0,NULL,NULL,0) +#define mutt_enter_vfolder(A,B,C,D) _mutt_enter_fname(A,B,C,D,0,NULL,NULL,MUTT_SEL_VFOLDER) +int _mutt_enter_fname(const char *prompt, char *buf, size_t blen, int buffy, int multiple, char ***files, int *numfiles, int flags); int mutt_enter_string(char *buf, size_t buflen, int col, int flags); int _mutt_enter_string(char *buf, size_t buflen, int col, int flags, int multiple, @@ -371,7 +371,7 @@ int mutt_query_complete(char *buf, size_t buflen); int mutt_query_variables(LIST *queries); int mutt_save_attachment(FILE *fp, BODY *m, char *path, int flags, HEADER *hdr); int _mutt_save_message(HEADER *h, CONTEXT *ctx, int delete, int decode, int decrypt); -int mutt_save_message(HEADER *h, int delete, int decode, int decrypt, int *redraw); +int mutt_save_message(HEADER *h, int delete, int decode, int decrypt); int mutt_search_command(int cur, int op); #ifdef USE_SMTP int mutt_smtp_send(const ADDRESS *from, const ADDRESS *to, const ADDRESS *cc, @@ -484,7 +484,7 @@ int setegid (gid_t); #endif /* _AIX */ /* unsorted */ -void ci_bounce_message(HEADER *h, int *redraw); +void ci_bounce_message(HEADER *h); int ci_send_message(int flags, HEADER *msg, char *tempfile, CONTEXT *ctx, HEADER *cur); /* prototypes for compatibility functions */ diff --git a/query.c b/query.c index 5c3a43d0578..601864e0e37 100644 --- a/query.c +++ b/query.c @@ -270,6 +270,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) { @@ -326,6 +327,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) menu->current = 0; + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); menu = mutt_new_menu (MENU_QUERY); menu->make_entry = query_entry; @@ -333,6 +335,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) @@ -477,11 +480,9 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) free_query (&results); FREE (&QueryTable); - - /* tell whoever called me to redraw the screen when I return */ - set_option (OPTNEEDREDRAW); } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); } int mutt_query_complete (char *buf, size_t buflen) diff --git a/recvattach.c b/recvattach.c index 48c1a3d76be..94ace2329b6 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1032,6 +1032,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); @@ -1306,6 +1307,7 @@ void mutt_view_attachments (HEADER *hdr) mutt_free_body (&cur); } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); return; } diff --git a/remailer.c b/remailer.c index 68483a9514a..d7428324c0c 100644 --- a/remailer.c +++ b/remailer.c @@ -464,7 +464,7 @@ static const struct mapping_t RemailerHelp[] = }; -void mix_make_chain (LIST **chainp, int *redraw) +void mix_make_chain (LIST **chainp) { LIST *p = NULL; MIXCHAIN *chain = NULL; @@ -490,8 +490,6 @@ void mix_make_chain (LIST **chainp, int *redraw) return; } - *redraw = REDRAW_FULL; - chain = safe_calloc (sizeof (MIXCHAIN), 1); for (p = *chainp; p; p = p->next) mix_chain_add (chain, (char *) p->data, type2_list); @@ -515,6 +513,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) { @@ -650,6 +649,7 @@ void mix_make_chain (LIST **chainp, int *redraw) } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); /* construct the remailer list */ diff --git a/remailer.h b/remailer.h index f148d626f48..2890551a5de 100644 --- a/remailer.h +++ b/remailer.h @@ -55,7 +55,7 @@ typedef struct mixchain MIXCHAIN; int mix_send_message(LIST *chain, const char *tempfile); int mix_check_message(HEADER *msg); -void mix_make_chain(LIST **chainp, int *redraw); +void mix_make_chain(LIST **chainp); #endif /* MIXMASTER */ diff --git a/score.c b/score.c index 64d02632e62..d3da8b11e53 100644 --- a/score.c +++ b/score.c @@ -18,6 +18,7 @@ #include "config.h" #include "mutt.h" +#include "mutt_menu.h" #include "sort.h" #include #include @@ -48,8 +49,8 @@ void mutt_check_rescore (CONTEXT *ctx) } /* must redraw the index since the user might have %N in it */ - set_option (OPTFORCEREDRAWINDEX); - set_option (OPTFORCEREDRAWPAGER); + mutt_set_menu_redraw_full (MENU_MAIN); + mutt_set_menu_redraw_full (MENU_PAGER); for (i = 0; ctx && i < ctx->msgcount; i++) { diff --git a/sidebar.c b/sidebar.c index 62d0e4868d7..c4c88b60196 100644 --- a/sidebar.c +++ b/sidebar.c @@ -1056,7 +1056,7 @@ void mutt_sb_change_mailbox (int op) default: return; } - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); } /** @@ -1198,7 +1198,7 @@ void mutt_sb_notify_mailbox (BUFFY *b, int created) Entries[del_index] = Entries[del_index + 1]; } - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); } /** @@ -1230,6 +1230,6 @@ mutt_sb_toggle_virtual (void) for (b = get_incoming(); b; b = b->next) mutt_sb_notify_mailbox (b, 1); - SidebarNeedsRedraw = 1; + mutt_set_current_menu_redraw (REDRAW_SIDEBAR); } diff --git a/smime.c b/smime.c index 706b82a7738..307a77865ba 100644 --- a/smime.c +++ b/smime.c @@ -442,6 +442,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(); @@ -488,9 +489,9 @@ static smime_key_t *smime_select_key (smime_key_t *keys, char *query) } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); FREE (&table); - set_option (OPTNEEDREDRAW); return selected_key; } @@ -2084,7 +2085,7 @@ int smime_application_smime_handler (BODY *m, STATE *s) return smime_handle_entity (m, s, NULL) ? 0 : -1; } -int smime_send_menu (HEADER *msg, int *redraw) +int smime_send_menu (HEADER *msg) { smime_key_t *key = NULL; char *prompt = NULL, *letters = NULL, *choices = NULL; @@ -2217,8 +2218,6 @@ int smime_send_menu (HEADER *msg, int *redraw) case 'S': /* (s)ign in oppenc mode */ if(!SmimeDefaultKey) { - *redraw = REDRAW_FULL; - if ((key = smime_ask_for_key (_("Sign as: "), KEYFLAG_CANSIGN, 0))) { mutt_str_replace (&SmimeDefaultKey, key->hash); @@ -2245,7 +2244,6 @@ int smime_send_menu (HEADER *msg, int *redraw) crypt_smime_void_passphrase (); } - *redraw = REDRAW_FULL; break; case 'b': /* (b)oth */ diff --git a/smime.h b/smime.h index f8e618d46af..7267dbbc841 100644 --- a/smime.h +++ b/smime.h @@ -57,7 +57,7 @@ char *smime_find_keys(ADDRESS *adrlist, int oppenc_mode); void smime_invoke_import(char *infile, char *mailbox); -int smime_send_menu(HEADER *msg, int *redraw); +int smime_send_menu(HEADER *msg); #endif