From b6e96922cf672a2c1c0465444ebd9c0c7d161187 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 12:27:15 -0700 Subject: [PATCH 01/12] Fix mutt_refresh() pausing during macro events. Changeset a07e8215a0ef split input buffering into two pools. Unfortunately, the mutt_refresh() was not changed to check the correct buffer count, resulting in unnecessary refreshes during macros. The SSL interactive certificate prompts set OPTIGNOREMACROEVENTS and then put up a confirmation menu. Perhaps we've just been lucky, but it seems we should refresh the screen in those cases if we're in the middle of a macro. Add a check for this option in mutt_refresh() too. --- curs_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/curs_lib.c b/curs_lib.c index 87c5822cbda..1eb17e50f0c 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 */ From f69d354e1e5e4d2b3b804698546bcb8c83c6a920 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 18:31:39 -0700 Subject: [PATCH 02/12] 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. --- addrbook.c | 2 + browser.c | 12 +++-- compose.c | 2 + crypt-gpgme.c | 2 + curs_main.c | 2 + menu.c | 30 ++++++++++++ mutt_menu.h | 2 + mutt_ssl.c | 3 ++ mutt_ssl_gnutls.c | 2 + pager.c | 113 ++++++++++++++++++++++++---------------------- pgpkey.c | 2 + postpone.c | 2 + query.c | 4 ++ recvattach.c | 2 + remailer.c | 2 + smime.c | 2 + 16 files changed, 125 insertions(+), 59 deletions(-) diff --git a/addrbook.c b/addrbook.c index 50e19fadb6d..67f8229659b 100644 --- a/addrbook.c +++ b/addrbook.c @@ -151,6 +151,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: @@ -234,6 +235,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..e73a66f9e0e 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: @@ -1620,7 +1620,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; } } @@ -1690,7 +1689,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; @@ -1827,7 +1825,6 @@ 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); @@ -1845,7 +1842,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 +2048,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/compose.c b/compose.c index ab6120297fa..f08f5e2add4 100644 --- a/compose.c +++ b/compose.c @@ -573,6 +573,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) { @@ -1494,6 +1495,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..4eda2771de8 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,6 +4116,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); FREE (&key_table); diff --git a/curs_main.c b/curs_main.c index 592c3a81d4b..9758c753d6d 100644 --- a/curs_main.c +++ b/curs_main.c @@ -842,6 +842,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 */ @@ -3229,6 +3230,7 @@ int mutt_index_menu (void) if (done) break; } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); return close; } diff --git a/menu.c b/menu.c index 3679d423beb..f0e8f0b672f 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) { @@ -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,30 @@ void mutt_menu_destroy (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)) + { + mutt_debug (1, "mutt_pop_current_menu() called with inactive menu\n"); + return; + } + + MenuStackCount--; +} + + #define MUTT_SEARCH_UP 1 #define MUTT_SEARCH_DOWN 2 diff --git a/mutt_menu.h b/mutt_menu.h index 606183d75b1..2d85318838e 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -119,6 +119,8 @@ 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 *); 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..85627cc4e57 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,6 +899,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_menu_destroy (&menu); set_option (OPTNEEDREDRAW); mutt_debug (2, "ssl interactive_check_cert: done=%d\n", done); 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..b06bd9d31b6 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,14 @@ 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) { SidebarNeedsRedraw = 0; mutt_sb_draw (); } #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 +1921,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 +1971,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 +1984,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 +2027,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 +2074,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 +2139,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 +2437,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 +2454,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 +2468,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 +2540,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 +2560,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, &pager_menu->redraw); break; case OP_RESEND: @@ -2569,12 +2572,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 +2597,7 @@ 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); + MAYBE_REDRAW (pager_menu->redraw); break; case OP_PURGE_MESSAGE: @@ -2608,7 +2611,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 +2625,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 +2662,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; @@ -2754,7 +2757,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } if (option (OPTFORCEREDRAWPAGER)) - redraw = REDRAW_FULL; + pager_menu->redraw = REDRAW_FULL; unset_option (OPTFORCEREDRAWINDEX); unset_option (OPTFORCEREDRAWPAGER); break; @@ -2766,7 +2769,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 +2783,7 @@ 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); + MAYBE_REDRAW (pager_menu->redraw); break; case OP_PRINT: @@ -2795,7 +2798,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 +2810,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 +2825,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 +2850,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 +2864,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 +2882,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 +2893,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 +2904,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: @@ -2934,7 +2937,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) (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 + &pager_menu->redraw) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE || ch == OP_DECRYPT_SAVE )) { @@ -2944,14 +2947,14 @@ 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); + MAYBE_REDRAW (pager_menu->redraw); break; case OP_SHELL_ESCAPE: mutt_shell_escape (); - MAYBE_REDRAW (redraw); + MAYBE_REDRAW (pager_menu->redraw); break; case OP_TAG: @@ -2965,7 +2968,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 +2988,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 +3004,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 +3034,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 +3059,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 +3071,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 +3079,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 +3099,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 +3119,7 @@ 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; + pager_menu->redraw = REDRAW_FULL; break; #endif @@ -3158,6 +3161,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/pgpkey.c b/pgpkey.c index 00e4347e861..7747a59d78e 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,6 +640,7 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, } } + mutt_pop_current_menu (menu); mutt_menu_destroy (&menu); FREE (&KeyTable); 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/query.c b/query.c index 5c3a43d0578..8b9d839b82a 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) @@ -482,6 +485,7 @@ static void query_menu (char *buf, size_t buflen, QUERY *results, int retbuf) 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..a56499af2d2 100644 --- a/remailer.c +++ b/remailer.c @@ -515,6 +515,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 +651,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/smime.c b/smime.c index 706b82a7738..e7f031128fe 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,6 +489,7 @@ 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); From f6fb63f276f2cc53568c8bee70840def4ad2fc0d Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 18:31:40 -0700 Subject: [PATCH 03/12] 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. --- curs_main.c | 26 ++++++++++++++++++-------- menu.c | 10 +++++++++- pager.c | 1 - 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/curs_main.c b/curs_main.c index 9758c753d6d..7f9846c7fc9 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, @@ -2077,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) @@ -2777,7 +2788,6 @@ int mutt_index_menu (void) case OP_ENTER_COMMAND: - CurrentMenu = MENU_MAIN; mutt_enter_command (); mutt_check_rescore (Context); if (option (OPTFORCEREDRAWINDEX)) diff --git a/menu.c b/menu.c index f0e8f0b672f..dc49d739eec 100644 --- a/menu.c +++ b/menu.c @@ -807,6 +807,7 @@ void mutt_push_current_menu (MUTTMENU *menu) } MenuStack[MenuStackCount++] = menu; + CurrentMenu = menu->menu; } void mutt_pop_current_menu (MUTTMENU *menu) @@ -819,6 +820,14 @@ void mutt_pop_current_menu (MUTTMENU *menu) } MenuStackCount--; + if (MenuStackCount) + { + CurrentMenu = MenuStack[MenuStackCount - 1]->menu; + } + else + { + CurrentMenu = MENU_MAIN; + } } @@ -1134,7 +1143,6 @@ int mutt_menu_loop (MUTTMENU *menu) break; case OP_ENTER_COMMAND: - CurrentMenu = menu->menu; mutt_enter_command (); if (option (OPTFORCEREDRAWINDEX)) { diff --git a/pager.c b/pager.c index b06bd9d31b6..ccd90559467 100644 --- a/pager.c +++ b/pager.c @@ -2681,7 +2681,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)) From e3c3eaaa37e13ec7139698a89d7e06a2e0b7522b Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 18:31:41 -0700 Subject: [PATCH 04/12] Set refresh when popping the menu stack. This removes the need for the OPTNEEDREDRAW option and MAYBE_REDRAW macro previously used to communicate back the need to refresh after exiting a menu. Remove the redraw parameter from ci_bounce_message() and mix_make_chain() which served the same purpose. --- addrbook.c | 3 --- browser.c | 6 ------ commands.c | 9 +-------- compose.c | 30 +++++++----------------------- crypt-gpgme.c | 2 -- curs_lib.c | 3 +-- curs_main.c | 6 +----- enter.c | 2 -- menu.c | 25 +++++++++++++++++++++---- mutt.h | 1 - mutt_curses.h | 2 -- mutt_menu.h | 1 + mutt_ssl.c | 1 - pager.c | 6 +----- pgpkey.c | 2 -- protos.h | 2 +- query.c | 3 --- remailer.c | 4 +--- remailer.h | 2 +- smime.c | 1 - 20 files changed, 36 insertions(+), 75 deletions(-) diff --git a/addrbook.c b/addrbook.c index 67f8229659b..8afd16a8a20 100644 --- a/addrbook.c +++ b/addrbook.c @@ -143,9 +143,6 @@ 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; diff --git a/browser.c b/browser.c index e73a66f9e0e..0b072cfa969 100644 --- a/browser.c +++ b/browser.c @@ -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 @@ -1633,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: @@ -1699,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,7 +1822,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num destroy_state (&state); goto bail; } - MAYBE_REDRAW (menu->redraw); break; case OP_BROWSER_VIEW_FILE: diff --git a/commands.c b/commands.c index e7d4339cdd8..6df341fa194 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; diff --git a/compose.c b/compose.c index f08f5e2add4..31a61ac3fc7 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) @@ -588,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: @@ -596,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); @@ -609,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); @@ -622,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); @@ -703,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: @@ -716,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: @@ -796,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; @@ -1310,7 +1295,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; @@ -1476,7 +1460,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 diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 4eda2771de8..c48d8da295c 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4120,8 +4120,6 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, mutt_menu_destroy (&menu); FREE (&key_table); - set_option (OPTNEEDREDRAW); - return k; } diff --git a/curs_lib.c b/curs_lib.c index 1eb17e50f0c..42cdace2a9a 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -98,7 +98,7 @@ void mutt_need_hard_redraw (void) { keypad (stdscr, true); clearok (stdscr, true); - set_option (OPTNEEDREDRAW); + mutt_set_current_menu_redraw (); } event_t mutt_getch (void) @@ -842,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 7f9846c7fc9..aabb15fd0e2 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2674,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: @@ -2928,7 +2926,6 @@ int mutt_index_menu (void) } #endif - MAYBE_REDRAW (menu->redraw); break; case OP_PRINT: @@ -3090,7 +3087,6 @@ int mutt_index_menu (void) case OP_SHELL_ESCAPE: mutt_shell_escape (); - MAYBE_REDRAW (menu->redraw); break; case OP_TAG_THREAD: 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/menu.c b/menu.c index dc49d739eec..0024614c92b 100644 --- a/menu.c +++ b/menu.c @@ -459,7 +459,7 @@ void menu_check_recenter (MUTTMENU *menu) if (menu->top != 0) { menu->top = 0; - set_option (OPTNEEDREDRAW); + menu->redraw |= REDRAW_INDEX; } } else @@ -798,6 +798,11 @@ 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) @@ -812,6 +817,8 @@ void mutt_push_current_menu (MUTTMENU *menu) void mutt_pop_current_menu (MUTTMENU *menu) { + MUTTMENU *prev_menu; + if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu)) { @@ -820,9 +827,11 @@ void mutt_pop_current_menu (MUTTMENU *menu) } MenuStackCount--; - if (MenuStackCount) + prev_menu = get_current_menu (); + if (prev_menu) { - CurrentMenu = MenuStack[MenuStackCount - 1]->menu; + CurrentMenu = prev_menu->menu; + prev_menu->redraw = REDRAW_FULL; } else { @@ -830,6 +839,15 @@ void mutt_pop_current_menu (MUTTMENU *menu) } } +void mutt_set_current_menu_redraw (void) +{ + MUTTMENU *current_menu; + + current_menu = get_current_menu (); + if (current_menu) + current_menu->redraw = REDRAW_FULL; +} + #define MUTT_SEARCH_UP 1 #define MUTT_SEARCH_DOWN 2 @@ -1182,7 +1200,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..91dff1d3e20 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 */ 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 2d85318838e..5940843b843 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -121,6 +121,7 @@ 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 (void); 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 85627cc4e57..ba40dcec668 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -901,7 +901,6 @@ 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/pager.c b/pager.c index ccd90559467..3c9ff108076 100644 --- a/pager.c +++ b/pager.c @@ -2560,7 +2560,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, &pager_menu->redraw); + ci_bounce_message (extra->hdr); break; case OP_RESEND: @@ -2597,7 +2597,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 (pager_menu->redraw); break; case OP_PURGE_MESSAGE: @@ -2782,7 +2781,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 (pager_menu->redraw); break; case OP_PRINT: @@ -2948,12 +2946,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) else pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX; } - MAYBE_REDRAW (pager_menu->redraw); break; case OP_SHELL_ESCAPE: mutt_shell_escape (); - MAYBE_REDRAW (pager_menu->redraw); break; case OP_TAG: diff --git a/pgpkey.c b/pgpkey.c index 7747a59d78e..e6686b7c874 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -644,8 +644,6 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, mutt_menu_destroy (&menu); FREE (&KeyTable); - set_option (OPTNEEDREDRAW); - return kp; } diff --git a/protos.h b/protos.h index 7aebc7028a4..7d5e53886ff 100644 --- a/protos.h +++ b/protos.h @@ -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 8b9d839b82a..601864e0e37 100644 --- a/query.c +++ b/query.c @@ -480,9 +480,6 @@ 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); diff --git a/remailer.c b/remailer.c index a56499af2d2..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); 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/smime.c b/smime.c index e7f031128fe..09d57a484cb 100644 --- a/smime.c +++ b/smime.c @@ -492,7 +492,6 @@ 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; } From 38273d9c139d2b5b9bf683a841db9c068934fe9e Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 18:31:43 -0700 Subject: [PATCH 05/12] Remove redraw parameter from crypt send_menus. The parameter was used to notify the caller if the sign (a)s menu was invoked, which displayed the key selection menu. This is no longer necessary with the menu stack pop operation. --- compose.c | 4 ++-- crypt-gpgme.c | 11 +++++------ crypt-gpgme.h | 4 ++-- crypt-mod-pgp-classic.c | 4 ++-- crypt-mod-pgp-gpgme.c | 4 ++-- crypt-mod-smime-classic.c | 4 ++-- crypt-mod-smime-gpgme.c | 4 ++-- crypt-mod.h | 2 +- cryptglue.c | 8 ++++---- mutt_crypt.h | 4 ++-- pgp.c | 3 +-- pgp.h | 2 +- smime.c | 5 +---- smime.h | 2 +- 14 files changed, 28 insertions(+), 33 deletions(-) diff --git a/compose.c b/compose.c index 31a61ac3fc7..2374d12c221 100644 --- a/compose.c +++ b/compose.c @@ -1418,7 +1418,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; @@ -1451,7 +1451,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; diff --git a/crypt-gpgme.c b/crypt-gpgme.c index c48d8da295c..68409625b93 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -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/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/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/smime.c b/smime.c index 09d57a484cb..307a77865ba 100644 --- a/smime.c +++ b/smime.c @@ -2085,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; @@ -2218,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); @@ -2246,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 From 58c32a6c8ff04267694d3fef951e1e2b7e6b8ce1 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 18:31:45 -0700 Subject: [PATCH 06/12] Don't full redraw the index when handling a command from the pager. This causes a noticable flicker when moving through messages from the pager. --- curs_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/curs_main.c b/curs_main.c index aabb15fd0e2..c40e70a3b03 100644 --- a/curs_main.c +++ b/curs_main.c @@ -969,14 +969,14 @@ 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) { From 431cf5900d273a536cbc7b8629fe1c71ac639912 Mon Sep 17 00:00:00 2001 From: Vincent Lefevre Date: Fri, 31 Mar 2017 17:29:35 +0200 Subject: [PATCH 07/12] Filter other directional markers that corrupt the screen. --- mbyte.c | 2 ++ 1 file changed, 2 insertions(+) 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; From 97d731ecb2851b64c3c39722d0ce9246dbfd7384 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 31 Mar 2017 18:15:12 -0700 Subject: [PATCH 08/12] Remove the OPTFORCEREDRAW options. Use the menu stack to flag redraws for the index and pager. --- color.c | 17 +++++++++-------- curs_lib.c | 2 +- curs_main.c | 4 ---- init.c | 24 +++++++++++------------- menu.c | 23 ++++++++++++++++------- mutt.h | 2 -- mutt_menu.h | 4 +++- pager.c | 4 ---- score.c | 5 +++-- 9 files changed, 43 insertions(+), 42 deletions(-) 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/curs_lib.c b/curs_lib.c index 42cdace2a9a..b006f56eaff 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -98,7 +98,7 @@ void mutt_need_hard_redraw (void) { keypad (stdscr, true); clearok (stdscr, true); - mutt_set_current_menu_redraw (); + mutt_set_current_menu_redraw_full (); } event_t mutt_getch (void) diff --git a/curs_main.c b/curs_main.c index c40e70a3b03..afe072c8c2b 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2788,10 +2788,6 @@ int mutt_index_menu (void) 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: diff --git a/init.c b/init.c index c62f8dad511..c550695f8bb 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) @@ -2188,8 +2188,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 +2317,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 +2777,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) diff --git a/menu.c b/menu.c index 0024614c92b..829d42ff08f 100644 --- a/menu.c +++ b/menu.c @@ -839,7 +839,16 @@ void mutt_pop_current_menu (MUTTMENU *menu) } } -void mutt_set_current_menu_redraw (void) +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; @@ -848,6 +857,12 @@ void mutt_set_current_menu_redraw (void) 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 @@ -1162,12 +1177,6 @@ int mutt_menu_loop (MUTTMENU *menu) case OP_ENTER_COMMAND: mutt_enter_command (); - if (option (OPTFORCEREDRAWINDEX)) - { - menu->redraw = REDRAW_FULL; - unset_option (OPTFORCEREDRAWINDEX); - unset_option (OPTFORCEREDRAWPAGER); - } break; case OP_TAG: diff --git a/mutt.h b/mutt.h index 91dff1d3e20..8030a530ba0 100644 --- a/mutt.h +++ b/mutt.h @@ -573,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_menu.h b/mutt_menu.h index 5940843b843..74755ccc3c9 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -121,7 +121,9 @@ 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 (void); +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/pager.c b/pager.c index 3c9ff108076..7edd4099d30 100644 --- a/pager.c +++ b/pager.c @@ -2754,10 +2754,6 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) ch = 0; } - if (option (OPTFORCEREDRAWPAGER)) - pager_menu->redraw = REDRAW_FULL; - unset_option (OPTFORCEREDRAWINDEX); - unset_option (OPTFORCEREDRAWPAGER); break; case OP_FLAG_MESSAGE: 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++) { From 0fe76c0a417107979d5402c3fe01775c941ebad9 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 31 Mar 2017 18:15:20 -0700 Subject: [PATCH 09/12] Remove SidebarNeedsRedraw. The menu stack can be used to flag a redraw of the sidebar window. --- buffy.c | 3 ++- curs_main.c | 2 +- flags.c | 3 ++- globals.h | 1 - imap/command.c | 3 ++- init.c | 4 ++-- menu.c | 4 ++-- pager.c | 5 ++--- sidebar.c | 6 +++--- 9 files changed, 16 insertions(+), 15 deletions(-) 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/curs_main.c b/curs_main.c index afe072c8c2b..f3167cf0190 100644 --- a/curs_main.c +++ b/curs_main.c @@ -978,7 +978,7 @@ int mutt_index_menu (void) } #ifdef USE_SIDEBAR - if (menu->redraw & REDRAW_SIDEBAR || SidebarNeedsRedraw) + if (menu->redraw & REDRAW_SIDEBAR) { mutt_sb_set_buffystats (Context); menu_redraw_sidebar (menu); 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 c550695f8bb..0ec887f5edd 100644 --- a/init.c +++ b/init.c @@ -2013,7 +2013,7 @@ 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 } @@ -2792,7 +2792,7 @@ 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 } } diff --git a/menu.c b/menu.c index 829d42ff08f..82682859bef 100644 --- a/menu.c +++ b/menu.c @@ -307,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 @@ -989,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) diff --git a/pager.c b/pager.c index 7edd4099d30..658b67d8840 100644 --- a/pager.c +++ b/pager.c @@ -1878,10 +1878,9 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) } #ifdef USE_SIDEBAR - if ((pager_menu->redraw & REDRAW_SIDEBAR) || SidebarNeedsRedraw) + if (pager_menu->redraw & REDRAW_SIDEBAR) { - SidebarNeedsRedraw = 0; - mutt_sb_draw (); + menu_redraw_sidebar (pager_menu); } #endif 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); } From 5f19af41f368776bd5ad4b3a58f336afe815071c Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 31 Mar 2017 18:15:22 -0700 Subject: [PATCH 10/12] Change reflow_windows() to set full redraw. A full redraw should always be set in this case. This also enables us to remove redraw flags for some options. --- curs_lib.c | 2 ++ curs_main.c | 1 - init.h | 10 +++++----- pager.c | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/curs_lib.c b/curs_lib.c index b006f56eaff..1f29d92028b 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -617,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) diff --git a/curs_main.c b/curs_main.c index f3167cf0190..84d61655343 100644 --- a/curs_main.c +++ b/curs_main.c @@ -3205,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: diff --git a/init.h b/init.h index 8581fd8e1ed..d302fa0e55c 100644 --- a/init.h +++ b/init.h @@ -50,7 +50,7 @@ #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_BOTH (R_INDEX | R_PAGER) #define R_RESORT_BOTH (R_RESORT | R_RESORT_SUB) @@ -1112,7 +1112,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 @@ -3245,7 +3245,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 +3253,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 +3925,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/pager.c b/pager.c index 658b67d8840..2f472156413 100644 --- a/pager.c +++ b/pager.c @@ -3109,7 +3109,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(); - pager_menu->redraw = REDRAW_FULL; break; #endif From 05954d75ee6cd8796db85253de62db3b16ab4d4f Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 31 Mar 2017 18:15:28 -0700 Subject: [PATCH 11/12] Create R_MENU redraw option. Previously, the R_INDEX option meant both the index as well as all other menus. The removal of the OPTFORCEREDRAWINDEX option caused problems with redrawing other menus for options such as arrow_cursor. One solution would be change R_INDEX back to meaning "everything" except pager, but there are only a handful of options that affect other menus. Instead, create R_MENU to indicate options that affect either all menus or one of the other menus beside the index and pager. --- init.c | 4 ++++ init.h | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/init.c b/init.c index 0ec887f5edd..7915ab7da43 100644 --- a/init.c +++ b/init.c @@ -2015,6 +2015,8 @@ static void restore_default (struct option_t *p) if (p->flags & R_SIDEBAR) 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) @@ -2794,6 +2796,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) if (MuttVars[idx].flags & R_SIDEBAR) 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 d302fa0e55c..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 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 @@ -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 From 401cc3e4e805043023496f21dddbe36fdaa49d37 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 31 Mar 2017 18:15:31 -0700 Subject: [PATCH 12/12] Remove refresh parameter from mutt_enter_fname(). Also remove it from mutt_save_message(), which used it to pass through to mutt_enter_fname(). The callers of this already had redraw logic, to which REDRAW_STATUS merely needed to be added. --- commands.c | 16 ++-------------- compose.c | 7 +++---- curs_lib.c | 4 +--- curs_main.c | 8 ++++---- pager.c | 3 +-- protos.h | 8 ++++---- 6 files changed, 15 insertions(+), 31 deletions(-) diff --git a/commands.c b/commands.c index 6df341fa194..b6db0130696 100644 --- a/commands.c +++ b/commands.c @@ -728,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; @@ -737,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")) : @@ -787,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 2374d12c221..4b472959240 100644 --- a/compose.c +++ b/compose.c @@ -801,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; @@ -871,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 @@ -1380,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)); diff --git a/curs_lib.c b/curs_lib.c index 1f29d92028b..9b540066a10 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -805,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; @@ -833,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 { diff --git a/curs_main.c b/curs_main.c index 84d61655343..c56490f1a83 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1991,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); @@ -2021,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) { @@ -2319,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)) diff --git a/pager.c b/pager.c index 2f472156413..3453b26ef5c 100644 --- a/pager.c +++ b/pager.c @@ -2928,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, - &pager_menu->redraw) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE + 0) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE || ch == OP_DECRYPT_SAVE )) { diff --git a/protos.h b/protos.h index 7d5e53886ff..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,