From: Thomas Roessler Date: Fri, 29 Jan 1999 11:11:53 +0000 (+0000) Subject: Add generic menu searching. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4483b0f0cc4d9eb8b91d39a16fe0a52afc2dc8d;p=neomutt Add generic menu searching. --- diff --git a/addrbook.c b/addrbook.c index ea25fdbb3..3be25cbe0 100644 --- a/addrbook.c +++ b/addrbook.c @@ -67,17 +67,6 @@ alias_format_str (char *dest, size_t destlen, char op, const char *src, return (src); } -int alias_search (MUTTMENU *m, regex_t *re, int n) -{ - char s[LONG_STRING]; - int slen = sizeof(s); - - mutt_FormatString (s, slen, NONULL (AliasFmt), alias_format_str, - (unsigned long) ((ALIAS **) m->data)[n], 0); - return regexec (re, s, 0, NULL, 0); -} - - void alias_entry (char *s, size_t slen, MUTTMENU *m, int num) { mutt_FormatString (s, slen, NONULL (AliasFmt), alias_format_str, (unsigned long) ((ALIAS **) m->data)[num], M_FORMAT_ARROWCURSOR); @@ -137,7 +126,6 @@ void mutt_alias_menu (char *buf, size_t buflen, ALIAS *aliases) menu = mutt_new_menu (); menu->make_entry = alias_entry; - menu->search = alias_search; menu->tag = alias_tag; menu->menu = MENU_ALIAS; menu->title = _("Aliases"); diff --git a/menu.c b/menu.c index afe8367d3..1cc74c756 100644 --- a/menu.c +++ b/menu.c @@ -560,6 +560,14 @@ static int default_color (int i) return ColorDefs[MT_COLOR_NORMAL]; } +static int menu_search_generic (MUTTMENU *m, regex_t *re, int n) +{ + char buf[LONG_STRING]; + + m->make_entry (buf, sizeof (buf), m, n); + return (regexec (re, buf, 0, NULL, 0)); +} + MUTTMENU *mutt_new_menu (void) { MUTTMENU *p = (MUTTMENU *) safe_calloc (1, sizeof (MUTTMENU)); @@ -570,6 +578,7 @@ MUTTMENU *mutt_new_menu (void) p->redraw = REDRAW_FULL; p->pagelen = PAGELEN; p->color = default_color; + p->search = menu_search_generic; return (p); } diff --git a/pgpkey.c b/pgpkey.c index 7f120b849..6f0f8258a 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -227,14 +227,6 @@ static void pgp_entry (char *s, size_t l, MUTTMENU * menu, int num) (unsigned long) &entry, M_FORMAT_ARROWCURSOR); } -static int pgp_search (MUTTMENU * m, regex_t * re, int n) -{ - char buf[LONG_STRING]; - - pgp_entry (buf, sizeof (buf), m, n); - return (regexec (re, buf, 0, NULL, 0)); -} - static int pgp_compare (const void *a, const void *b) { int r; @@ -303,7 +295,6 @@ static pgp_key_t *pgp_select_key (struct pgp_vinfo *pgp, menu = mutt_new_menu (); menu->max = keymax; menu->make_entry = pgp_entry; - menu->search = pgp_search; menu->menu = MENU_PGP; menu->help = helpstr; menu->data = KeyTable; diff --git a/remailer.c b/remailer.c index df9a46f55..885e63e0e 100644 --- a/remailer.c +++ b/remailer.c @@ -51,7 +51,6 @@ static REMAILER *mix_new_remailer (void); static const char *mix_format_caps (REMAILER *r); static int mix_chain_add (MIXCHAIN *chain, const char *s, REMAILER **type2_list); static int mix_get_caps (const char *capstr); -static int mix_search (MUTTMENU *, regex_t *, int); static void mix_add_entry (REMAILER ***, REMAILER *, size_t *, size_t *); static void mix_entry (char *b, size_t blen, MUTTMENU *menu, int num); static void mix_free_remailer (REMAILER **r); @@ -445,14 +444,6 @@ static void mix_entry (char *b, size_t blen, MUTTMENU *menu, int num) (unsigned long) type2_list[num], M_FORMAT_ARROWCURSOR); } -static int mix_search (MUTTMENU *m, regex_t *re, int n) -{ - char buf[LONG_STRING]; - - mix_entry (buf, sizeof (buf), m, n); - return (regexec (re, buf, 0, NULL, 0)); -} - static int mix_chain_add (MIXCHAIN *chain, const char *s, REMAILER **type2_list) { @@ -543,7 +534,6 @@ void mix_make_chain (LIST **chainp, int *redraw) menu->menu = MENU_MIX; menu->max = ttll; menu->make_entry = mix_entry; - menu->search = mix_search; menu->tag = NULL; menu->title = _("Select a remailer chain."); menu->data = type2_list;