Go to the documentation of this file.
48 #ifndef USE_SLANG_CURSES
72 #ifdef CRYPT_BACKEND_GPGME
88 {
"<PageUp>", KEY_PPAGE },
89 {
"<PageDown>", KEY_NPAGE },
91 {
"<Down>", KEY_DOWN },
92 {
"<Right>", KEY_RIGHT },
93 {
"<Left>", KEY_LEFT },
94 {
"<Delete>", KEY_DC },
95 {
"<BackSpace>", KEY_BACKSPACE },
96 {
"<Insert>", KEY_IC },
97 {
"<Home>", KEY_HOME },
100 {
"<Return>",
'\r' },
105 {
"<BackTab>", KEY_BTAB },
108 {
"<Next>", KEY_NEXT },
110 #ifdef NCURSES_VERSION
151 #ifdef NCURSES_VERSION
161 static const struct Extkey ExtKeys[] = {
162 {
"<c-up>",
"kUP5" },
164 {
"<a-up>",
"kUP3" },
166 {
"<s-down>",
"kDN" },
167 {
"<a-down>",
"kDN3" },
168 {
"<c-down>",
"kDN5" },
170 {
"<c-right>",
"kRIT5" },
171 {
"<s-right>",
"kRIT" },
172 {
"<a-right>",
"kRIT3" },
174 {
"<s-left>",
"kLFT" },
175 {
"<a-left>",
"kLFT3" },
176 {
"<c-left>",
"kLFT5" },
178 {
"<s-home>",
"kHOM" },
179 {
"<a-home>",
"kHOM3" },
180 {
"<c-home>",
"kHOM5" },
182 {
"<s-end>",
"kEND" },
183 {
"<a-end>",
"kEND3" },
184 {
"<c-end>",
"kEND5" },
186 {
"<s-next>",
"kNXT" },
187 {
"<a-next>",
"kNXT3" },
188 {
"<c-next>",
"kNXT5" },
190 {
"<s-prev>",
"kPRV" },
191 {
"<a-prev>",
"kPRV3" },
192 {
"<c-prev>",
"kPRV5" },
219 struct Keymap *np = NULL, *tmp = NULL;
254 if ((s[0] !=
'<') || (tolower(s[1]) !=
'f'))
257 for (t = s + 2; *t && isdigit((
unsigned char) *t); t++)
278 char *end_char = NULL;
279 long int result = strtol(s + 1, &end_char, 8);
284 if ((*end_char !=
'>') || (result < 0) || (result == LONG_MAX))
313 if ((*s ==
'<') && (t = strchr(s,
'>')))
341 *d = (
unsigned char) *s;
360 while (*pos < k1->
len && *pos < k2->
len)
362 if (k1->
keys[*pos] < k2->
keys[*pos])
364 else if (k1->
keys[*pos] > k2->
keys[*pos])
390 struct Keymap *last = NULL, *np = NULL, *compare = NULL;
392 size_t pos = 0, lastpos = 0;
413 else if (compare == np)
421 if ((np->len !=
len) && (np->op != OP_NULL))
430 _(
"Binding '%s' will alias '%s' Before, try: 'bind %s %s noop' "
431 "https://neomutt.org/guide/configuration.html#bind-warnings");
435 snprintf(err->
data, err->
dsize, err_msg, old_binding, new_binding,
518 for (
int i = 0; bindings[i].
name; i++)
523 return bindings[i].
op;
541 for (
int i = 0; bindings[i].
name; i++)
543 if (bindings[i].
op ==
op)
544 return bindings[i].
name;
572 for (pp = p - 1; pp >= s && *pp !=
'<'; pp--)
580 generic_push(KEY_F(i), 0);
606 op =
get_op(binding, pp + 1, l - 2);
620 generic_push((
unsigned char) *p--, 0);
638 for (; keyslen; keyslen--)
718 const char *func = NULL;
719 const struct Binding *bindings = NULL;
773 if (++pos == map->
len)
775 if (map->
op != OP_MACRO)
818 for (
int i = 0; map[i].
name; i++)
838 if ((c < 256) && (c > -128) && iscntrl((
unsigned char) c))
846 buf[1] = (c +
'@') & 0x7f;
850 snprintf(buf,
sizeof(buf),
"\\%d%d%d", c >> 6, (c >> 3) & 7, c & 7);
852 else if ((c >= KEY_F0) && (c < KEY_F(256)))
853 sprintf(buf,
"<F%d>", c - KEY_F0);
855 snprintf(buf,
sizeof(buf),
"%c", (
unsigned char) c);
857 snprintf(buf,
sizeof(buf),
"\\x%hx", (
unsigned short) c);
872 mutt_error(
_(
"Abort key is not set, defaulting to Ctrl-G"));
879 _(
"Specified abort key sequence (%s) will be truncated to first key"),
C_AbortKey);
924 if ((++p >= map->
len) || !len)
950 #ifdef NCURSES_VERSION
960 static const char *find_ext_name(
const char *key)
962 for (
int j = 0; ExtKeys[j].name; j++)
964 if (strcasecmp(key, ExtKeys[j].name) == 0)
965 return ExtKeys[j].sym;
983 #ifdef NCURSES_VERSION
984 use_extended_names(
true);
990 const char *keyname = find_ext_name(
KeyNames[j].name);
994 char *s = tigetstr((
char *) keyname);
995 if (s && ((
long) (s) != -1))
997 int code = key_defined(s);
1029 #ifdef CRYPT_BACKEND_GPGME
1042 #ifdef USE_AUTOCRYPT
1178 if (
op != OP_END_COND)
1187 mutt_error(
_(
"Key is not bound. Press '%s' for help."), buf);
1194 intptr_t data,
struct Buffer *err)
1222 int *num_menus,
struct Buffer *err,
bool bind)
1235 while (i < max_menus)
1258 if (buf.
data[0] ==
'\0')
1286 for (
int i = 0; bindings[i].
name; i++)
1314 #ifdef USE_AUTOCRYPT
1326 #ifdef CRYPT_BACKEND_GPGME
1357 intptr_t data,
struct Buffer *err)
1359 const struct Binding *bindings = NULL;
1377 for (
int i = 0; i < num_menus; i++)
1391 for (
int i = 0; i < num_menus; i++)
1410 err->
data[0] =
'\0';
1440 char *marker = menu_names_dup;
1441 char *menu_name = NULL;
1443 while ((menu_name = strsep(&marker,
",")))
1455 FREE(&menu_names_dup);
1468 struct Keymap *np = NULL, *tmp = NULL;
1491 intptr_t data,
struct Buffer *err)
1494 bool all_keys =
false;
1516 const char *cmd = (data &
MUTT_UNMACRO) ?
"unmacro" :
"unbind";
1565 intptr_t data,
struct Buffer *err)
1577 if (buf->
data[0] ==
'\0')
1594 for (
int i = 0; i < num_menus; i++)
1610 for (
int i = 0; i < num_menus; i++)
1630 intptr_t data,
struct Buffer *err)
1634 const struct Binding *bindings = NULL;
1635 char *
function = NULL;
1646 function = buf->
data;
1656 if (ops[nops] == OP_NULL)
1685 if ((ch != ERR) && (ch !=
AbortKey))
1689 }
while (ch != ERR && ch !=
AbortKey);
@ MENU_POSTPONE
Select a postponed email.
const struct Binding OpCompose[]
Key bindings for the compose menu.
const struct Binding OpSmime[]
Key bindings for the smime menu.
@ MENU_GENERIC
Generic selection list.
#define STAILQ_INIT(head)
enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'macro' command - Implements Command::parse()
WHERE short C_Timeout
Config: Time to wait for user input in menus.
short C_ImapKeepalive
Config: (imap) Time to wait before polling an open IMAP connection.
char * macro
macro expansion (op == OP_MACRO)
void mutt_init_abort_key(void)
Parse the abort_key config string.
@ MENU_QUERY
Select from results of external query.
Data passed to a notification function.
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
bool MonitorFilesChanged
true after a monitored file has changed
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_getch_timeout(int delay)
Set the getch() timeout.
struct MuttWindow * MessageWindow
Message Window, ":set", etc.
const struct Binding OpAlias[]
Key bindings for the alias menu.
Mapping between a user key and a function.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
int mutt_window_mvprintw(struct MuttWindow *win, int col, int row, const char *fmt,...)
Move the cursor and write a formatted string to a Window.
#define MUTT_TOKEN_CONDENSE
^(char) to control chars (macros)
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
struct KeymapList Keymaps[MENU_MAX]
Array of Keymap keybindings, one for each Menu.
String manipulation buffer.
short eq
number of leading keys equal to next entry
static void mutt_keymaplist_free(struct KeymapList *km_list)
Free a List of Keymaps.
#define STAILQ_REMOVE(head, elm, type, field)
void mutt_unget_string(const char *s)
Return a string to the input buffer.
static void mutt_keymap_free(struct Keymap **km)
Free a Keymap.
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu's keybindings.
const struct Binding OpPost[]
Key bindings for the postpone menu.
const struct Binding OpQuery[]
Key bindings for the external query menu.
@ MENU_PGP
PGP encryption menu.
@ NT_MACRO_NEW
A key macro has been created.
struct Notify * notify
Notifications handler.
enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'exec' command - Implements Command::parse()
struct Buffer * mutt_buffer_init(struct Buffer *buf)
Initialise a new Buffer.
@ MENU_ATTACH
Select an attachment.
char * mutt_str_dup(const char *str)
Copy a string, safely.
void km_init(void)
Initialise all the menu keybindings.
#define STAILQ_FIRST(head)
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
short op
operation to perform
const struct Binding OpAttach[]
Key bindings for the attachment menu.
@ NT_BINDING_DELETED
A key binding has been deleted.
size_t dsize
Length of data.
const struct Binding OpEditor[]
Key bindings for the editor menu.
int LastKey
contains the last key the user pressed
const char * name
name of the function
WHERE bool OptIgnoreMacroEvents
(pseudo) don't process macro/push/exec events while set
const struct Binding OpPager[]
Key bindings for the pager menu.
enum MenuType menu
Menu, e.g. MENU_PAGER.
keycode_t * keys
key sequence
#define mutt_array_size(x)
#define STAILQ_FOREACH(var, head, field)
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
struct KeyEvent mutt_getch(void)
Read a character from the input buffer.
const struct Binding OpMain[]
Key bindings for the index menu.
enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'bind' command - Implements Command::parse()
static int retry_generic(enum MenuType menu, keycode_t *keys, int keyslen, int lastkey)
Try to find the key in the generic menu bindings.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Mapping between user-readable string and a constant.
static struct Keymap * alloc_keys(size_t len, keycode_t *keys)
Allocate space for a sequence of keys.
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
WHERE char * C_AbortKey
Config: String representation of key to abort prompts.
const struct Binding OpBrowser[]
Key bindings for the file browser menu.
@ NT_MACRO_DELETED
A key macro has been deleted.
@ MENU_KEY_SELECT_PGP
Select a PGP key.
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function's mapping in a Menu.
static enum CommandResult km_bindkey_err(const char *s, enum MenuType menu, int op, struct Buffer *err)
Bind a key in a Menu to an operation (with error message)
int mutt_abort_key_config_observer(struct NotifyCallback *nc)
Listen for abort_key config changes - Implements observer_t.
enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc)
Bind a key to a macro.
@ MENU_COMPOSE
Compose an email.
void mutt_flush_unget_to_endcond(void)
Clear entries from UngetKeyEvents.
static enum CommandResult km_bind_err(const char *s, enum MenuType menu, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
#define APPLICATION_PGP
Use PGP to encrypt/sign.
WHERE enum MenuType CurrentMenu
Current Menu, e.g. MENU_PAGER.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
@ NT_MACRO_DELETE_ALL
All key macros are about to be deleted.
const char * seq
default key binding
const char * mutt_get_func(const struct Binding *bindings, int op)
Get the name of a function.
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
#define STAILQ_INSERT_HEAD(head, elm, field)
keycode_t AbortKey
code of key to abort prompts, normally Ctrl-G
const struct Mapping Menus[]
Menu name lookup table.
static size_t parsekeys(const char *str, keycode_t *d, size_t max)
Parse a key string into key codes.
static void create_bindings(const struct Binding *map, enum MenuType menu)
Attach a set of keybindings to a Menu.
An event such as a keypress.
void init_extended_keys(void)
Initialise map of ncurses extended keys.
const struct Binding OpPgp[]
Key bindings for the pgp menu.
@ MUTT_CMD_SUCCESS
Success: Command worked.
@ NT_BINDING
Key binding has changed, NotifyBinding, EventBinding.
@ MENU_SMIME
SMIME encryption menu.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
@ MUTT_CMD_ERROR
Error: Can't help the user.
const struct Binding OpAutocryptAcct[]
Key bindings for the autocrypt account.
static int parse_fkey(char *s)
Parse a function key string.
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
@ MENU_AUTOCRYPT_ACCT
Autocrypt Account menu.
void * event_data
Data from notify_send()
CommandResult
Error codes for command_t parse functions.
@ NT_BINDING_NEW
A key binding has been created.
void mutt_flushinp(void)
Empty all the keyboard buffers.
static struct Mapping KeyNames[]
Key name lookup table.
enum CommandResult mutt_parse_unbind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unbind' command - Implements Command::parse()
@ MUTT_CMD_WARNING
Warning: Help given to the user.
void mutt_what_key(void)
Ask the user to press a key.
static enum CommandResult km_bindkey(const char *s, enum MenuType menu, int op)
Bind a key in a Menu to an operation.
@ MENU_ALIAS
Select an email address by its alias.
#define STAILQ_INSERT_TAIL(head, elm, field)
short len
length of key sequence (unit: sizeof (keycode_t))
@ NT_BINDING_DELETE_ALL
All key bindings are about to be deleted.
@ MENU_MAIN
Index panel (list of emails)
const char * name
Name of config item that changed.
Container for Accounts, Notifications.
static void generic_tokenize_push_string(char *s, void(*generic_push)(int, int))
Parse and queue a 'push' command.
@ MENU_FOLDER
General file/mailbox browser.
const char * key
Key string being bound (for new bind/macro)
MenuType
Types of GUI selections.
static void * parse_menu(bool *menu, char *s, struct Buffer *err)
Parse menu-names into an array.
static int get_op(const struct Binding *bindings, const char *start, size_t len)
Get the function by its name.
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
@ MENU_EDITOR
Text entry area.
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
static int parse_keycode(const char *s)
Parse a numeric keycode.
char * desc
description of a macro for the help menu
@ MENU_MIX
Create/edit a Mixmaster chain.
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field)
@ MENU_KEY_SELECT_SMIME
Select a SMIME key.
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
#define STAILQ_NEXT(elm, field)
static struct Keymap * km_compare_keys(struct Keymap *k1, struct Keymap *k2, size_t *pos)
Compare two keymaps' keyscodes and return the bigger one.
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
static const char * km_keyname(int c)
Get the human name for a key.
char * data
Pointer to data.
const struct Binding OpMix[]
Key bindings for the mixmaster menu.
static char * parse_keymap(enum MenuType *menu, struct Buffer *s, int max_menus, int *num_menus, struct Buffer *err, bool bind)
Parse a user-config key binding.
#define mutt_message(...)
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
const struct Binding OpGeneric[]
Key bindings for the generic menu.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
#define mutt_warning(...)
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
void imap_keepalive(void)
poll the current folder to keep the connection alive
enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'push' command - Implements Command::parse()
@ MENU_PAGER
Pager pager (email viewer)
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
static enum CommandResult try_bind(char *key, enum MenuType menu, char *func, const struct Binding *bindings, struct Buffer *err)
Try to make a key binding.
static void km_unbind_all(struct KeymapList *km_list, unsigned long mode)
Free all the keys in the supplied Keymap.
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
void mutt_keys_free(void)
Free the key maps.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)