Thanks to visit codestin.com
Credit goes to code.neomutt.org

NeoMutt  2025-12-11-189-gceedb6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
init.h File Reference

Set up the key bindings. More...

#include "keymap.h"
#include "menu.h"
+ Include dependency graph for init.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int km_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
void km_init (void)
 Initialise all the menu keybindings.
 
void km_menu_add_bindings (struct MenuDefinition *md, const struct MenuOpSeq bindings[])
 Add Keybindings to a Menu.
 
void km_menu_add_submenu (struct MenuDefinition *md, struct SubMenu *sm)
 Add a SubMenu to a Menu Definition.
 
struct MenuDefinitionkm_register_menu (int menu, const char *name)
 Register a menu.
 
struct SubMenukm_register_submenu (const struct MenuFuncOp functions[])
 Register a submenu.
 
void km_set_abort_key (void)
 Parse the abort_key config string.
 
void km_cleanup (void)
 Free the key maps.
 

Variables

keycode_t AbortKey
 key to abort edits etc, normally Ctrl-G
 
struct SubMenuArray SubMenus
 All the registered SubMenus.
 
struct MenuDefinitionArray MenuDefs
 All the registered Menus.
 

Detailed Description

Set up the key bindings.

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

Function Documentation

◆ km_init()

void km_init ( void )

Initialise all the menu keybindings.

Definition at line 170 of file init.c.

171{
174
176}
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
int km_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition init.c:150
struct MenuDefinitionArray MenuDefs
All the registered Menus.
Definition init.c:42
struct SubMenuArray SubMenus
All the registered SubMenus.
Definition init.c:45
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
Container for Accounts, Notifications.
Definition neomutt.h:128
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_menu_add_bindings()

void km_menu_add_bindings ( struct MenuDefinition * md,
const struct MenuOpSeq bindings[] )

Add Keybindings to a Menu.

Parameters
mdMenu Definition
bindingsKeybindings to add

Definition at line 136 of file init.c.

137{
138 for (int i = 0; bindings[i].op != OP_NULL; i++)
139 {
140 if (bindings[i].seq)
141 {
142 km_bind(md, bindings[i].seq, bindings[i].op, NULL, NULL, NULL);
143 }
144 }
145}
enum CommandResult km_bind(struct MenuDefinition *md, const char *key_str, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
Definition menu.c:51
int op
Operation, e.g. OP_DELETE.
Definition menu.h:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_menu_add_submenu()

void km_menu_add_submenu ( struct MenuDefinition * md,
struct SubMenu * sm )

Add a SubMenu to a Menu Definition.

Parameters
mdMenu Definition
smSubMenu to add

Definition at line 123 of file init.c.

124{
125 if (!sm->parent)
126 sm->parent = md;
127
128 ARRAY_ADD(&md->submenus, sm);
129}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
struct SubMenuPArray submenus
Parts making up the Menu.
Definition menu.h:84
struct MenuDefinition * parent
Primary parent.
Definition menu.h:70
+ Here is the caller graph for this function:

◆ km_register_menu()

struct MenuDefinition * km_register_menu ( int menu,
const char * name )

Register a menu.

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

Definition at line 107 of file init.c.

108{
109 struct MenuDefinition md = { 0 };
110 md.id = menu;
111 md.name = mutt_str_dup(name);
112 ARRAY_INIT(&md.submenus);
113
114 ARRAY_ADD(&MenuDefs, md);
115 return ARRAY_LAST(&MenuDefs);
116}
#define ARRAY_LAST(head)
Convenience method to get the last element.
Definition array.h:145
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
Functions for a Dialog or Window.
Definition menu.h:81
const char * name
Menu name, e.g. "alias".
Definition menu.h:83
int id
Menu ID, e.g. MENU_ALIAS.
Definition menu.h:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_register_submenu()

struct SubMenu * km_register_submenu ( const struct MenuFuncOp functions[])

Register a submenu.

Parameters
functionsFunction definitions
Return values
ptrSubMenu

Register a set of functions. The result can be used in multiple Menus.

Definition at line 91 of file init.c.

92{
93 struct SubMenu sm = { 0 };
96
97 ARRAY_ADD(&SubMenus, sm);
98 return ARRAY_LAST(&SubMenus);
99}
Collection of related functions.
Definition menu.h:69
const struct MenuFuncOp * functions
All available functions.
Definition menu.h:71
struct KeymapList keymaps
All keybindings.
Definition menu.h:72
+ Here is the caller graph for this function:

◆ km_set_abort_key()

void km_set_abort_key ( void )

Parse the abort_key config string.

Parse the string into $abort_key and put the keycode into AbortKey.

Definition at line 210 of file init.c.

211{
212 keycode_t buf[4] = { 0 };
213 const char *const c_abort_key = cs_subset_string(NeoMutt->sub, "abort_key");
214
215 size_t len = parse_keys(c_abort_key, buf, countof(buf));
216 if (len == 0)
217 {
218 mutt_error(_("Abort key is not set, defaulting to Ctrl-G"));
219 AbortKey = ctrl('G');
220 return;
221 }
222
223 if (len > 1)
224 {
225 mutt_warning(_("Specified abort key sequence (%s) will be truncated to first key"),
226 c_abort_key);
227 }
228 AbortKey = buf[0];
229}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
#define mutt_warning(...)
Definition logging2.h:92
#define mutt_error(...)
Definition logging2.h:94
keycode_t AbortKey
code of key to abort prompts, normally Ctrl-G
Definition init.c:47
size_t parse_keys(const char *str, keycode_t *d, size_t max)
Parse a key string into key codes.
Definition keymap.c:318
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
Definition keymap.h:31
#define countof(x)
Definition memory.h:45
#define _(a)
Definition message.h:28
#define ctrl(ch)
Definition mutt_curses.h:52
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ km_cleanup()

void km_cleanup ( void )

Free the key maps.

Definition at line 181 of file init.c.

182{
183 if (NeoMutt && NeoMutt->sub)
185
186 struct MenuDefinition *md = NULL;
188 {
189 FREE(&md->name);
190 ARRAY_FREE(&md->submenus);
191 }
193
194 struct SubMenu *sm = NULL;
196 {
198 }
200
203}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
struct KeyEventArray MacroEvents
These are used for macros and exec/push commands.
Definition get.c:56
struct KeyEventArray UngetKeyEvents
These are used in all other "normal" situations, and are not ignored when passing GETCH_IGNORE_MACRO.
Definition get.c:60
void keymaplist_free(struct KeymapList *kml)
Free a List of Keymaps.
Definition keymap.c:144
#define FREE(x)
Definition memory.h:63
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition notify.c:230
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AbortKey

keycode_t AbortKey
extern

key to abort edits etc, normally Ctrl-G

key to abort edits etc, normally Ctrl-G

Definition at line 47 of file init.c.

◆ SubMenus

struct SubMenuArray SubMenus
extern

All the registered SubMenus.

Definition at line 45 of file init.c.

◆ MenuDefs

struct MenuDefinitionArray MenuDefs
extern

All the registered Menus.

Definition at line 42 of file init.c.