NeoMutt  2025-12-11-435-g4ac674
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...
 

Macros

#define MAX_SEQ   8
 Maximum length of a key binding sequence used for buffer in km_bind.
 

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.

Macro Definition Documentation

◆ MAX_SEQ

#define MAX_SEQ   8

Maximum length of a key binding sequence used for buffer in km_bind.

Definition at line 32 of file menu.h.

Typedef Documentation

◆ init_keys_t

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

Definition at line 95 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 287 of file menu.c.

288{
289 struct SubMenu **smp = NULL;
290
291 ARRAY_FOREACH(smp, &md->submenus)
292 {
293 struct SubMenu *sm = *smp;
294
295 struct Keymap *map = NULL;
296 STAILQ_FOREACH(map, &sm->keymaps, entries)
297 {
298 if (map->op == op)
299 return true;
300 }
301 }
302
303 return false;
304}
#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:83
Collection of related functions.
Definition menu.h:68
struct KeymapList keymaps
All keybindings.
Definition menu.h:71
+ 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 157 of file menu.c.

158{
159 if (!md)
160 return NULL;
161
162 struct SubMenu **smp = NULL;
163
164 ARRAY_FOREACH(smp, &md->submenus)
165 {
166 struct SubMenu *sm = *smp;
167
168 struct Keymap *map = NULL;
169 STAILQ_FOREACH(map, &sm->keymaps, entries)
170 {
171 if (map->op == func)
172 return map;
173 }
174 }
175
176 return NULL;
177}
+ 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 184 of file menu.c.

185{
186 struct MenuDefinition **mdp = NULL;
188 {
189 struct MenuDefinition *md = *mdp;
190 struct SubMenu **smp = NULL;
191
192 ARRAY_FOREACH(smp, &md->submenus)
193 {
194 struct SubMenu *sm = *smp;
195
196 for (int i = 0; sm->functions[i].name; i++)
197 {
198 if (mutt_str_equal(sm->functions[i].name, func))
199 return sm->functions[i].op;
200 }
201 }
202 }
203
204 return OP_NULL;
205}
struct MenuDefinitionArray MenuDefs
All the registered Menus.
Definition init.c:42
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
Functions for a Dialog or Window.
Definition menu.h:80
const char * name
Name of the function.
Definition menu.h:39
int op
Operation, e.g. OP_DELETE.
Definition menu.h:40
const struct MenuFuncOp * functions
All available functions.
Definition menu.h:70
+ 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 213 of file menu.c.

214{
215 struct MenuDefinition **mdp = NULL;
217 {
218 struct MenuDefinition *md = *mdp;
219
220 if (md->id != mtype)
221 continue;
222
223 struct SubMenu **smp = NULL;
224
225 ARRAY_FOREACH(smp, &md->submenus)
226 {
227 struct SubMenu *sm = *smp;
228
229 for (int i = 0; sm->functions[i].name; i++)
230 {
231 if (mutt_str_equal(sm->functions[i].name, func))
232 return sm->functions[i].op;
233 }
234 }
235 }
236
237 return OP_NULL;
238}
int id
Menu ID, e.g. MENU_ALIAS.
Definition menu.h:81
+ 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 245 of file menu.c.

246{
247 struct MenuDefinition **mdp = NULL;
249 {
250 struct MenuDefinition *md = *mdp;
251
252 if (md->id == menu)
253 return md;
254 }
255
256 return NULL;
257}
+ 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 264 of file menu.c.

265{
266 if (!name)
267 return NULL;
268
269 struct MenuDefinition **mdp = NULL;
271 {
272 struct MenuDefinition *md = *mdp;
273
274 if (mutt_str_equal(md->name, name))
275 return md;
276 }
277
278 return NULL;
279}
const char * name
Menu name, e.g. "alias".
Definition menu.h:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function: