NeoMutt  2025-12-11-911-gd8d604
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 471 of file dlg_browser.c.

472{
473 struct BrowserPrivateData *priv = menu->mdata;
474 struct BrowserEntryArray *entry = &priv->state.entry;
475 if (OptNews)
476 return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
477 struct FolderFile *ff = ARRAY_GET(entry, line);
478 char *search_on = ff->desc ? ff->desc : ff->name;
479
480 return regexec(rx, search_on, 0, NULL, 0);
481}
#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:149
Browser entry representing a folder/dir.
Definition lib.h:82
char * name
Name of file/dir/mailbox.
Definition lib.h:90
char * desc
Description of mailbox.
Definition lib.h:91
void * mdata
Private data.
Definition lib.h:155
+ 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 57 of file menu.c.

58{
59 struct Buffer *buf = buf_pool_get();
60
61 menu->make_entry(menu, line, -1, buf);
62 int rc = regexec(rx, buf->data, 0, NULL, 0);
63 buf_pool_release(&buf);
64
65 return rc;
66}
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:114
+ Here is the call graph for this function:
+ Here is the caller graph for this function: