59 char *macro,
char *desc,
struct Buffer *err)
62 struct Keymap *last = NULL, *np = NULL, *compare = NULL;
64 size_t pos = 0, lastpos = 0;
85 else if (compare == np)
93 if ((np->len !=
len) && (np->op != OP_NULL))
95 static const char *guide_link =
"https://neomutt.org/guide/configuration.html#bind-warnings";
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'");
105 buf_printf(err, err_msg, old_binding, new_binding,
112 buf_printf(tmp, err_msg, old_binding, new_binding,
128 if (map->
op == OP_NULL)
162 return km_bind_err(s, mtype, op, macro, desc, NULL);
174 int op,
struct Buffer *err)
200 struct Keymap *np = NULL, *tmp = NULL;
227 int *num_menus,
struct Buffer *err,
bool bind)
239 while (i < max_menus)
262 if (
buf_at(buf, 0) ==
'\0')
264 buf_printf(err,
_(
"%s: null key sequence"), bind ?
"bind" :
"macro");
274 buf_printf(err,
_(
"%s: too few arguments"), bind ?
"bind" :
"macro");
293 char *marker = menu_names_dup;
294 char *menu_name = NULL;
310 FREE(&menu_names_dup);
326 for (
int i = 0; funcs[i].
name; i++)
335 buf_printf(err,
_(
"Function '%s' not available for menu '%s'"), func,
350 buf_printf(err,
_(
"%s: too many arguments"),
"push");
390 buf_printf(err,
_(
"%s: too many arguments"),
"bind");
395 for (
int i = 0; i < num_menus; i++)
401 char keystr[32] = { 0 };
414 for (
int i = 0; i < num_menus; i++)
423 char keystr[32] = { 0 };
445 char keystr[32] = { 0 };
473 intptr_t data,
struct Buffer *err)
475 bool menu_matches[
MENU_MAX] = { 0 };
476 bool all_keys =
false;
483 menu_matches[i] =
true;
502 const char *cmd = (data &
MUTT_UNMACRO) ?
"unmacro" :
"unbind";
510 if (!menu_matches[i])
539 char keystr[32] = { 0 };
560 intptr_t data,
struct Buffer *err)
565 char *dptr = s->
dptr;
583 if (buf->
data[0] ==
'\0')
596 buf_printf(err,
_(
"%s: too many arguments"),
"macro");
600 for (
int i = 0; i < num_menus; i++)
605 char keystr[32] = { 0 };
621 for (
int i = 0; i < num_menus; i++)
626 char keystr[32] = { 0 };
646 intptr_t data,
struct Buffer *err)
651 char *function = NULL;
662 function = buf->
data;
675 if (ops[nops] == OP_NULL)
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.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
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_ERROR
Error: Can't help the user.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
bool StartupComplete
When the config has been read.
Convenience wrapper for the core headers.
void mutt_flushinp(void)
Empty all the keyboard buffers.
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'bind' command - Implements Command::parse() -.
enum CommandResult mutt_parse_unbind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unbind' command - Implements Command::parse() -.
enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'macro' command - Implements Command::parse() -.
enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'push' command - Implements Command::parse() -.
enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'exec' command - Implements Command::parse() -.
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() -.
#define mutt_debug(LEVEL,...)
const struct MenuFuncOp OpGeneric[]
Functions for the Generic Menu.
Convenience wrapper for the gui headers.
void generic_tokenize_push_string(char *s)
Parse and queue a 'push' command.
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.
const struct MenuFuncOp * km_get_table(enum MenuType mtype)
Lookup a Menu's functions.
int get_op(const struct MenuFuncOp *funcs, const char *start, size_t len)
Get the function by its name.
int km_expand_key_string(char *str, char *buf, size_t buflen)
Get a human-readable key string.
@ NT_MACRO_ADD
Key macro has been added.
@ NT_MACRO_DELETE
Key macro has been deleted.
@ NT_MACRO_DELETE_ALL
All key macros have been deleted.
@ NT_BINDING_DELETE
Key binding has been deleted.
@ NT_BINDING_ADD
Key binding has been added.
@ NT_BINDING_DELETE_ALL
All key bindings have been deleted.
#define MUTT_UNBIND
Parse 'unbind' command.
#define MUTT_UNMACRO
Parse 'unmacro' command.
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
static void * parse_menu(bool *menus, char *s, struct Buffer *err)
Parse menu-names into an array.
enum CommandResult km_bind(char *s, enum MenuType mtype, int op, char *macro, char *desc)
Bind a key to a macro.
static enum CommandResult km_bind_err(const char *s, enum MenuType mtype, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
static enum CommandResult km_bindkey_err(const char *s, enum MenuType mtype, int op, struct Buffer *err)
Bind a key in a Menu to an operation (with error message)
static void km_unbind_all(struct KeymapList *km_list, unsigned long mode)
Free all the keys in the supplied Keymap.
enum CommandResult km_bindkey(const char *s, enum MenuType mtype, int op)
Bind a key in a Menu to an operation.
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.
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.
#define MAX_SEQ
Maximum length of a key binding sequence used for buffer in km_bindkey.
@ LL_NOTIFY
Log of notifications.
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
#define mutt_array_size(x)
Convenience wrapper for the library headers.
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
char * mutt_str_sep(char **stringp, const char *delim)
Find first occurrence of any of delim characters in *stringp.
Many unsorted constants and some structs.
@ NT_BINDING
Key binding has changed, NotifyBinding, EventBinding.
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_FOREACH_SAFE(var, head, field, tvar)
#define STAILQ_NEXT(elm, field)
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field)
String manipulation buffer.
char * dptr
Current read/write position.
char * data
Pointer to data.
const char * key
Key string being bound (for new bind/macro)
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
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.
Container for Accounts, Notifications.
struct Notify * notify
Notifications handler.
const int MenuNamesLen
Number of entries in the MenuNames array.
const struct Mapping MenuNames[]
Menu name lookup table.
MenuType
Types of GUI selections.
@ MENU_INDEX
Index panel (list of emails)
@ MENU_GENERIC
Generic selection list.
@ MENU_PAGER
Pager pager (email viewer)
@ MENU_EDITOR
Text entry area.