NeoMutt  2024-11-14-34-g5aaf0d
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 931 of file dlg_browser.c.

932{
933 struct BrowserPrivateData *priv = menu->mdata;
934 struct BrowserEntryArray *entry = &priv->state.entry;
935 if (OptNews)
936 return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
937 struct FolderFile *ff = ARRAY_GET(entry, line);
938 char *search_on = ff->desc ? ff->desc : ff->name;
939
940 return regexec(rx, search_on, 0, NULL, 0);
941}
#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
Private state data for the Browser.
Definition: private_data.h:34
struct Menu * menu
Menu.
Definition: private_data.h:43
struct BrowserState state
State containing list of files/dir/mailboxes.
Definition: private_data.h:42
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition: lib.h:144
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: