NeoMutt  2025-12-11-435-g4ac674
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 494 of file dlg_browser.c.

495{
496 struct BrowserPrivateData *priv = menu->mdata;
497 struct BrowserEntryArray *entry = &priv->state.entry;
498 if (OptNews)
499 return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
500 struct FolderFile *ff = ARRAY_GET(entry, line);
501 char *search_on = ff->desc ? ff->desc : ff->name;
502
503 return regexec(rx, search_on, 0, NULL, 0);
504}
#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:53
Private state data for the Browser.
struct Menu * menu
Menu.
struct BrowserState state
State containing list of files/dir/mailboxes.
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition lib.h:146
Browser entry representing a folder/dir.
Definition lib.h:79
char * name
Name of file/dir/mailbox.
Definition lib.h:87
char * desc
Description of mailbox.
Definition lib.h:88
void * mdata
Private data.
Definition lib.h:149
+ 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 58 of file menu.c.

59{
60 struct Buffer *buf = buf_pool_get();
61
62 menu->make_entry(menu, line, -1, buf);
63 int rc = regexec(rx, buf->data, 0, NULL, 0);
64 buf_pool_release(&buf);
65
66 return rc;
67}
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
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:108
+ Here is the call graph for this function:
+ Here is the caller graph for this function: