NeoMutt  2025-12-11-87-gae07fd
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

void km_init (void)
 Initialise all the menu keybindings.
 
void km_menu_add_bindings (const struct MenuOpSeq *map, enum MenuType mtype)
 Attach a set of keybindings to a Menu.
 
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
 

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 91 of file init.c.

92{
93 memset(Keymaps, 0, sizeof(struct KeymapList) * MENU_MAX);
94
96}
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
static const struct Command KeyCommands[]
Key Binding Commands.
Definition init.c:57
struct KeymapList Keymaps[MENU_MAX]
Array of key mappings, one for each MenuType.
Definition lib.c:56
Container for Accounts, Notifications.
Definition neomutt.h:43
struct CommandArray commands
NeoMutt commands.
Definition neomutt.h:51
@ MENU_MAX
Definition type.h:52
+ 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 ( const struct MenuOpSeq * map,
enum MenuType mtype )

Attach a set of keybindings to a Menu.

Parameters
mapKey bindings
mtypeMenu type, e.g. MENU_PAGER

Definition at line 45 of file init.c.

46{
47 STAILQ_INIT(&Keymaps[mtype]);
48
49 for (int i = 0; map[i].op != OP_NULL; i++)
50 if (map[i].seq)
51 km_bind(map[i].seq, mtype, map[i].op, NULL, NULL, NULL);
52}
enum CommandResult km_bind(const char *s, enum MenuType mtype, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
Definition commands.c:56
#define STAILQ_INIT(head)
Definition queue.h:410
int op
Operation, e.g. OP_DELETE.
Definition menu.h:48
+ Here is the call graph for this function:
+ 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 137 of file init.c.

138{
139 keycode_t buf[4] = { 0 };
140 const char *const c_abort_key = cs_subset_string(NeoMutt->sub, "abort_key");
141
142 size_t len = parse_keys(c_abort_key, buf, countof(buf));
143 if (len == 0)
144 {
145 mutt_error(_("Abort key is not set, defaulting to Ctrl-G"));
146 AbortKey = ctrl('G');
147 return;
148 }
149
150 if (len > 1)
151 {
152 mutt_warning(_("Specified abort key sequence (%s) will be truncated to first key"),
153 c_abort_key);
154 }
155 AbortKey = buf[0];
156
158}
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
int km_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition init.c:101
keycode_t AbortKey
code of key to abort prompts, normally Ctrl-G
Definition init.c:38
size_t parse_keys(const char *str, keycode_t *d, size_t max)
Parse a key string into key codes.
Definition keymap.c:315
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
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
#define ctrl(ch)
Definition mutt_curses.h:52
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
+ 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 121 of file init.c.

122{
123 for (enum MenuType i = 1; i < MENU_MAX; i++)
124 {
126 }
127
128 if (NeoMutt && NeoMutt->sub)
130}
void keymaplist_free(struct KeymapList *kml)
Free a List of Keymaps.
Definition keymap.c:144
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
MenuType
Types of GUI selections.
Definition type.h:35
+ 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 38 of file init.c.