NeoMutt  2019-11-11
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 "mutt/mutt.h"
29 #include "mutt_commands.h"
30 
31 #define MUTT_UNBIND 1<<0
32 #define MUTT_UNMACRO 1<<1
33 /* maximal length of a key binding sequence used for buffer in km_bindkey */
34 #define MAX_SEQ 8
35 
36 /* type for key storage, the rest of neomutt works fine with int type */
37 typedef short keycode_t;
38 
39 void init_extended_keys(void);
40 
46 struct Keymap
47 {
48  char *macro;
49  char *desc;
50  struct Keymap *next;
51  short op;
52  short eq;
53  short len;
55 };
56 
60 struct KeyEvent
61 {
62  int ch;
63  int op;
64 };
65 
70 {
83 #ifdef CRYPT_BACKEND_GPGME
84  MENU_KEY_SELECT_PGP,
85  MENU_KEY_SELECT_SMIME,
86 #endif
87 #ifdef MIXMASTER
88  MENU_MIX,
89 #endif
90 #ifdef USE_AUTOCRYPT
92 #endif
94 };
95 
96 int km_expand_key(char *s, size_t len, struct Keymap *map);
97 struct Keymap *km_find_func(enum MenuType menu, int func);
98 void km_init(void);
99 void km_error_key(enum MenuType menu);
100 void mutt_what_key(void);
101 
102 enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc);
103 int km_dokey(enum MenuType menu);
104 
105 extern struct Keymap *Keymaps[];
106 
107 extern int LastKey;
108 
109 extern const struct Mapping Menus[];
110 
114 struct Binding
115 {
116  const char *name;
117  int op;
118  const char *seq;
119 };
120 
121 const struct Binding *km_get_table(enum MenuType menu);
122 const char *mutt_get_func(const struct Binding *bindings, int op);
123 
124 extern const struct Binding OpGeneric[];
125 extern const struct Binding OpPost[];
126 extern const struct Binding OpMain[];
127 extern const struct Binding OpAttach[];
128 extern const struct Binding OpPager[];
129 extern const struct Binding OpCompose[];
130 extern const struct Binding OpBrowser[];
131 extern const struct Binding OpEditor[];
132 extern const struct Binding OpQuery[];
133 extern const struct Binding OpAlias[];
134 
135 extern const struct Binding OpPgp[];
136 
137 extern const struct Binding OpSmime[];
138 
139 #ifdef MIXMASTER
140 extern const struct Binding OpMix[];
141 #endif
142 
143 #ifdef USE_AUTOCRYPT
144 extern const struct Binding OpAutocryptAcct[];
145 #endif
146 
147 void mutt_keys_free(void);
148 
149 enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
150 enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
151 enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
152 enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
153 enum CommandResult mutt_parse_unbind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
154 enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
155 
156 #endif /* MUTT_KEYMAP_H */
short eq
number of leading keys equal to next entry
Definition: keymap.h:52
PGP encryption menu.
Definition: keymap.h:81
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
MenuType
Types of GUI selections.
Definition: keymap.h:69
void init_extended_keys(void)
Initialise map of ncurses extended keys.
Definition: keymap.c:897
const struct Binding OpQuery[]
Key bindings for the external query menu.
Definition: functions.h:592
int op
function id number
Definition: keymap.h:117
keycode_t * keys
key sequence
Definition: keymap.h:54
General file/mailbox browser.
Definition: keymap.h:75
enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;exec&#39; command - Implements command_t.
Definition: keymap.c:1533
String manipulation buffer.
Definition: buffer.h:33
Compose an email.
Definition: keymap.h:73
int op
function op
Definition: keymap.h:63
int ch
raw key pressed
Definition: keymap.h:62
Index panel (list of emails)
Definition: keymap.h:77
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1580
int LastKey
Last real key pressed, recorded by dokey()
Definition: keymap.c:147
enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;bind&#39; command - Implements command_t.
Definition: keymap.c:1273
const char * mutt_get_func(const struct Binding *bindings, int op)
Get the name of a function.
Definition: keymap.c:501
const struct Binding OpPgp[]
Key bindings for the pgp menu.
Definition: functions.h:635
SMIME encryption menu.
Definition: keymap.h:82
Pager pager (email viewer)
Definition: keymap.h:78
Select from results of external query.
Definition: keymap.h:80
const struct Binding OpMain[]
Key bindings for the index menu.
Definition: functions.h:103
const char * name
name of the function
Definition: keymap.h:116
short op
operation to perform
Definition: keymap.h:51
enum CommandResult mutt_parse_unbind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;unbind&#39; command - Implements command_t.
Definition: keymap.c:1414
void km_init(void)
Initialise all the menu keybindings.
Definition: keymap.c:927
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1054
void mutt_keys_free(void)
Free the key maps.
Definition: keymap.c:1601
enum CommandResult mutt_parse_macro(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;macro&#39; command - Implements command_t.
Definition: keymap.c:1479
const struct Binding OpPost[]
Key bindings for the postpone menu.
Definition: functions.h:521
struct Keymap * next
next key in map
Definition: keymap.h:50
const struct Binding OpGeneric[]
Key bindings for the generic menu.
Definition: functions.h:54
Select an attachment.
Definition: keymap.h:72
char * macro
macro expansion (op == OP_MACRO)
Definition: keymap.h:48
const struct Binding OpPager[]
Key bindings for the pager menu.
Definition: functions.h:261
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:619
Mapping from user command name to function.
const struct Binding OpBrowser[]
Key bindings for the file browser menu.
Definition: functions.h:539
An event such as a keypress.
Definition: keymap.h:60
short keycode_t
Definition: keymap.h:37
char * desc
description of a macro for the help menu
Definition: keymap.h:49
Select an email address by its alias.
Definition: keymap.h:71
const struct Binding OpAttach[]
Key bindings for the attachment menu.
Definition: functions.h:415
A keyboard mapping.
Definition: keymap.h:46
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function&#39;s mapping in a Menu.
Definition: keymap.c:856
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:62
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu&#39;s keybindings.
Definition: keymap.c:1223
const struct Binding OpCompose[]
Key bindings for the compose menu.
Definition: functions.h:451
enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc)
Bind a key to a macro.
Definition: keymap.c:440
const char * seq
default key binding
Definition: keymap.h:118
Mapping between user-readable string and a constant.
Definition: mapping.h:29
enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Text entry area.
Definition: keymap.h:74
const struct Binding OpAlias[]
Key bindings for the alias menu.
Definition: functions.h:530
enum CommandResult mutt_parse_push(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err)
Parse the &#39;push&#39; command - Implements command_t.
Definition: keymap.c:1110
const struct Binding OpEditor[]
Key bindings for the editor menu.
Definition: functions.h:603
Mapping between a user key and a function.
Definition: keymap.h:114
Select a postponed email.
Definition: keymap.h:79
const struct Binding OpAutocryptAcct[]
Key bindings for the autocrypt account.
Definition: functions.h:672
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:828
Generic selection list.
Definition: keymap.h:76
const struct Binding OpSmime[]
Key bindings for the smime menu.
Definition: functions.h:644