NeoMutt  2025-12-11-911-gd8d604
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 "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...
 
struct  MenuFunctionOp
 Mapping between a function and an operation. More...
 
struct  SubMenu
 Collection of related functions. More...
 
struct  MenuDefinition
 Functions for a Dialog or Window. More...
 

Typedefs

typedef void(* init_keys_t) (struct SubMenu *sm_generic)
 

Functions

 ARRAY_HEAD (MenuFunctionOpArray, struct MenuFunctionOp)
 
 ARRAY_HEAD (SubMenuArray, struct SubMenu)
 
 ARRAY_HEAD (SubMenuPArray, struct SubMenu *)
 
 ARRAY_HEAD (MenuDefinitionArray, struct MenuDefinition *)
 
bool is_bound (const struct MenuDefinition *md, int op)
 Does a function have a keybinding?
 
struct Keymapkm_find_func (const struct MenuDefinition *md, int func)
 Find a function's mapping in a Menu.
 
int km_get_op (const char *func)
 Get the OpCode for a Function.
 
int km_get_op_menu (int mtype, const char *func)
 Get the OpCode for a Function from a Menu.
 
struct MenuDefinitionmenu_find (int menu)
 Find a Menu Definition by Menu type.
 
struct MenuDefinitionmenu_find_by_name (const char *name)
 Find a Menu Definition 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.

Typedef Documentation

◆ init_keys_t

typedef void(* init_keys_t) (struct SubMenu *sm_generic)

Definition at line 92 of file menu.h.

Function Documentation

◆ ARRAY_HEAD() [1/4]

ARRAY_HEAD ( MenuFunctionOpArray ,
struct MenuFunctionOp  )

◆ ARRAY_HEAD() [2/4]

ARRAY_HEAD ( SubMenuArray ,
struct SubMenu  )

◆ ARRAY_HEAD() [3/4]

ARRAY_HEAD ( SubMenuPArray ,
struct SubMenu *  )

◆ ARRAY_HEAD() [4/4]

ARRAY_HEAD ( MenuDefinitionArray ,
struct MenuDefinition *  )

◆ is_bound()

bool is_bound ( const struct MenuDefinition * md,
int op )

Does a function have a keybinding?

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

Definition at line 275 of file menu.c.

276{
277 struct SubMenu **smp = NULL;
278
279 ARRAY_FOREACH(smp, &md->submenus)
280 {
281 struct SubMenu *sm = *smp;
282
283 struct Keymap *map = NULL;
284 STAILQ_FOREACH(map, &sm->keymaps, entries)
285 {
286 if (map->op == op)
287 return true;
288 }
289 }
290
291 return false;
292}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#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
struct SubMenuPArray submenus
Parts making up the Menu.
Definition menu.h:80
Collection of related functions.
Definition menu.h:65
struct KeymapList keymaps
All keybindings.
Definition menu.h:68
+ Here is the caller graph for this function:

◆ km_find_func()

struct Keymap * km_find_func ( const struct MenuDefinition * md,
int func )

Find a function's mapping in a Menu.

Parameters
mdMenu Definition
funcFunction, e.g. OP_DELETE
Return values
ptrKeymap for the function

Definition at line 141 of file menu.c.

142{
143 if (!md)
144 return NULL;
145
146 struct SubMenu **smp = NULL;
147
148 ARRAY_FOREACH(smp, &md->submenus)
149 {
150 struct SubMenu *sm = *smp;
151
152 struct Keymap *map = NULL;
153 STAILQ_FOREACH(map, &sm->keymaps, entries)
154 {
155 if (map->op == func)
156 return map;
157 }
158 }
159
160 return NULL;
161}
+ Here is the caller graph for this function:

◆ km_get_op()

int km_get_op ( const char * func)

Get the OpCode for a Function.

Parameters
funcFunction name, e.g. "exit"
Return values
numOpCode, e.g. OP_EXIT

Definition at line 168 of file menu.c.

169{
171 struct MenuDefinition **mdp = NULL;
172 ARRAY_FOREACH(mdp, &mod_data->menu_defs)
173 {
174 struct MenuDefinition *md = *mdp;
175 struct SubMenu **smp = NULL;
176
177 ARRAY_FOREACH(smp, &md->submenus)
178 {
179 struct SubMenu *sm = *smp;
180
181 for (int i = 0; sm->functions[i].name; i++)
182 {
183 if (mutt_str_equal(sm->functions[i].name, func))
184 return sm->functions[i].op;
185 }
186 }
187 }
188
189 return OP_NULL;
190}
@ MODULE_ID_KEY
ModuleKey, Key mappings
Definition module_api.h:73
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
Key private Module data.
Definition module_data.h:34
struct MenuDefinitionArray menu_defs
All registered Menus.
Definition module_data.h:39
Functions for a Dialog or Window.
Definition menu.h:77
const char * name
Name of the function.
Definition menu.h:36
int op
Operation, e.g. OP_DELETE.
Definition menu.h:37
Container for Accounts, Notifications.
Definition neomutt.h:41
const struct MenuFuncOp * functions
All available functions.
Definition menu.h:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_get_op_menu()

int km_get_op_menu ( int mtype,
const char * func )

Get the OpCode for a Function from a Menu.

Parameters
mtypeMenu Type, e.g. MENU_INDEX
funcFunction name, e.g. "exit"
Return values
numOpCode, e.g. OP_EXIT

Definition at line 198 of file menu.c.

199{
201 struct MenuDefinition **mdp = NULL;
202 ARRAY_FOREACH(mdp, &mod_data->menu_defs)
203 {
204 struct MenuDefinition *md = *mdp;
205
206 if (md->id != mtype)
207 continue;
208
209 struct SubMenu **smp = NULL;
210
211 ARRAY_FOREACH(smp, &md->submenus)
212 {
213 struct SubMenu *sm = *smp;
214
215 for (int i = 0; sm->functions[i].name; i++)
216 {
217 if (mutt_str_equal(sm->functions[i].name, func))
218 return sm->functions[i].op;
219 }
220 }
221 }
222
223 return OP_NULL;
224}
int id
Menu ID, e.g. MENU_ALIAS.
Definition menu.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_find()

struct MenuDefinition * menu_find ( int menu)

Find a Menu Definition by Menu type.

Parameters
menuMenu Type, e.g. MENU_INDEX
Return values
ptrMenu Definition

Definition at line 231 of file menu.c.

232{
234 struct MenuDefinition **mdp = NULL;
235 ARRAY_FOREACH(mdp, &mod_data->menu_defs)
236 {
237 struct MenuDefinition *md = *mdp;
238
239 if (md->id == menu)
240 return md;
241 }
242
243 return NULL;
244}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ menu_find_by_name()

struct MenuDefinition * menu_find_by_name ( const char * name)

Find a Menu Definition by its name.

Parameters
nameMenu name, e.g. "index"
Return values
ptrMenu Definition

Definition at line 251 of file menu.c.

252{
253 if (!name)
254 return NULL;
255
257 struct MenuDefinition **mdp = NULL;
258 ARRAY_FOREACH(mdp, &mod_data->menu_defs)
259 {
260 struct MenuDefinition *md = *mdp;
261
262 if (mutt_str_equal(md->name, name))
263 return md;
264 }
265
266 return NULL;
267}
const char * name
Menu name, e.g. "alias".
Definition menu.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function: