NeoMutt  2025-12-11-87-gae07fd
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
menu.h File Reference

Maniplate Menus and SubMenus. More...

#include <stdbool.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "menu/lib.h"
#include "get.h"
#include "keymap.h"
+ Include dependency graph for menu.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MenuFuncOp
 Mapping between a function and an operation. More...
 
struct  MenuOpSeq
 Mapping between an operation and a key sequence. More...
 

Functions

bool is_bound (const struct KeymapList *km_list, int op)
 Does a function have a keybinding?
 
struct Keymapkm_find_func (enum MenuType mtype, int func)
 Find a function's mapping in a Menu.
 
int km_get_op (const struct MenuFuncOp *funcs, const char *start, size_t len)
 Get the function by its name.
 

Detailed Description

Maniplate Menus and SubMenus.

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 menu.h.

Function Documentation

◆ is_bound()

bool is_bound ( const struct KeymapList * km_list,
int op )

Does a function have a keybinding?

Parameters
km_listKeymap to examine
opOperation, e.g. OP_DELETE
Return values
trueA key is bound to that operation

Definition at line 82 of file menu.c.

83{
84 if (!km_list)
85 return false;
86
87 struct Keymap *map = NULL;
88 STAILQ_FOREACH(map, km_list, entries)
89 {
90 if (map->op == op)
91 return true;
92 }
93
94 return false;
95}
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
A keyboard mapping.
Definition keymap.h:43
short op
Operation to perform.
Definition keymap.h:46
+ Here is the caller graph for this function:

◆ km_find_func()

struct Keymap * km_find_func ( enum MenuType mtype,
int func )

Find a function's mapping in a Menu.

Parameters
mtypeMenu type, e.g. MENU_PAGER
funcFunction, e.g. OP_DELETE
Return values
ptrKeymap for the function

Definition at line 45 of file menu.c.

46{
47 struct Keymap *np = NULL;
48 STAILQ_FOREACH(np, &Keymaps[mtype], entries)
49 {
50 if (np->op == func)
51 break;
52 }
53 return np;
54}
struct KeymapList Keymaps[MENU_MAX]
Array of key mappings, one for each MenuType.
Definition lib.c:56
+ Here is the caller graph for this function:

◆ km_get_op()

int km_get_op ( const struct MenuFuncOp * funcs,
const char * start,
size_t len )

Get the function by its name.

Parameters
funcsFunctions table
startName of function to find
lenLength of string to match
Return values
numOperation, e.g. OP_DELETE

Definition at line 63 of file menu.c.

64{
65 for (int i = 0; funcs[i].name; i++)
66 {
67 if (mutt_istrn_equal(start, funcs[i].name, len) && (mutt_str_len(funcs[i].name) == len))
68 {
69 return funcs[i].op;
70 }
71 }
72
73 return OP_NULL;
74}
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:500
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition string.c:457
const char * name
Name of the function.
Definition menu.h:38
int op
Operation, e.g. OP_DELETE.
Definition menu.h:39