NeoMutt  2020-09-25
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 */
short eq
number of leading keys equal to next entry
Definition: keymap.h:52
PGP encryption menu.
Definition: keymap.h:84
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
Data passed to a notification function.
Definition: observer.h:39
MenuType
Types of GUI selections.
Definition: keymap.h:72
void init_extended_keys(void)
Initialise map of ncurses extended keys.
Definition: keymap.c:981
int op
function id number
Definition: keymap.h:123
enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the &#39;exec&#39; command - Implements Command::parse()
Definition: keymap.c:1629
A key binding has been created.
Definition: keymap.h:144
keycode_t * keys
key sequence
Definition: keymap.h:54
int op
Operation the key&#39;s bound to (for bind), e.g. OP_DELETE.
Definition: keymap.h:134
enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the &#39;push&#39; command - Implements Command::parse()
Definition: keymap.c:1193
enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
General file/mailbox browser.
Definition: keymap.h:78
String manipulation buffer.
Definition: buffer.h:33
Autocrypt Account menu.
Definition: keymap.h:94
Compose an email.
Definition: keymap.h:76
int op
function op
Definition: keymap.h:66
int ch
raw key pressed
Definition: keymap.h:65
A key macro has been deleted.
Definition: keymap.h:149
Index panel (list of emails)
Definition: keymap.h:80
NotifyBinding
Key Binding notification types.
Definition: keymap.h:142
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1676
int LastKey
Last real key pressed, recorded by dokey()
Definition: keymap.c:146
enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the &#39;bind&#39; command - Implements Command::parse()
Definition: keymap.c:1356
enum CommandResult mutt_parse_unbind(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the &#39;unbind&#39; command - Implements Command::parse()
Definition: keymap.c:1490
const char * mutt_get_func(const struct Binding *bindings, int op)
Get the name of a function.
Definition: keymap.c:539
All key bindings are about to be deleted.
Definition: keymap.h:146
const char * key
Key string being bound (for new bind/macro)
Definition: keymap.h:133
SMIME encryption menu.
Definition: keymap.h:85
Pager pager (email viewer)
Definition: keymap.h:81
void mutt_init_abort_key(void)
Parse the abort_key config string.
Definition: keymap.c:866
Select from results of external query.
Definition: keymap.h:83
struct KeymapList Keymaps[]
Array of Keymap keybindings, one for each Menu.
Definition: keymap.c:149
const char * name
name of the function
Definition: keymap.h:122
short op
operation to perform
Definition: keymap.h:51
keycode_t AbortKey
key to abort edits etc, normally Ctrl-G
Definition: keymap.c:147
void km_init(void)
Initialise all the menu keybindings.
Definition: keymap.c:1010
All key macros are about to be deleted.
Definition: keymap.h:150
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1137
void mutt_keys_free(void)
Free the key maps.
Definition: keymap.c:1698
STAILQ_ENTRY(Keymap) entries
next key in map
int mutt_abort_key_config_observer(struct NotifyCallback *nc)
Listen for abort_key config changes - Implements observer_t.
Definition: keymap.c:887
Select an attachment.
Definition: keymap.h:75
char * macro
macro expansion (op == OP_MACRO)
Definition: keymap.h:49
Select a PGP key.
Definition: keymap.h:87
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:658
Definitions of NeoMutt commands.
An event such as a keypress.
Definition: keymap.h:63
short keycode_t
Definition: keymap.h:38
char * desc
description of a macro for the help menu
Definition: keymap.h:50
A key binding has been deleted.
Definition: keymap.h:145
Select an email address by its alias.
Definition: keymap.h:74
A keyboard mapping.
Definition: keymap.h:47
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function&#39;s mapping in a Menu.
Definition: keymap.c:939
short len
length of key sequence (unit: sizeof (keycode_t))
Definition: keymap.h:53
const struct Mapping Menus[]
Menu name lookup table.
Definition: keymap.c:61
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu&#39;s keybindings.
Definition: keymap.c:1306
enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the &#39;macro&#39; command - Implements Command::parse()
Definition: keymap.c:1564
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
Create/edit a Mixmaster chain.
Definition: keymap.h:91
const char * seq
default key binding
Definition: keymap.h:124
Select a SMIME key.
Definition: keymap.h:88
Mapping between user-readable string and a constant.
Definition: mapping.h:31
Text entry area.
Definition: keymap.h:77
Convenience wrapper for the library headers.
Mapping between a user key and a function.
Definition: keymap.h:120
Select a postponed email.
Definition: keymap.h:82
A key macro has been created.
Definition: keymap.h:148
A key binding Event.
Definition: keymap.h:130
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:911
STAILQ_HEAD(KeymapList, Keymap)
Generic selection list.
Definition: keymap.h:79