From 8330353b762aff25717d24e15a45b9728616d7c0 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sun, 26 Mar 2017 18:31:41 -0700 Subject: [PATCH] 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 | 5 +---- 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, 37 insertions(+), 76 deletions(-) diff --git a/addrbook.c b/addrbook.c index 9228a8dff..f6d961309 100644 --- a/addrbook.c +++ b/addrbook.c @@ -145,10 +145,7 @@ void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases) mutt_error _("You have no 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 83edc5f35..03b1fc346 100644 --- a/browser.c +++ b/browser.c @@ -954,7 +954,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num menu->current = 0; menu->top = 0; init_menu (&state, menu, title, sizeof (title), buffy); - MAYBE_REDRAW (menu->redraw); } /* else leave error on screen */ break; @@ -977,7 +976,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num menu->current = 0; menu->top = 0; init_menu (&state, menu, title, sizeof (title), buffy); - MAYBE_REDRAW (menu->redraw); } } break; @@ -1015,7 +1013,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 @@ -1094,7 +1091,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: @@ -1160,7 +1156,6 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num } } } - MAYBE_REDRAW (menu->redraw); break; case OP_SORT: @@ -1246,7 +1241,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 8b0162b3f..f3fbc582b 100644 --- a/commands.c +++ b/commands.c @@ -238,7 +238,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]; @@ -276,13 +276,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 7230936b5..94da43d3e 100644 --- a/compose.c +++ b/compose.c @@ -273,7 +273,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; @@ -287,12 +287,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); @@ -305,8 +299,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) @@ -528,11 +520,11 @@ 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: - 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); @@ -541,7 +533,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_BCC: - 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); @@ -550,7 +542,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; case OP_COMPOSE_EDIT_CC: - 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); @@ -575,7 +567,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: @@ -588,7 +580,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: @@ -667,12 +658,6 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ FREE (&idx[idxlen]); menu->redraw |= REDRAW_STATUS; - - if (option(OPTNEEDREDRAW)) - { - menu->redraw = REDRAW_FULL; - unset_option(OPTNEEDREDRAW); - } mutt_message_hook (NULL, msg, MUTT_SEND2HOOK); break; @@ -1164,7 +1149,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; @@ -1330,7 +1314,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 1a311796b..7b010d0f9 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4143,8 +4143,6 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, mutt_pop_current_menu (menu); mutt_menuDestroy (&menu); FREE (&key_table); - - set_option (OPTNEEDREDRAW); return k; } diff --git a/curs_lib.c b/curs_lib.c index c4c42b425..3f91bbab6 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -94,7 +94,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) @@ -769,7 +769,6 @@ int _mutt_enter_fname (const char *prompt, char *buf, size_t blen, int *redraw, 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); } diff --git a/curs_main.c b/curs_main.c index cc7c1a952..5cec42cfb 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1960,20 +1960,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: @@ -2192,7 +2190,6 @@ int mutt_index_menu (void) } #endif - MAYBE_REDRAW (menu->redraw); break; case OP_PRINT: @@ -2321,7 +2318,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 dbbd786fb..cc985f274 100644 --- a/enter.c +++ b/enter.c @@ -532,7 +532,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; @@ -643,7 +642,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 891a580eb..99af16510 100644 --- a/menu.c +++ b/menu.c @@ -394,7 +394,7 @@ void menu_check_recenter (MUTTMENU *menu) if (menu->top != 0) { menu->top = 0; - set_option (OPTNEEDREDRAW); + menu->redraw |= REDRAW_INDEX; } } else @@ -733,6 +733,11 @@ void mutt_menuDestroy (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) @@ -747,6 +752,8 @@ void mutt_push_current_menu (MUTTMENU *menu) void mutt_pop_current_menu (MUTTMENU *menu) { + MUTTMENU *prev_menu; + if (!MenuStackCount || (MenuStack[MenuStackCount - 1] != menu)) { @@ -755,9 +762,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 { @@ -765,6 +774,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 @@ -1108,7 +1126,6 @@ int mutt_menuLoop (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 3f7166ba6..32ece54c0 100644 --- a/mutt.h +++ b/mutt.h @@ -523,7 +523,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 62004491f..c8b047e76 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -232,8 +232,6 @@ 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; } - /* ---------------------------------------------------------------------------- * These are here to avoid compiler warnings with -Wall under SunOS 4.1.x */ diff --git a/mutt_menu.h b/mutt_menu.h index 3d0b6f817..52ddab129 100644 --- a/mutt_menu.h +++ b/mutt_menu.h @@ -122,6 +122,7 @@ MUTTMENU *mutt_new_menu (int); void mutt_menuDestroy (MUTTMENU **); void mutt_push_current_menu (MUTTMENU *); void mutt_pop_current_menu (MUTTMENU *); +void mutt_set_current_menu_redraw (); int mutt_menuLoop (MUTTMENU *); /* used in both the index and pager index to make an entry. */ diff --git a/mutt_ssl.c b/mutt_ssl.c index 0ce0150f2..2208f6852 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -1306,7 +1306,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_menuDestroy (&menu); - set_option (OPTNEEDREDRAW); dprint (2, (debugfile, "ssl interactive_check_cert: done=%d\n", done)); return (done == 2); } diff --git a/pager.c b/pager.c index bfbfc0239..fd5074892 100644 --- a/pager.c +++ b/pager.c @@ -2384,7 +2384,7 @@ search_next: extra->idx, extra->idxlen, extra->bdy); else - ci_bounce_message (extra->hdr, &pager_menu->redraw); + ci_bounce_message (extra->hdr); break; case OP_RESEND: @@ -2416,7 +2416,6 @@ search_next: 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: @@ -2594,7 +2593,6 @@ search_next: 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: @@ -2706,12 +2704,10 @@ search_next: 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 c39f25ea6..cfbc6ba78 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -655,8 +655,6 @@ static pgp_key_t pgp_select_key (pgp_key_t keys, mutt_menuDestroy (&menu); FREE (&KeyTable); - set_option (OPTNEEDREDRAW); - return (kp); } diff --git a/protos.h b/protos.h index 37bfe6df6..b9a30dd2d 100644 --- a/protos.h +++ b/protos.h @@ -538,7 +538,7 @@ int ioctl (int, int, ...); #endif /* unsorted */ -void ci_bounce_message (HEADER *, int *); +void ci_bounce_message (HEADER *); int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *); /* prototypes for compatibility functions */ diff --git a/query.c b/query.c index aedc83269..b1f7043ae 100644 --- a/query.c +++ b/query.c @@ -536,9 +536,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 8e0434a37..f476fdbed 100644 --- a/remailer.c +++ b/remailer.c @@ -487,7 +487,7 @@ static const struct mapping_t RemailerHelp[] = }; -void mix_make_chain (LIST **chainp, int *redraw) +void mix_make_chain (LIST **chainp) { LIST *p; MIXCHAIN *chain; @@ -513,8 +513,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 cbae78f3b..c76593f01 100644 --- a/remailer.h +++ b/remailer.h @@ -56,7 +56,7 @@ typedef struct mixchain MIXCHAIN; int mix_send_message (LIST *, const char *); int mix_check_message (HEADER *msg); -void mix_make_chain (LIST **, int *); +void mix_make_chain (LIST **); #endif /* MIXMASTER */ diff --git a/smime.c b/smime.c index b12119ee3..93dba754d 100644 --- a/smime.c +++ b/smime.c @@ -497,7 +497,6 @@ static smime_key_t *smime_select_key (smime_key_t *keys, char *query) mutt_pop_current_menu (menu); mutt_menuDestroy (&menu); FREE (&table); - set_option (OPTNEEDREDRAW); return selected_key; } -- 2.40.0