Set up a key binding.
Insert a key sequence into the specified map. The map is sorted by ASCII value (lowest to highest)
60{
62 struct Keymap *last = NULL, *np = NULL, *compare = NULL;
64 size_t pos = 0, lastpos = 0;
65
67
72
73
75 {
77
78 if (compare == map)
79 {
80 last = np;
81 lastpos = pos;
82 if (pos > np->eq)
84 }
85 else if (compare == np)
86 {
88 break;
89 }
90 else
91 {
92
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
97 char old_binding[128] = { 0 };
98 char new_binding[128] = { 0 };
101 char *err_msg =
_(
"Binding '%s' will alias '%s' Before, try: 'bind %s %s noop'");
102 if (err)
103 {
104
105 buf_printf(err, err_msg, old_binding, new_binding,
108 }
109 else
110 {
112 buf_printf(tmp, err_msg, old_binding, new_binding,
117 }
119 }
120
124 break;
125 }
126 }
127
128 if (map->
op == OP_NULL)
129 {
131 }
132 else
133 {
134 if (last)
135 {
138 else
141 }
142 else
143 {
145 }
146 }
147
148 return rc;
149}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
CommandResult
Error codes for command_t parse functions.
@ MUTT_CMD_SUCCESS
Success: Command worked.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
struct Keymap * km_compare_keys(struct Keymap *k1, struct Keymap *k2, size_t *pos)
Compare two keymaps' keyscodes and return the bigger one.
struct Keymap * alloc_keys(size_t len, keycode_t *keys)
Allocate space for a sequence of keys.
void mutt_keymap_free(struct Keymap **ptr)
Free a Keymap.
struct KeymapList Keymaps[MENU_MAX]
Array of key mappings, one for each MenuType.
size_t parsekeys(const char *str, keycode_t *d, size_t max)
Parse a key string into key codes.
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
#define MAX_SEQ
Maximum length of a key binding sequence used for buffer in km_bindkey.
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
char * mutt_str_dup(const char *str)
Copy a string, safely.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define STAILQ_REMOVE(head, elm, type, field)
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_INSERT_TAIL(head, elm, field)
#define STAILQ_INSERT_HEAD(head, elm, field)
#define STAILQ_NEXT(elm, field)
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field)
String manipulation buffer.
char * macro
Macro expansion (op == OP_MACRO)
short eq
Number of leading keys equal to next entry.
char * desc
Description of a macro for the help menu.
short len
Length of key sequence (unit: sizeof (keycode_t))
short op
Operation to perform.
const struct Mapping MenuNames[]
Menu name lookup table.