#include "config.h"
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "keymap.h"
#include "ncrypt/lib.h"
#include "functions.h"
#include "init.h"
#include "mutt_commands.h"
#include "mutt_globals.h"
#include "mutt_logging.h"
#include "opcodes.h"
#include "options.h"
#include <strings.h>
#include "imap/lib.h"
#include "monitor.h"
Go to the source code of this file.
|
static void | mutt_keymap_free (struct Keymap **km) |
| Free a Keymap. More...
|
|
static void | mutt_keymaplist_free (struct KeymapList *km_list) |
| Free a List of Keymaps. More...
|
|
static struct Keymap * | alloc_keys (size_t len, keycode_t *keys) |
| Allocate space for a sequence of keys. More...
|
|
static int | parse_fkey (char *s) |
| Parse a function key string. More...
|
|
static int | parse_keycode (const char *s) |
| Parse a numeric keycode. More...
|
|
static size_t | parsekeys (const char *str, keycode_t *d, size_t max) |
| Parse a key string into key codes. More...
|
|
static struct Keymap * | km_compare_keys (struct Keymap *k1, struct Keymap *k2, size_t *pos) |
| Compare two keymaps' keyscodes and return the bigger one. More...
|
|
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. More...
|
|
enum CommandResult | km_bind (char *s, enum MenuType menu, int op, char *macro, char *desc) |
| Bind a key to a macro. More...
|
|
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) More...
|
|
static enum CommandResult | km_bindkey (const char *s, enum MenuType menu, int op) |
| Bind a key in a Menu to an operation. More...
|
|
static int | get_op (const struct Binding *bindings, const char *start, size_t len) |
| Get the function by its name. More...
|
|
const char * | mutt_get_func (const struct Binding *bindings, int op) |
| Get the name of a function. More...
|
|
static void | generic_tokenize_push_string (char *s, void(*generic_push)(int, int)) |
| Parse and queue a 'push' command. More...
|
|
static int | retry_generic (enum MenuType menu, keycode_t *keys, int keyslen, int lastkey) |
| Try to find the key in the generic menu bindings. More...
|
|
int | km_dokey (enum MenuType menu) |
| Determine what a keypress should do. More...
|
|
static void | create_bindings (const struct Binding *map, enum MenuType menu) |
| Attach a set of keybindings to a Menu. More...
|
|
static const char * | km_keyname (int c) |
| Get the human name for a key. More...
|
|
void | mutt_init_abort_key (void) |
| Parse the abort_key config string. More...
|
|
int | mutt_abort_key_config_observer (struct NotifyCallback *nc) |
| Listen for abort_key config changes - Implements observer_t. More...
|
|
int | km_expand_key (char *s, size_t len, struct Keymap *map) |
| Get the key string bound to a Keymap. More...
|
|
struct Keymap * | km_find_func (enum MenuType menu, int func) |
| Find a function's mapping in a Menu. More...
|
|
void | init_extended_keys (void) |
| Initialise map of ncurses extended keys. More...
|
|
void | km_init (void) |
| Initialise all the menu keybindings. More...
|
|
void | km_error_key (enum MenuType menu) |
| Handle an unbound key sequence. More...
|
|
enum CommandResult | mutt_parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'push' command - Implements Command::parse() More...
|
|
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. More...
|
|
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. More...
|
|
const struct Binding * | km_get_table (enum MenuType menu) |
| Lookup a menu's keybindings. More...
|
|
enum CommandResult | mutt_parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'bind' command - Implements Command::parse() More...
|
|
static void * | parse_menu (bool *menu, char *s, struct Buffer *err) |
| Parse menu-names into an array. More...
|
|
static void | km_unbind_all (struct KeymapList *km_list, unsigned long mode) |
| Free all the keys in the supplied Keymap. More...
|
|
enum CommandResult | mutt_parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'unbind' command - Implements Command::parse() More...
|
|
enum CommandResult | mutt_parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'macro' command - Implements Command::parse() More...
|
|
enum CommandResult | mutt_parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'exec' command - Implements Command::parse() More...
|
|
void | mutt_what_key (void) |
| Ask the user to press a key. More...
|
|
void | mutt_keys_free (void) |
| Free the key maps. More...
|
|
Manage keymappings
- Authors
-
- Copyright
- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
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 keymap.c.
◆ mutt_keymap_free()
static void mutt_keymap_free |
( |
struct Keymap ** |
km | ) |
|
|
static |
◆ mutt_keymaplist_free()
static void mutt_keymaplist_free |
( |
struct KeymapList * |
km_list | ) |
|
|
static |
Free a List of Keymaps.
- Parameters
-
km_list | List of Keymaps to free |
Definition at line 217 of file keymap.c.
219 struct Keymap *np = NULL, *tmp = NULL;
◆ alloc_keys()
Allocate space for a sequence of keys.
- Parameters
-
len | Number of keys |
keys | Array of keys |
- Return values
-
Definition at line 233 of file keymap.c.
◆ parse_fkey()
static int parse_fkey |
( |
char * |
s | ) |
|
|
static |
Parse a function key string.
- Parameters
-
- Return values
-
Given "<f8>", it will return 8.
Definition at line 249 of file keymap.c.
254 if ((s[0] !=
'<') || (tolower(s[1]) !=
'f'))
257 for (t = s + 2; *t && isdigit((
unsigned char) *t); t++)
◆ parse_keycode()
static int parse_keycode |
( |
const char * |
s | ) |
|
|
static |
Parse a numeric keycode.
- Parameters
-
- Return values
-
This function parses the string <NNN>
and uses the octal value as the key to bind.
Definition at line 276 of file keymap.c.
278 char *end_char = NULL;
279 long int result = strtol(s + 1, &end_char, 8);
284 if ((*end_char !=
'>') || (result < 0) || (result == LONG_MAX))
◆ parsekeys()
static size_t parsekeys |
( |
const char * |
str, |
|
|
keycode_t * |
d, |
|
|
size_t |
max |
|
) |
| |
|
static |
Parse a key string into key codes.
- Parameters
-
str | Key string |
d | Array for key codes |
max | Maximum length of key sequence |
- Return values
-
num | Length of key sequence |
Definition at line 299 of file keymap.c.
313 if ((*s ==
'<') && (t = strchr(s,
'>')))
341 *d = (
unsigned char) *s;
◆ km_compare_keys()
static struct Keymap* km_compare_keys |
( |
struct Keymap * |
k1, |
|
|
struct Keymap * |
k2, |
|
|
size_t * |
pos |
|
) |
| |
|
static |
Compare two keymaps' keyscodes and return the bigger one.
- Parameters
-
k1 | first keymap to compare |
k2 | second keymap to compare |
pos | position where the two keycodes differ |
- Return values
-
ptr | Keymap with a bigger ASCII keycode |
Definition at line 358 of file keymap.c.
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])
◆ km_bind_err()
Set up a key binding.
- Parameters
-
s | Key string |
menu | Menu id, e.g. MENU_EDITOR |
op | Operation, e.g. OP_DELETE |
macro | Macro string |
desc | Description of macro (OPTIONAL) |
err | Buffer for error message |
- Return values
-
Insert a key sequence into the specified map. The map is sorted by ASCII value (lowest to highest)
Definition at line 386 of file keymap.c.
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,
◆ km_bind()
Bind a key to a macro.
- Parameters
-
s | Key string |
menu | Menu id, e.g. MENU_EDITOR |
op | Operation, e.g. OP_DELETE |
macro | Macro string |
desc | Description of macro (OPTIONAL) |
- Return values
-
Definition at line 478 of file keymap.c.
◆ km_bindkey_err()
Bind a key in a Menu to an operation (with error message)
- Parameters
-
- Return values
-
Definition at line 491 of file keymap.c.
◆ km_bindkey()
Bind a key in a Menu to an operation.
- Parameters
-
- Return values
-
Definition at line 504 of file keymap.c.
◆ get_op()
static int get_op |
( |
const struct Binding * |
bindings, |
|
|
const char * |
start, |
|
|
size_t |
len |
|
) |
| |
|
static |
Get the function by its name.
- Parameters
-
bindings | Key bindings table |
start | Name of function to find |
len | Length of string to match |
- Return values
-
num | Operation, e.g. OP_DELETE |
Definition at line 516 of file keymap.c.
518 for (
int i = 0; bindings[i].
name; i++)
523 return bindings[i].
op;
◆ mutt_get_func()
const char* mutt_get_func |
( |
const struct Binding * |
bindings, |
|
|
int |
op |
|
) |
| |
Get the name of a function.
- Parameters
-
bindings | Key bindings table |
op | Operation, e.g. OP_DELETE |
- Return values
-
ptr | Name of function |
NULL | Operation not found |
- Note
- This returns a static string.
Definition at line 539 of file keymap.c.
541 for (
int i = 0; bindings[i].
name; i++)
543 if (bindings[i].
op ==
op)
544 return bindings[i].
name;
◆ generic_tokenize_push_string()
static void generic_tokenize_push_string |
( |
char * |
s, |
|
|
void(*)(int, int) |
generic_push |
|
) |
| |
|
static |
Parse and queue a 'push' command.
- Parameters
-
s | String to push into the key queue |
generic_push | Callback function to add events to macro queue |
Parses s for <function>
syntax and adds the whole sequence to either the macro or unget buffer. This function is invoked by the next two defines below.
Definition at line 559 of file keymap.c.
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);
◆ retry_generic()
static int retry_generic |
( |
enum MenuType |
menu, |
|
|
keycode_t * |
keys, |
|
|
int |
keyslen, |
|
|
int |
lastkey |
|
) |
| |
|
static |
Try to find the key in the generic menu bindings.
- Parameters
-
menu | Menu id, e.g. MENU_PAGER |
keys | Array of keys to return to the input queue |
keyslen | Number of keys in the array |
lastkey | Last key pressed (to return to input queue) |
- Return values
-
num | Operation, e.g. OP_DELETE |
Definition at line 632 of file keymap.c.
638 for (; keyslen; keyslen--)
◆ km_dokey()
Determine what a keypress should do.
- Parameters
-
- Return values
-
>0 | Function to execute |
OP_NULL | No function bound to key sequence |
-1 | Error occurred while reading input |
-2 | A timeout or sigwinch occurred |
Definition at line 658 of file keymap.c.
718 const char *func = NULL;
719 const struct Binding *bindings = NULL;
773 if (++pos == map->
len)
775 if (map->
op != OP_MACRO)
◆ create_bindings()
static void create_bindings |
( |
const struct Binding * |
map, |
|
|
enum MenuType |
menu |
|
) |
| |
|
static |
Attach a set of keybindings to a Menu.
- Parameters
-
Definition at line 814 of file keymap.c.
818 for (
int i = 0; map[i].
name; i++)
◆ km_keyname()
static const char* km_keyname |
( |
int |
c | ) |
|
|
static |
Get the human name for a key.
- Parameters
-
- Return values
-
- Note
- This returns a pointer to a static buffer.
Definition at line 830 of file keymap.c.
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);
◆ mutt_init_abort_key()
void mutt_init_abort_key |
( |
void |
| ) |
|
Parse the abort_key config string.
Parse the string into $abort_key
and put the keycode into AbortKey.
Definition at line 866 of file keymap.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);
◆ mutt_abort_key_config_observer()
◆ km_expand_key()
int km_expand_key |
( |
char * |
s, |
|
|
size_t |
len, |
|
|
struct Keymap * |
map |
|
) |
| |
Get the key string bound to a Keymap.
- Parameters
-
s | Buffer for the key string |
len | Length of buffer |
map | Keybinding map |
- Return values
-
Definition at line 911 of file keymap.c.
924 if ((++p >= map->
len) || !len)
◆ km_find_func()
Find a function's mapping in a Menu.
- Parameters
-
- Return values
-
Definition at line 939 of file keymap.c.
◆ init_extended_keys()
void init_extended_keys |
( |
void |
| ) |
|
Initialise map of ncurses extended keys.
Determine the keycodes for ncurses extended keys and fill in the KeyNames array.
This function must be called after initscr(), or tigetstr() returns -1. This creates a bit of a chicken-and-egg problem because km_init() is called prior to start_curses(). This means that the default keybindings can't include any of the extended keys because they won't be defined until later.
Definition at line 981 of file keymap.c.
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);
◆ km_init()
Initialise all the menu keybindings.
Definition at line 1010 of file keymap.c.
1029 #ifdef CRYPT_BACKEND_GPGME
1042 #ifdef USE_AUTOCRYPT
◆ km_error_key()
Handle an unbound key sequence.
- Parameters
-
Definition at line 1137 of file keymap.c.
1178 if (
op != OP_END_COND)
1187 mutt_error(
_(
"Key is not bound. Press '%s' for help."), buf);
◆ mutt_parse_push()
◆ parse_keymap()
static char* parse_keymap |
( |
enum MenuType * |
menu, |
|
|
struct Buffer * |
s, |
|
|
int |
max_menus, |
|
|
int * |
num_menus, |
|
|
struct Buffer * |
err, |
|
|
bool |
bind |
|
) |
| |
|
static |
Parse a user-config key binding.
- Parameters
-
menu | Array for results |
s | Buffer containing config string |
max_menus | Total number of menus |
num_menus | Number of menus this config applies to |
err | Buffer for error messages |
bind | If true 'bind', otherwise 'macro' |
- Return values
-
ptr | Key string for the binding |
Expects to see: <menu-string>,<menu-string>,... <key-string>
- Note
- Caller needs to free the returned string
Definition at line 1221 of file keymap.c.
1235 while (i < max_menus)
1258 if (buf.data[0] ==
'\0')
◆ try_bind()
Try to make a key binding.
- Parameters
-
key | Key name |
menu | Menu id, e.g. MENU_PAGER |
func | Function name |
bindings | Key bindings table |
err | Buffer for error message |
- Return values
-
Definition at line 1283 of file keymap.c.
1286 for (
int i = 0; bindings[i].
name; i++)
◆ km_get_table()
Lookup a menu's keybindings.
- Parameters
-
- Return values
-
Definition at line 1306 of file keymap.c.
1314 #ifdef USE_AUTOCRYPT
1326 #ifdef CRYPT_BACKEND_GPGME
◆ mutt_parse_bind()
Parse the 'bind' command - Implements Command::parse()
bind menu-name <key_sequence>
function-name
Definition at line 1356 of file keymap.c.
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';
◆ parse_menu()
static void* parse_menu |
( |
bool * |
menu, |
|
|
char * |
s, |
|
|
struct Buffer * |
err |
|
) |
| |
|
static |
Parse menu-names into an array.
- Parameters
-
menu | Array for results |
s | String containing menu-names |
err | Buffer for error messages |
Expects to see: <menu-string>[,<menu-string>]
Definition at line 1437 of file keymap.c.
1440 char *marker = menu_names_dup;
1441 char *menu_name = NULL;
1443 while ((menu_name = strsep(&marker,
",")))
1455 FREE(&menu_names_dup);
◆ km_unbind_all()
static void km_unbind_all |
( |
struct KeymapList * |
km_list, |
|
|
unsigned long |
mode |
|
) |
| |
|
static |
Free all the keys in the supplied Keymap.
- Parameters
-
Iterate through Keymap and free keys defined either by "macro" or "bind".
Definition at line 1466 of file keymap.c.
1468 struct Keymap *np = NULL, *tmp = NULL;
◆ mutt_parse_unbind()
Parse the 'unbind' command - Implements Command::parse()
Command unbinds:
- one binding in one menu-name
- one binding in all menu-names
- all bindings in all menu-names
unbind <menu-name[,...]|*>
[<key_sequence>
]
Definition at line 1490 of file keymap.c.
1494 bool all_keys =
false;
1516 const char *cmd = (data &
MUTT_UNMACRO) ?
"unmacro" :
"unbind";
◆ mutt_parse_macro()
Parse the 'macro' command - Implements Command::parse()
macro <menu>
<key>
<macro>
<description>
Definition at line 1564 of file keymap.c.
1577 if (buf->
data[0] ==
'\0')
1594 for (
int i = 0; i < num_menus; i++)
1610 for (
int i = 0; i < num_menus; i++)
◆ mutt_parse_exec()
Parse the 'exec' command - Implements Command::parse()
Definition at line 1629 of file keymap.c.
1634 const struct Binding *bindings = NULL;
1635 char *
function = NULL;
1646 function = buf->
data;
1656 if (ops[nops] == OP_NULL)
◆ mutt_what_key()
void mutt_what_key |
( |
void |
| ) |
|
Ask the user to press a key.
Displays the octal value back to the user.
Definition at line 1676 of file keymap.c.
1685 if ((ch != ERR) && (ch !=
AbortKey))
1689 }
while (ch != ERR && ch !=
AbortKey);
◆ mutt_keys_free()
void mutt_keys_free |
( |
void |
| ) |
|
Free the key maps.
Definition at line 1698 of file keymap.c.
◆ Menus
Initial value:
Menu name lookup table.
Definition at line 61 of file keymap.c.
◆ KeyNames
Key name lookup table.
Definition at line 87 of file keymap.c.
◆ LastKey
contains the last key the user pressed
Last real key pressed, recorded by dokey()
Definition at line 146 of file keymap.c.
◆ AbortKey
code of key to abort prompts, normally Ctrl-G
key to abort edits etc, normally Ctrl-G
Definition at line 147 of file keymap.c.
◆ Keymaps
@ 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)
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.
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.
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.
#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.
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)
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.
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.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
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.
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
@ 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.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)