NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
keymap.h
Go to the documentation of this file.
1 
23 #ifndef MUTT_KEYMAP_H
24 #define MUTT_KEYMAP_H
25 
26 #include "config.h"
27 #include <stddef.h>
28 #include <stdint.h>
29 #include "mutt/lib.h"
30 #include "mutt_commands.h"
31 
32 #define MUTT_UNBIND 1<<0
33 #define MUTT_UNMACRO 1<<1
34 /* maximal length of a key binding sequence used for buffer in km_bindkey */
35 #define MAX_SEQ 8
36 
37 /* type for key storage, the rest of neomutt works fine with int type */
38 typedef short keycode_t;
39 
40 void init_extended_keys(void);
41 
47 struct Keymap
48 {
49  char *macro;
50  char *desc;
51  short op;
52  short eq;
53  short len;
55  STAILQ_ENTRY(Keymap) entries;
56 };
57 
58 STAILQ_HEAD(KeymapList, Keymap);
59 
63 struct KeyEvent
64 {
65  int ch;
66  int op;
67 };
68 
73 {
86 #ifdef CRYPT_BACKEND_GPGME
89 #endif
90 #ifdef MIXMASTER
92 #endif
93 #ifdef USE_AUTOCRYPT
95 #endif
97 };
98 
99 int km_expand_key(char *s, size_t len, struct Keymap *map);
100 struct Keymap *km_find_func(enum MenuType menu, int func);
101 void km_init(void);
102 void km_error_key(enum MenuType menu);
103 void mutt_what_key(void);
104 void mutt_init_abort_key(void);
106 
107 enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc);
108 int km_dokey(enum MenuType menu);
109 
110 extern struct KeymapList Keymaps[];
111 
112 extern int LastKey;
113 extern keycode_t AbortKey;
114 
115 extern const struct Mapping Menus[];
116 
120 struct Binding
121 {
122  const char *name;
123  int op;
124  const char *seq;
125 };
126 
131 {
132  enum MenuType menu;
133  const char *key;
134  int op;
135 };
136 
143 {
147 
151 };
152 
153 const struct Binding *km_get_table(enum MenuType menu);
154 const char *mutt_get_func(const struct Binding *bindings, int op);
155 
156 void mutt_keys_free(void);
157 
158 enum CommandResult mutt_parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
159 enum CommandResult mutt_parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
160 enum CommandResult mutt_parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
161 enum CommandResult mutt_parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
162 enum CommandResult mutt_parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
163 enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
164 
165 #endif /* MUTT_KEYMAP_H */
MENU_POSTPONE
@ MENU_POSTPONE
Select a postponed email.
Definition: keymap.h:82
NotifyBinding
NotifyBinding
Key Binding notification types.
Definition: keymap.h:142
MENU_GENERIC
@ MENU_GENERIC
Generic selection list.
Definition: keymap.h:79
Keymap::macro
char * macro
macro expansion (op == OP_MACRO)
Definition: keymap.h:49
MENU_QUERY
@ MENU_QUERY
Select from results of external query.
Definition: keymap.h:83
NotifyCallback
Data passed to a notification function.
Definition: observer.h:39
Binding
Mapping between a user key and a function.
Definition: keymap.h:120
km_get_table
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu's keybindings.
Definition: keymap.c:1306
keycode_t
short keycode_t
Definition: keymap.h:38
Buffer
String manipulation buffer.
Definition: buffer.h:33
Keymap::eq
short eq
number of leading keys equal to next entry
Definition: keymap.h:52
LastKey
int LastKey
Last real key pressed, recorded by dokey()
Definition: keymap.c:146
mutt_parse_exec
enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'exec' command - Implements Command::parse()
Definition: keymap.c:1629
EventBinding
A key binding Event.
Definition: keymap.h:130
MENU_PGP
@ MENU_PGP
PGP encryption menu.
Definition: keymap.h:84
NT_MACRO_NEW
@ NT_MACRO_NEW
A key macro has been created.
Definition: keymap.h:148
Keymaps
struct KeymapList Keymaps[]
Array of Keymap keybindings, one for each Menu.
Definition: keymap.c:149
MENU_ATTACH
@ MENU_ATTACH
Select an attachment.
Definition: keymap.h:75
MENU_MAX
@ MENU_MAX
Definition: keymap.h:96
Keymap::op
short op
operation to perform
Definition: keymap.h:51
NT_BINDING_DELETED
@ NT_BINDING_DELETED
A key binding has been deleted.
Definition: keymap.h:145
Binding::name
const char * name
name of the function
Definition: keymap.h:122
mutt_parse_bind
enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'bind' command - Implements Command::parse()
Definition: keymap.c:1356
AbortKey
keycode_t AbortKey
key to abort edits etc, normally Ctrl-G
Definition: keymap.c:147
EventBinding::menu
enum MenuType menu
Menu, e.g. MENU_PAGER.
Definition: keymap.h:132
Keymap::keys
keycode_t * keys
key sequence
Definition: keymap.h:54
init_extended_keys
void init_extended_keys(void)
Initialise map of ncurses extended keys.
Definition: keymap.c:981
Mapping
Mapping between user-readable string and a constant.
Definition: mapping.h:31
mutt_abort_key_config_observer
int mutt_abort_key_config_observer(struct NotifyCallback *nc)
Listen for abort_key config changes - Implements observer_t.
Definition: keymap.c:887
km_bind
enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc)
Bind a key to a macro.
Definition: keymap.c:478
km_dokey
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:658
mutt_parse_unbind
enum CommandResult mutt_parse_unbind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unbind' command - Implements Command::parse()
Definition: keymap.c:1490
NT_MACRO_DELETED
@ NT_MACRO_DELETED
A key macro has been deleted.
Definition: keymap.h:149
Keymap
A keyboard mapping.
Definition: keymap.h:47
MENU_KEY_SELECT_PGP
@ MENU_KEY_SELECT_PGP
Select a PGP key.
Definition: keymap.h:87
lib.h
km_init
void km_init(void)
Initialise all the menu keybindings.
Definition: keymap.c:1010
mutt_get_func
const char * mutt_get_func(const struct Binding *bindings, int op)
Get the name of a function.
Definition: keymap.c:539
MENU_COMPOSE
@ MENU_COMPOSE
Compose an email.
Definition: keymap.h:76
NT_MACRO_DELETE_ALL
@ NT_MACRO_DELETE_ALL
All key macros are about to be deleted.
Definition: keymap.h:150
Binding::seq
const char * seq
default key binding
Definition: keymap.h:124
KeyEvent::op
int op
function op
Definition: keymap.h:66
Keymap::STAILQ_ENTRY
STAILQ_ENTRY(Keymap) entries
next key in map
mutt_what_key
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1676
KeyEvent
An event such as a keypress.
Definition: keymap.h:63
MENU_SMIME
@ MENU_SMIME
SMIME encryption menu.
Definition: keymap.h:85
MENU_AUTOCRYPT_ACCT
@ MENU_AUTOCRYPT_ACCT
Autocrypt Account menu.
Definition: keymap.h:94
CommandResult
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
NT_BINDING_NEW
@ NT_BINDING_NEW
A key binding has been created.
Definition: keymap.h:144
km_find_func
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function's mapping in a Menu.
Definition: keymap.c:939
STAILQ_HEAD
STAILQ_HEAD(KeymapList, Keymap)
MENU_ALIAS
@ MENU_ALIAS
Select an email address by its alias.
Definition: keymap.h:74
km_error_key
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1137
Keymap::len
short len
length of key sequence (unit: sizeof (keycode_t))
Definition: keymap.h:53
NT_BINDING_DELETE_ALL
@ NT_BINDING_DELETE_ALL
All key bindings are about to be deleted.
Definition: keymap.h:146
MENU_MAIN
@ MENU_MAIN
Index panel (list of emails)
Definition: keymap.h:80
MENU_FOLDER
@ MENU_FOLDER
General file/mailbox browser.
Definition: keymap.h:78
EventBinding::key
const char * key
Key string being bound (for new bind/macro)
Definition: keymap.h:133
MenuType
MenuType
Types of GUI selections.
Definition: keymap.h:72
Menus
const struct Mapping Menus[]
Menu name lookup table.
Definition: keymap.c:61
MENU_EDITOR
@ MENU_EDITOR
Text entry area.
Definition: keymap.h:77
Keymap::desc
char * desc
description of a macro for the help menu
Definition: keymap.h:50
mutt_parse_push
enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'push' command - Implements Command::parse()
Definition: keymap.c:1193
Binding::op
int op
function id number
Definition: keymap.h:123
MENU_MIX
@ MENU_MIX
Create/edit a Mixmaster chain.
Definition: keymap.h:91
MENU_KEY_SELECT_SMIME
@ MENU_KEY_SELECT_SMIME
Select a SMIME key.
Definition: keymap.h:88
mutt_commands.h
mutt_parse_macro
enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'macro' command - Implements Command::parse()
Definition: keymap.c:1564
mutt_init_abort_key
void mutt_init_abort_key(void)
Parse the abort_key config string.
Definition: keymap.c:866
KeyEvent::ch
int ch
raw key pressed
Definition: keymap.h:65
km_expand_key
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:911
mutt_parse_unmacro
enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
MENU_PAGER
@ MENU_PAGER
Pager pager (email viewer)
Definition: keymap.h:81
mutt_keys_free
void mutt_keys_free(void)
Free the key maps.
Definition: keymap.c:1698
EventBinding::op
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
Definition: keymap.h:134