NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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() -.
 
static int generic_search (struct Menu *menu, regex_t *rx, int line)
 Search a menu for a item matching a regex - Implements Menu::search() -.
 

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 938 of file dlg_browser.c.

939{
940 struct BrowserEntryArray *entry = menu->mdata;
941 if (OptNews)
942 return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
943 struct FolderFile *ff = ARRAY_GET(entry, line);
944 char *search_on = ff->desc ? ff->desc : ff->name;
945
946 return regexec(rx, search_on, 0, NULL, 0);
947}
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:109
bool OptNews
(pseudo) used to change reader mode
Definition: globals.c:67
Browser entry representing a folder/dir.
Definition: lib.h:77
char * name
Name of file/dir/mailbox.
Definition: lib.h:85
char * desc
Description of mailbox.
Definition: lib.h:86
void * mdata
Private data.
Definition: lib.h:147
+ 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 56 of file menu.c.

57{
58 struct Buffer *buf = buf_pool_get();
59
60 menu->make_entry(menu, line, -1, buf);
61 int rc = regexec(rx, buf->data, 0, NULL, 0);
62 buf_pool_release(&buf);
63
64 return rc;
65}
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
String manipulation buffer.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:37
int(* make_entry)(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Definition: lib.h:106
+ Here is the call graph for this function:
+ Here is the caller graph for this function: