NeoMutt  2025-09-05-43-g177ed6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
commands.c
Go to the documentation of this file.
1
22
28
29#include "config.h"
30#include <stdbool.h>
31#include <stdint.h>
32#include <stdio.h>
33#include <string.h>
34#include "mutt/lib.h"
35#include "core/lib.h"
36#include "gui/lib.h"
37#include "mutt.h"
38#include "lib.h"
39#include "menu/lib.h"
40#include "parse/lib.h"
41
43#define MAX_SEQ 8
44
58enum CommandResult km_bind(const char *s, enum MenuType mtype, int op,
59 char *macro, char *desc, struct Buffer *err)
60{
62 struct Keymap *last = NULL, *np = NULL, *compare = NULL;
63 keycode_t buf[MAX_SEQ];
64 size_t pos = 0, lastpos = 0;
65
66 size_t len = parsekeys(s, buf, MAX_SEQ);
67
68 struct Keymap *map = alloc_keys(len, buf);
69 map->op = op;
70 map->macro = mutt_str_dup(macro);
71 map->desc = mutt_str_dup(desc);
72
73 /* find position to place new keymap */
74 STAILQ_FOREACH(np, &Keymaps[mtype], entries)
75 {
76 compare = km_compare_keys(map, np, &pos);
77
78 if (compare == map) /* map's keycode is bigger */
79 {
80 last = np;
81 lastpos = pos;
82 if (pos > np->eq)
83 pos = np->eq;
84 }
85 else if (compare == np) /* np's keycode is bigger, found insert location */
86 {
87 map->eq = pos;
88 break;
89 }
90 else /* equal keycodes */
91 {
92 /* Don't warn on overwriting a 'noop' binding */
93 if ((np->len != len) && (np->op != OP_NULL))
94 {
95 static const char *guide_link = "https://neomutt.org/guide/configuration.html#bind-warnings";
96 /* Overwrite with the different lengths, warn */
97 struct Buffer *old_binding = buf_pool_get();
98 struct Buffer *new_binding = buf_pool_get();
99
100 km_expand_key(map, old_binding);
101 km_expand_key(np, new_binding);
102
103 char *err_msg = _("Binding '%s' will alias '%s' Before, try: 'bind %s %s noop'");
104 if (err)
105 {
106 /* err was passed, put the string there */
107 buf_printf(err, err_msg, buf_string(old_binding), buf_string(new_binding),
108 mutt_map_get_name(mtype, MenuNames), buf_string(new_binding));
109 buf_add_printf(err, " %s", guide_link);
110 }
111 else
112 {
113 struct Buffer *tmp = buf_pool_get();
114 buf_printf(tmp, err_msg, buf_string(old_binding), buf_string(new_binding),
115 mutt_map_get_name(mtype, MenuNames), buf_string(new_binding));
116 buf_add_printf(tmp, " %s", guide_link);
117 mutt_error("%s", buf_string(tmp));
118 buf_pool_release(&tmp);
119 }
120 rc = MUTT_CMD_WARNING;
121
122 buf_pool_release(&old_binding);
123 buf_pool_release(&new_binding);
124 }
125
126 map->eq = np->eq;
127 STAILQ_REMOVE(&Keymaps[mtype], np, Keymap, entries);
128 mutt_keymap_free(&np);
129 break;
130 }
131 }
132
133 if (map->op == OP_NULL)
134 {
135 mutt_keymap_free(&map);
136 }
137 else
138 {
139 if (last) /* if queue has at least one entry */
140 {
141 if (STAILQ_NEXT(last, entries))
142 STAILQ_INSERT_AFTER(&Keymaps[mtype], last, map, entries);
143 else /* last entry in the queue */
144 STAILQ_INSERT_TAIL(&Keymaps[mtype], map, entries);
145 last->eq = lastpos;
146 }
147 else /* queue is empty, so insert from head */
148 {
149 STAILQ_INSERT_HEAD(&Keymaps[mtype], map, entries);
150 }
151 }
152
153 return rc;
154}
155
163static void km_unbind_all(struct KeymapList *km_list, unsigned long mode)
164{
165 struct Keymap *np = NULL, *tmp = NULL;
166
167 STAILQ_FOREACH_SAFE(np, km_list, entries, tmp)
168 {
169 if (((mode & MUTT_UNBIND) && !np->macro) || ((mode & MUTT_UNMACRO) && np->macro))
170 {
171 STAILQ_REMOVE(km_list, np, Keymap, entries);
172 mutt_keymap_free(&np);
173 }
174 }
175}
176
191static char *parse_keymap(enum MenuType *mtypes, struct Buffer *s, int max_menus,
192 int *num_menus, struct Buffer *err, bool bind)
193{
194 struct Buffer *buf = buf_pool_get();
195 int i = 0;
196 char *q = NULL;
197 char *result = NULL;
198
199 /* menu name */
201 char *p = buf->data;
202 if (MoreArgs(s))
203 {
204 while (i < max_menus)
205 {
206 q = strchr(p, ',');
207 if (q)
208 *q = '\0';
209
210 int val = mutt_map_get_value(p, MenuNames);
211 if (val == -1)
212 {
213 buf_printf(err, _("%s: no such menu"), p);
214 goto done;
215 }
216 mtypes[i] = val;
217 i++;
218 if (q)
219 p = q + 1;
220 else
221 break;
222 }
223 *num_menus = i;
224 /* key sequence */
226
227 if (buf_at(buf, 0) == '\0')
228 {
229 buf_printf(err, _("%s: null key sequence"), bind ? "bind" : "macro");
230 }
231 else if (MoreArgs(s))
232 {
233 result = buf_strdup(buf);
234 goto done;
235 }
236 }
237 else
238 {
239 buf_printf(err, _("%s: too few arguments"), bind ? "bind" : "macro");
240 }
241done:
242 buf_pool_release(&buf);
243 return result;
244}
245
255static void *parse_menu(bool *menus, char *s, struct Buffer *err)
256{
257 char *menu_names_dup = mutt_str_dup(s);
258 char *marker = menu_names_dup;
259 char *menu_name = NULL;
260
261 while ((menu_name = mutt_str_sep(&marker, ",")))
262 {
263 int value = mutt_map_get_value(menu_name, MenuNames);
264 if (value == -1)
265 {
266 buf_printf(err, _("%s: no such menu"), menu_name);
267 break;
268 }
269 else
270 {
271 menus[value] = true;
272 }
273 }
274
275 FREE(&menu_names_dup);
276 return NULL;
277}
278
288static enum CommandResult try_bind(char *key, enum MenuType mtype, char *func,
289 const struct MenuFuncOp *funcs, struct Buffer *err)
290{
291 for (int i = 0; funcs[i].name; i++)
292 {
293 if (mutt_str_equal(func, funcs[i].name))
294 {
295 return km_bind(key, mtype, funcs[i].op, NULL, NULL, err);
296 }
297 }
298 if (err)
299 {
300 buf_printf(err, _("Function '%s' not available for menu '%s'"), func,
302 }
303 return MUTT_CMD_ERROR; /* Couldn't find an existing function with this name */
304}
305
309enum CommandResult parse_push(struct Buffer *buf, struct Buffer *s,
310 intptr_t data, struct Buffer *err)
311{
313 if (MoreArgs(s))
314 {
315 buf_printf(err, _("%s: too many arguments"), "push");
316 return MUTT_CMD_ERROR;
317 }
318
320 return MUTT_CMD_SUCCESS;
321}
322
328enum CommandResult parse_bind(struct Buffer *buf, struct Buffer *s,
329 intptr_t data, struct Buffer *err)
330{
331 if (StartupComplete)
332 {
333 // Save and restore the offset in `s` because dump_bind_macro() might change it
334 char *dptr = s->dptr;
335 if (dump_bind_macro(buf, s, data, err) == MUTT_CMD_SUCCESS)
336 return MUTT_CMD_SUCCESS;
337 if (!buf_is_empty(err))
338 return MUTT_CMD_ERROR;
339 s->dptr = dptr;
340 }
341
342 const struct MenuFuncOp *funcs = NULL;
343 enum MenuType mtypes[MenuNamesLen];
344 int num_menus = 0;
346
347 char *key = parse_keymap(mtypes, s, countof(mtypes), &num_menus, err, true);
348 if (!key)
349 return MUTT_CMD_ERROR;
350
351 /* function to execute */
353 if (MoreArgs(s))
354 {
355 buf_printf(err, _("%s: too many arguments"), "bind");
356 rc = MUTT_CMD_ERROR;
357 }
358 else if (mutt_istr_equal("noop", buf->data))
359 {
360 struct Buffer *keystr = buf_pool_get();
361 for (int i = 0; i < num_menus; i++)
362 {
363 km_bind(key, mtypes[i], OP_NULL, NULL, NULL, NULL); /* the 'unbind' command */
364 funcs = km_get_table(mtypes[i]);
365 if (funcs)
366 {
367 buf_reset(keystr);
368 km_expand_key_string(key, keystr);
369 const char *mname = mutt_map_get_name(mtypes[i], MenuNames);
370 mutt_debug(LL_NOTIFY, "NT_BINDING_DELETE: %s %s\n", mname, buf_string(keystr));
371
372 int op = get_op(OpGeneric, buf->data, mutt_str_len(buf->data));
373 struct EventBinding ev_b = { mtypes[i], key, op };
375 }
376 }
377 buf_pool_release(&keystr);
378 }
379 else
380 {
381 struct Buffer *keystr = buf_pool_get();
382 for (int i = 0; i < num_menus; i++)
383 {
384 /* The pager and editor menus don't use the generic map,
385 * however for other menus try generic first. */
386 if ((mtypes[i] != MENU_PAGER) && (mtypes[i] != MENU_EDITOR) && (mtypes[i] != MENU_GENERIC))
387 {
388 rc = try_bind(key, mtypes[i], buf->data, OpGeneric, err);
389 if (rc == MUTT_CMD_SUCCESS)
390 {
391 buf_reset(keystr);
392 km_expand_key_string(key, keystr);
393 const char *mname = mutt_map_get_name(mtypes[i], MenuNames);
394 mutt_debug(LL_NOTIFY, "NT_BINDING_NEW: %s %s\n", mname, buf_string(keystr));
395
396 int op = get_op(OpGeneric, buf->data, mutt_str_len(buf->data));
397 struct EventBinding ev_b = { mtypes[i], key, op };
399 continue;
400 }
401 if (rc == MUTT_CMD_WARNING)
402 break;
403 }
404
405 /* Clear any error message, we're going to try again */
406 err->data[0] = '\0';
407 funcs = km_get_table(mtypes[i]);
408 if (funcs)
409 {
410 rc = try_bind(key, mtypes[i], buf->data, funcs, err);
411 if (rc == MUTT_CMD_SUCCESS)
412 {
413 buf_reset(keystr);
414 km_expand_key_string(key, keystr);
415 const char *mname = mutt_map_get_name(mtypes[i], MenuNames);
416 mutt_debug(LL_NOTIFY, "NT_BINDING_NEW: %s %s\n", mname, buf_string(keystr));
417
418 int op = get_op(funcs, buf->data, mutt_str_len(buf->data));
419 struct EventBinding ev_b = { mtypes[i], key, op };
421 continue;
422 }
423 }
424 }
425 buf_pool_release(&keystr);
426 }
427 FREE(&key);
428 return rc;
429}
430
441enum CommandResult parse_unbind(struct Buffer *buf, struct Buffer *s,
442 intptr_t data, struct Buffer *err)
443{
444 bool menu_matches[MENU_MAX] = { 0 };
445 bool all_keys = false;
446 char *key = NULL;
447
449 if (mutt_str_equal(buf->data, "*"))
450 {
451 for (enum MenuType i = 1; i < MENU_MAX; i++)
452 menu_matches[i] = true;
453 }
454 else
455 {
456 parse_menu(menu_matches, buf->data, err);
457 }
458
459 if (MoreArgs(s))
460 {
462 key = buf->data;
463 }
464 else
465 {
466 all_keys = true;
467 }
468
469 if (MoreArgs(s))
470 {
471 const char *cmd = (data & MUTT_UNMACRO) ? "unmacro" : "unbind";
472
473 buf_printf(err, _("%s: too many arguments"), cmd);
474 return MUTT_CMD_ERROR;
475 }
476
477 for (enum MenuType i = 1; i < MENU_MAX; i++)
478 {
479 if (!menu_matches[i])
480 continue;
481 if (all_keys)
482 {
483 km_unbind_all(&Keymaps[i], data);
484 km_bind("<enter>", MENU_GENERIC, OP_GENERIC_SELECT_ENTRY, NULL, NULL, NULL);
485 km_bind("<return>", MENU_GENERIC, OP_GENERIC_SELECT_ENTRY, NULL, NULL, NULL);
486 km_bind("<enter>", MENU_INDEX, OP_DISPLAY_MESSAGE, NULL, NULL, NULL);
487 km_bind("<return>", MENU_INDEX, OP_DISPLAY_MESSAGE, NULL, NULL, NULL);
488 km_bind("<backspace>", MENU_EDITOR, OP_EDITOR_BACKSPACE, NULL, NULL, NULL);
489 km_bind("\177", MENU_EDITOR, OP_EDITOR_BACKSPACE, NULL, NULL, NULL);
490 km_bind(":", MENU_GENERIC, OP_ENTER_COMMAND, NULL, NULL, NULL);
491 km_bind(":", MENU_PAGER, OP_ENTER_COMMAND, NULL, NULL, NULL);
492 if (i != MENU_EDITOR)
493 {
494 km_bind("?", i, OP_HELP, NULL, NULL, NULL);
495 km_bind("q", i, OP_EXIT, NULL, NULL, NULL);
496 }
497
498 const char *mname = mutt_map_get_name(i, MenuNames);
499 mutt_debug(LL_NOTIFY, "NT_MACRO_DELETE_ALL: %s\n", mname);
500
501 struct EventBinding ev_b = { i, NULL, OP_NULL };
504 &ev_b);
505 }
506 else
507 {
508 struct Buffer *keystr = buf_pool_get();
509 km_expand_key_string(key, keystr);
510 const char *mname = mutt_map_get_name(i, MenuNames);
511 mutt_debug(LL_NOTIFY, "NT_MACRO_DELETE: %s %s\n", mname, buf_string(keystr));
512 buf_pool_release(&keystr);
513
514 km_bind(key, i, OP_NULL, NULL, NULL, NULL);
515 struct EventBinding ev_b = { i, key, OP_NULL };
518 }
519 }
520
521 return MUTT_CMD_SUCCESS;
522}
523
529enum CommandResult parse_macro(struct Buffer *buf, struct Buffer *s,
530 intptr_t data, struct Buffer *err)
531{
532 if (StartupComplete)
533 {
534 // Save and restore the offset in `s` because dump_bind_macro() might change it
535 char *dptr = s->dptr;
536 if (dump_bind_macro(buf, s, data, err) == MUTT_CMD_SUCCESS)
537 return MUTT_CMD_SUCCESS;
538 if (!buf_is_empty(err))
539 return MUTT_CMD_ERROR;
540 s->dptr = dptr;
541 }
542
543 enum MenuType mtypes[MenuNamesLen];
544 int num_menus = 0;
546
547 char *key = parse_keymap(mtypes, s, countof(mtypes), &num_menus, err, false);
548 if (!key)
549 return MUTT_CMD_ERROR;
550
552 /* make sure the macro sequence is not an empty string */
553 if (buf_at(buf, 0) == '\0')
554 {
555 buf_strcpy(err, _("macro: empty key sequence"));
556 }
557 else
558 {
559 if (MoreArgs(s))
560 {
561 char *seq = mutt_str_dup(buf->data);
563
564 if (MoreArgs(s))
565 {
566 buf_printf(err, _("%s: too many arguments"), "macro");
567 }
568 else
569 {
570 struct Buffer *keystr = buf_pool_get();
571 for (int i = 0; i < num_menus; i++)
572 {
573 rc = km_bind(key, mtypes[i], OP_MACRO, seq, buf->data, NULL);
574 if (rc == MUTT_CMD_SUCCESS)
575 {
576 buf_reset(keystr);
577 km_expand_key_string(key, keystr);
578 const char *mname = mutt_map_get_name(mtypes[i], MenuNames);
579 mutt_debug(LL_NOTIFY, "NT_MACRO_NEW: %s %s\n", mname, buf_string(keystr));
580
581 struct EventBinding ev_b = { mtypes[i], key, OP_MACRO };
583 continue;
584 }
585 }
586 buf_pool_release(&keystr);
587 }
588
589 FREE(&seq);
590 }
591 else
592 {
593 struct Buffer *keystr = buf_pool_get();
594 for (int i = 0; i < num_menus; i++)
595 {
596 rc = km_bind(key, mtypes[i], OP_MACRO, buf->data, NULL, NULL);
597 if (rc == MUTT_CMD_SUCCESS)
598 {
599 buf_reset(keystr);
600 km_expand_key_string(key, keystr);
601 const char *mname = mutt_map_get_name(mtypes[i], MenuNames);
602 mutt_debug(LL_NOTIFY, "NT_MACRO_NEW: %s %s\n", mname, buf_string(keystr));
603
604 struct EventBinding ev_b = { mtypes[i], key, OP_MACRO };
606 continue;
607 }
608 }
609 buf_pool_release(&keystr);
610 }
611 }
612 FREE(&key);
613 return rc;
614}
615
619enum CommandResult parse_exec(struct Buffer *buf, struct Buffer *s,
620 intptr_t data, struct Buffer *err)
621{
622 int ops[128];
623 int nops = 0;
624 const struct MenuFuncOp *funcs = NULL;
625 char *function = NULL;
626
627 if (!MoreArgs(s))
628 {
629 buf_strcpy(err, _("exec: no arguments"));
630 return MUTT_CMD_ERROR;
631 }
632
633 do
634 {
636 function = buf->data;
637
638 const enum MenuType mtype = menu_get_current_type();
639 funcs = km_get_table(mtype);
640 if (!funcs && (mtype != MENU_PAGER))
641 funcs = OpGeneric;
642
643 ops[nops] = get_op(funcs, function, mutt_str_len(function));
644 if ((ops[nops] == OP_NULL) && (mtype != MENU_PAGER) && (mtype != MENU_GENERIC))
645 {
646 ops[nops] = get_op(OpGeneric, function, mutt_str_len(function));
647 }
648
649 if (ops[nops] == OP_NULL)
650 {
652 mutt_error(_("%s: no such function"), function);
653 return MUTT_CMD_ERROR;
654 }
655 nops++;
656 } while (MoreArgs(s) && nops < countof(ops));
657
658 while (nops)
659 mutt_push_macro_event(0, ops[--nops]);
660
661 return MUTT_CMD_SUCCESS;
662}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition buffer.c:204
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
Definition buffer.c:668
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:571
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
CommandResult
Error codes for command_t parse functions.
Definition command.h:35
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition command.h:38
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition command.h:36
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition command.h:37
bool StartupComplete
When the config has been read.
Definition address.c:13
Convenience wrapper for the core headers.
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition get.c:58
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
Definition get.c:155
int parse_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition extract.c:48
#define TOKEN_CONDENSE
^(char) to control chars (macros)
Definition extract.h:46
#define MoreArgs(buf)
Definition extract.h:30
#define TOKEN_NO_FLAGS
No flags are set.
Definition extract.h:44
void generic_tokenize_push_string(char *s)
Parse and queue a 'push' command.
Definition get.c:348
enum CommandResult parse_push(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'push' command - Implements Command::parse() -.
Definition commands.c:309
enum CommandResult parse_bind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'bind' command - Implements Command::parse() -.
Definition commands.c:328
enum CommandResult parse_unbind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unbind' command - Implements Command::parse() -.
Definition commands.c:441
enum CommandResult parse_exec(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'exec' command - Implements Command::parse() -.
Definition commands.c:619
enum CommandResult dump_bind_macro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse 'bind' and 'macro' commands - Implements Command::parse() -.
Definition dump.c:172
enum CommandResult parse_macro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'macro' command - Implements Command::parse() -.
Definition commands.c:529
#define mutt_error(...)
Definition logging2.h:93
#define mutt_debug(LEVEL,...)
Definition logging2.h:90
const struct MenuFuncOp OpGeneric[]
Functions for the Generic Menu.
Definition functions.c:69
Convenience wrapper for the gui headers.
static void * parse_menu(bool *menus, char *s, struct Buffer *err)
Parse menu-names into an array.
Definition commands.c:255
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:58
static void km_unbind_all(struct KeymapList *km_list, unsigned long mode)
Free all the keys in the supplied Keymap.
Definition commands.c:163
static char * parse_keymap(enum MenuType *mtypes, struct Buffer *s, int max_menus, int *num_menus, struct Buffer *err, bool bind)
Parse a user-config key binding.
Definition commands.c:191
static enum CommandResult try_bind(char *key, enum MenuType mtype, char *func, const struct MenuFuncOp *funcs, struct Buffer *err)
Try to make a key binding.
Definition commands.c:288
#define MAX_SEQ
Maximum length of a key binding sequence used for buffer in km_bind.
Definition commands.c:43
struct Keymap * km_compare_keys(struct Keymap *k1, struct Keymap *k2, size_t *pos)
Compare two keymaps' keyscodes and return the bigger one.
Definition lib.c:274
struct Keymap * alloc_keys(size_t len, keycode_t *keys)
Allocate space for a sequence of keys.
Definition lib.c:149
void mutt_keymap_free(struct Keymap **ptr)
Free a Keymap.
Definition lib.c:130
struct KeymapList Keymaps[MENU_MAX]
Array of key mappings, one for each MenuType.
Definition lib.c:124
size_t parsekeys(const char *str, keycode_t *d, size_t max)
Parse a key string into key codes.
Definition lib.c:215
const struct MenuFuncOp * km_get_table(enum MenuType mtype)
Lookup a Menu's functions.
Definition lib.c:571
int get_op(const struct MenuFuncOp *funcs, const char *start, size_t len)
Get the function by its name.
Definition lib.c:298
bool km_expand_key(struct Keymap *map, struct Buffer *buf)
Get the key string bound to a Keymap.
Definition lib.c:523
void km_expand_key_string(char *str, struct Buffer *buf)
Get a human-readable key string.
Definition lib.c:541
Manage keymappings.
@ NT_MACRO_ADD
Key macro has been added.
Definition lib.h:153
@ NT_MACRO_DELETE
Key macro has been deleted.
Definition lib.h:154
@ NT_MACRO_DELETE_ALL
All key macros have been deleted.
Definition lib.h:155
@ NT_BINDING_DELETE
Key binding has been deleted.
Definition lib.h:150
@ NT_BINDING_ADD
Key binding has been added.
Definition lib.h:149
@ NT_BINDING_DELETE_ALL
All key bindings have been deleted.
Definition lib.h:151
#define MUTT_UNBIND
Parse 'unbind' command.
Definition lib.h:49
#define MUTT_UNMACRO
Parse 'unmacro' command.
Definition lib.h:50
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
Definition lib.h:57
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:49
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
Definition mapping.c:85
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition mapping.c:42
#define countof(x)
Definition memory.h:44
#define FREE(x)
Definition memory.h:62
GUI present the user with a selectable list.
enum MenuType menu_get_current_type(void)
Get the type of the current Window.
Definition menu.c:89
Convenience wrapper for the library headers.
#define _(a)
Definition message.h:28
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:672
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:255
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:660
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:498
char * mutt_str_sep(char **stringp, const char *delim)
Find first occurrence of any of delim characters in *stringp.
Definition string.c:188
Many unsorted constants and some structs.
@ NT_BINDING
Key binding has changed, NotifyBinding, EventBinding.
Definition notify_type.h:40
Text parsing functions.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:96
#define STAILQ_REMOVE(head, elm, type, field)
Definition queue.h:441
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
#define STAILQ_INSERT_TAIL(head, elm, field)
Definition queue.h:427
#define STAILQ_INSERT_HEAD(head, elm, field)
Definition queue.h:421
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition queue.h:400
#define STAILQ_NEXT(elm, field)
Definition queue.h:439
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field)
Definition queue.h:415
String manipulation buffer.
Definition buffer.h:36
char * dptr
Current read/write position.
Definition buffer.h:38
char * data
Pointer to data.
Definition buffer.h:37
A key binding Event.
Definition lib.h:134
const char * key
Key string being bound (for new bind/macro)
Definition lib.h:136
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
Definition lib.h:137
A keyboard mapping.
Definition lib.h:67
char * macro
Macro expansion (op == OP_MACRO)
Definition lib.h:68
short eq
Number of leading keys equal to next entry.
Definition lib.h:71
char * desc
Description of a macro for the help menu.
Definition lib.h:69
short len
Length of key sequence (unit: sizeof (keycode_t))
Definition lib.h:72
short op
Operation to perform.
Definition lib.h:70
Mapping between a function and an operation.
Definition lib.h:115
const char * name
Name of the function.
Definition lib.h:116
int op
Operation, e.g. OP_DELETE.
Definition lib.h:117
Container for Accounts, Notifications.
Definition neomutt.h:43
struct Notify * notify
Notifications handler.
Definition neomutt.h:44
const int MenuNamesLen
Number of entries in the MenuNames array.
Definition type.c:60
const struct Mapping MenuNames[]
Menu name lookup table.
Definition type.c:37
MenuType
Types of GUI selections.
Definition type.h:36
@ MENU_INDEX
Index panel (list of emails)
Definition type.h:47
@ MENU_GENERIC
Generic selection list.
Definition type.h:46
@ MENU_PAGER
Pager pager (email viewer)
Definition type.h:48
@ MENU_MAX
Definition type.h:53
@ MENU_EDITOR
Text entry area.
Definition type.h:44