NeoMutt  2024-10-02-7-gd3e66a
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 943 of file dlg_browser.c.

944{
945 struct BrowserEntryArray *entry = menu->mdata;
946 if (OptNews)
947 return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
948 struct FolderFile *ff = ARRAY_GET(entry, line);
949 char *search_on = ff->desc ? ff->desc : ff->name;
950
951 return regexec(rx, search_on, 0, NULL, 0);
952}
#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:68
Browser entry representing a folder/dir.
Definition: lib.h:78
char * name
Name of file/dir/mailbox.
Definition: lib.h:86
char * desc
Description of mailbox.
Definition: lib.h:87
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: