Commit 95070a70 authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

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.
parent 5af1b825
......@@ -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;
......
......@@ -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:
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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:
......
......@@ -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);
......
......@@ -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:
......
......@@ -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 */
......
......@@ -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
*/
......
......@@ -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. */
......
......@@ -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);
}
......
......@@ -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:
......
......@@ -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);
}
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment