Previously, the pattern was thrown away during menu destruction.
For the next search, mutt then can't provide a good suggestion.
The new behaviour is to manage the pattern outside the lifecyle
to always provide the last pattern as suggestion.
/* tell whoever called me to redraw the screen when I return */
set_option (OPTNEEDREDRAW);
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (MENU_ALIAS);
menu->make_entry = alias_entry;
menu->tag = alias_tag;
- menu->menu = MENU_ALIAS;
menu->title = _("Aliases");
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_ALIAS, AliasHelp);
if (examine_directory (NULL, &state, LastDir, prefix) == -1)
goto bail;
- menu = mutt_new_menu ();
- menu->menu = MENU_FOLDER;
+ menu = mutt_new_menu (MENU_FOLDER);
menu->make_entry = folder_entry;
menu->search = select_file_search;
menu->title = title;
mutt_attach_init (msg->content);
idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1);
- menu = mutt_new_menu ();
- menu->menu = MENU_COMPOSE;
+ menu = mutt_new_menu (MENU_COMPOSE);
menu->offset = HDR_ATTACH;
menu->max = idxlen;
menu->make_entry = snd_entry;
mutt_make_help (buf, sizeof (buf), _("Help"), menu_to_use, OP_HELP);
strcat (helpstr, buf); /* __STRCAT_CHECKED__ */
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (menu_to_use);
menu->max = i;
menu->make_entry = crypt_entry;
- menu->menu = menu_to_use;
menu->help = helpstr;
menu->data = key_table;
int close = 0; /* did we OP_QUIT or OP_EXIT out of this menu? */
int attach_msg = option(OPTATTACHMSG);
- menu = mutt_new_menu ();
- menu->menu = MENU_MAIN;
+ menu = mutt_new_menu (MENU_MAIN);
menu->offset = 1;
menu->pagelen = LINES - 3;
menu->make_entry = index_make_entry;
Groups = hash_create (1031);
ReverseAlias = hash_create (1031);
+ mutt_menu_init ();
+
/*
* XXX - use something even more difficult to predict?
*/
extern size_t UngetCount;
+char* SearchBuffers[MENU_MAX];
+
static void print_enriched_string (int attr, unsigned char *s, int do_color)
{
wchar_t wc;
return (regexec (re, buf, 0, NULL, 0));
}
-MUTTMENU *mutt_new_menu (void)
+void mutt_menu_init (void)
+{
+ int i;
+
+ for (i = 0; i < MENU_MAX; i++)
+ SearchBuffers[i] = NULL;
+}
+
+MUTTMENU *mutt_new_menu (int menu)
{
MUTTMENU *p = (MUTTMENU *) safe_calloc (1, sizeof (MUTTMENU));
+ p->menu = menu;
p->current = 0;
p->top = 0;
p->offset = 1;
{
int i;
- FREE (&(*p)->searchBuf);
-
- if ((*p)->dialog)
+ if ((*p)->dialog)
{
for (i=0; i < (*p)->max; i++)
FREE (&(*p)->dialog[i]);
int searchDir;
regex_t re;
char buf[SHORT_STRING];
+ char* searchBuf = menu->menu >= 0 && menu->menu < MENU_MAX ?
+ SearchBuffers[menu->menu] : NULL;
if (op != OP_SEARCH_NEXT && op != OP_SEARCH_OPPOSITE)
{
- strfcpy (buf, menu->searchBuf ? menu->searchBuf : "", sizeof (buf));
+ strfcpy (buf, searchBuf ? searchBuf : "", sizeof (buf));
if (mutt_get_field ((op == OP_SEARCH) ? _("Search for: ") :
_("Reverse search for: "),
buf, sizeof (buf), M_CLEAR) != 0 || !buf[0])
return (-1);
- mutt_str_replace (&menu->searchBuf, buf);
+ if (menu->menu >= 0 && menu->menu < MENU_MAX)
+ {
+ mutt_str_replace (&SearchBuffers[menu->menu], buf);
+ searchBuf = SearchBuffers[menu->menu];
+ }
menu->searchDir = (op == OP_SEARCH) ? M_SEARCH_DOWN : M_SEARCH_UP;
}
else
{
- if (!menu->searchBuf)
+ if (!searchBuf || !*searchBuf)
{
mutt_error _("No search pattern.");
return (-1);
if (op == OP_SEARCH_OPPOSITE)
searchDir = -searchDir;
- if ((r = REGCOMP (&re, menu->searchBuf, REG_NOSUB | mutt_which_case (menu->searchBuf))) != 0)
+ if ((r = REGCOMP (&re, searchBuf, REG_NOSUB | mutt_which_case (searchBuf))) != 0)
{
regerror (r, &re, buf, sizeof (buf));
regfree (&re);
/* the following are used only by mutt_menuLoop() */
int top; /* entry that is the top of the current page */
int oldcurrent; /* for driver use only. */
- char *searchBuf; /* last search pattern */
int searchDir; /* direction of search */
int tagged; /* number of tagged entries */
} MUTTMENU;
+void mutt_menu_init (void);
void menu_jump (MUTTMENU *);
void menu_redraw_full (MUTTMENU *);
void menu_redraw_index (MUTTMENU *);
void menu_check_recenter (MUTTMENU *);
void menu_status_line (char *, size_t, MUTTMENU *, const char *);
-MUTTMENU *mutt_new_menu (void);
+MUTTMENU *mutt_new_menu (int);
void mutt_menuDestroy (MUTTMENU **);
int mutt_menuLoop (MUTTMENU *);
}
/* interactive check from user */
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (-1);
menu->max = 19;
menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
for (i = 0; i < menu->max; i++)
/* interactive check from user */
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (-1);
menu->max = 25;
menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
for (i = 0; i < menu->max; i++)
{
/* only allocate the space if/when we need the index.
Initialise the menu as per the main index */
- index = mutt_new_menu();
- index->menu = MENU_MAIN;
+ index = mutt_new_menu(MENU_MAIN);
index->make_entry = index_make_entry;
index->color = index_color;
index->max = Context->vcount;
mutt_make_help (buf, sizeof (buf), _("Help"), MENU_PGP, OP_HELP);
strcat (helpstr, buf); /* __STRCAT_CHECKED__ */
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (MENU_PGP);
menu->max = i;
menu->make_entry = pgp_entry;
- menu->menu = MENU_PGP;
menu->help = helpstr;
menu->data = KeyTable;
char helpstr[LONG_STRING];
short orig_sort;
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (MENU_POST);
menu->make_entry = post_entry;
- menu->menu = MENU_POST;
menu->max = PostContext->msgcount;
menu->title = _("Postponed Messages");
menu->data = PostContext;
snprintf (title, sizeof (title), _("Query")); /* FIXME */
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (MENU_QUERY);
menu->make_entry = query_entry;
menu->search = query_search;
menu->tag = query_tag;
- menu->menu = MENU_QUERY;
menu->title = title;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
menu->current = 0;
mutt_menuDestroy (&menu);
- menu = mutt_new_menu ();
+ menu = mutt_new_menu (MENU_QUERY);
menu->make_entry = query_entry;
menu->search = query_search;
menu->tag = query_tag;
- menu->menu = MENU_QUERY;
menu->title = title;
menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_QUERY, QueryHelp);
cur = hdr->content;
}
- menu = mutt_new_menu ();
- menu->menu = MENU_ATTACH;
+ menu = mutt_new_menu (MENU_ATTACH);
menu->title = _("Attachments");
menu->make_entry = attach_entry;
menu->tag = mutt_tag_attach;
mix_screen_coordinates (type2_list, &coords, chain, 0);
- menu = mutt_new_menu ();
- menu->menu = MENU_MIX;
+ menu = mutt_new_menu (MENU_MIX);
menu->max = ttll;
menu->make_entry = mix_entry;
menu->tag = NULL;
strcat (helpstr, buf); /* __STRCAT_CHECKED__ */
/* Create the menu */
- menu = mutt_new_menu();
+ menu = mutt_new_menu(MENU_SMIME);
menu->max = cur;
menu->make_entry = smime_entry;
- menu->menu = MENU_SMIME;
menu->help = helpstr;
menu->data = Table;
menu->title = title;