NeoMutt  2022-04-29-215-gc12b98
Teaching an old dog new tricks
DOXYGEN
search()

Search a menu for a item matching a regex. More...

+ Collaboration diagram for search():

Functions

static int select_file_search (struct Menu *menu, regex_t *rx, int line)
 Menu search callback for matching files - Implements Menu::search() -. More...
 
static int generic_search (struct Menu *menu, regex_t *rx, int line)
 Search a menu for a item matching a regex - Implements Menu::search() -. More...
 

Detailed Description

Search a menu for a item matching a regex.

Parameters
menuMenu to search
rxRegex to match
lineMenu entry to match
Return values
0Success
>0Error, e.g. REG_NOMATCH

Function Documentation

◆ select_file_search()

static int select_file_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Menu search callback for matching files - Implements Menu::search() -.

Definition at line 790 of file browser.c.

791{
792 struct BrowserStateEntry *entry = menu->mdata;
793#ifdef USE_NNTP
794 if (OptNews)
795 return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
796#endif
797 struct FolderFile *ff = ARRAY_GET(entry, line);
798 char *search_on = ff->desc ? ff->desc : ff->name;
799
800 return regexec(rx, search_on, 0, NULL, 0);
801}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:108
bool OptNews
(pseudo) used to change reader mode
Definition: options.h:50
Browser entry representing a folder/dir.
Definition: lib.h:73
char * name
Name of file/dir/mailbox.
Definition: lib.h:81
char * desc
Description of mailbox.
Definition: lib.h:82
void * mdata
Private data.
Definition: lib.h:137
+ Here is the caller graph for this function:

◆ generic_search()

static int generic_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Search a menu for a item matching a regex - Implements Menu::search() -.

Definition at line 54 of file menu.c.

55{
56 char buf[1024] = { 0 };
57
58 menu->make_entry(menu, buf, sizeof(buf), line);
59 return regexec(rx, buf, 0, NULL, 0);
60}
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
+ Here is the caller graph for this function: