NeoMutt  2025-12-11-980-ge38c27
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

Fuzzy matching library. More...

#include <stdbool.h>
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FuzzyOptions
 Options for fuzzy matching. More...
 
struct  FuzzyResult
 Result of a fuzzy match. More...
 

Enumerations

enum  FuzzyAlgo { FUZZY_ALGO_SUBSEQ = 0 }
 Fuzzy matching algorithm types. More...
 

Functions

void fuzzy_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic)
 Initialise the Fuzzy Keybindings - Implements ::init_keys_api.
 
struct SubMenufuzzy_get_submenu (void)
 Get the Fuzzy SubMenu.
 
int fuzzy_match (const char *pattern, const char *candidate, enum FuzzyAlgo algo, const struct FuzzyOptions *opts, struct FuzzyResult *out)
 Perform fuzzy matching.
 

Detailed Description

Fuzzy matching library.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Enumeration Type Documentation

◆ FuzzyAlgo

enum FuzzyAlgo

Fuzzy matching algorithm types.

Enumerator
FUZZY_ALGO_SUBSEQ 

Subsequence matching algorithm.

Definition at line 80 of file lib.h.

81{
83 // extensible
84 // FUZZY_ALGO_EDIT,
85 // FUZZY_ALGO_TOKEN,
86};
@ FUZZY_ALGO_SUBSEQ
Subsequence matching algorithm.
Definition lib.h:82

Function Documentation

◆ fuzzy_init_keys()

void fuzzy_init_keys ( struct NeoMutt * n,
struct SubMenu * sm_generic )

Initialise the Fuzzy Keybindings - Implements ::init_keys_api.

Definition at line 70 of file functions.c.

71{
73 ASSERT(mod_data);
74
75 struct MenuDefinition *md = NULL;
76 struct SubMenu *sm = NULL;
77
79 md = km_register_menu(MENU_FUZZY, "fuzzy");
80 km_menu_add_submenu(md, sm);
82
83 mod_data->md_fuzzy = md;
84 mod_data->sm_fuzzy = sm;
85}
const struct MenuOpSeq FuzzyDefaultBindings[]
Key bindings for the Fuzzy Window.
Definition functions.c:56
static const struct MenuFuncOp OpFuzzy[]
Functions for the Fuzzy Window.
Definition functions.c:43
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:88
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:105
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
@ MODULE_ID_FUZZY
ModuleFuzzy, Fuzzy matching library
Definition module_api.h:67
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
#define ASSERT(COND)
Definition signal2.h:59
Fuzzy private Module data.
Definition module_data.h:32
struct MenuDefinition * md_fuzzy
Fuzzy Menu Definition.
Definition module_data.h:33
struct SubMenu * sm_fuzzy
Fuzzy functions.
Definition module_data.h:34
Functions for a Dialog or Window.
Definition menudef.h:44
Collection of related functions.
Definition menudef.h:33
@ MENU_FUZZY
Fuzzy searcher.
Definition type.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fuzzy_get_submenu()

struct SubMenu * fuzzy_get_submenu ( void )

Get the Fuzzy SubMenu.

Return values
ptrFuzzy SubMenu

Definition at line 91 of file functions.c.

92{
94 ASSERT(mod_data);
95
96 return mod_data->sm_fuzzy;
97}
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fuzzy_match()

int fuzzy_match ( const char * pattern,
const char * candidate,
enum FuzzyAlgo algo,
const struct FuzzyOptions * opts,
struct FuzzyResult * out )

Perform fuzzy matching.

Parameters
patternPattern to match
candidateCandidate string to match against
algoFuzzy matching algorithm to use
optsFuzzy matching options
outOutput result structure
Return values
>=0Match score
-1Error or no match

Definition at line 58 of file fuzzy.c.

60{
61 if (!pattern || !candidate)
62 return -1;
63
64 if (algo == FUZZY_ALGO_SUBSEQ)
65 return fuzzy_subseq_match(pattern, candidate, opts, out);
66
67 return -1;
68}
bool candidate(struct CompletionData *cd, char *user, const char *src, char *dest, size_t dlen)
Helper function for completion.
Definition helpers.c:79
int fuzzy_subseq_match(const char *pattern, const char *candidate, const struct FuzzyOptions *opts, struct FuzzyResult *out)
Perform subsequence fuzzy matching (UTF-8 aware, ASCII case-folding)
Definition subseq.c:262
+ Here is the call graph for this function:
+ Here is the caller graph for this function: