NeoMutt  2021-10-22-8-g9cb437
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 "core/lib.h"
31 #include "menu/lib.h"
32 
33 #define MUTT_UNBIND 1<<0
34 #define MUTT_UNMACRO 1<<1
35 /* maximal length of a key binding sequence used for buffer in km_bindkey */
36 #define MAX_SEQ 8
37 
39 typedef short keycode_t;
40 
41 void init_extended_keys(void);
42 
48 struct Keymap
49 {
50  char *macro;
51  char *desc;
52  short op;
53  short eq;
54  short len;
56  STAILQ_ENTRY(Keymap) entries;
57 };
58 
59 STAILQ_HEAD(KeymapList, Keymap);
60 
64 struct KeyEvent
65 {
66  int ch;
67  int op;
68 };
69 
70 int km_expand_key(char *s, size_t len, struct Keymap *map);
71 struct Keymap *km_find_func(enum MenuType menu, int func);
72 void km_init(void);
73 void km_error_key(enum MenuType menu);
74 void mutt_what_key(void);
75 void mutt_init_abort_key(void);
76 int main_config_observer(struct NotifyCallback *nc);
77 
78 enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc);
79 int km_dokey(enum MenuType menu);
80 
81 extern struct KeymapList Keymaps[];
82 
83 extern int LastKey;
84 extern keycode_t AbortKey;
85 
86 extern const struct Mapping Menus[];
87 
91 struct Binding
92 {
93  const char *name;
94  int op;
95  const char *seq;
96 };
97 
102 {
103  enum MenuType menu;
104  const char *key;
105  int op;
106 };
107 
116 {
120 
124 };
125 
126 const struct Binding *km_get_table(enum MenuType menu);
127 const char *mutt_get_func(const struct Binding *bindings, int op);
128 
129 void mutt_keys_free(void);
130 
131 enum CommandResult mutt_parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
132 enum CommandResult mutt_parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
133 enum CommandResult mutt_parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
134 enum CommandResult mutt_parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
135 enum CommandResult mutt_parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
136 enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
137 
138 #endif /* MUTT_KEYMAP_H */
CommandResult
Error codes for command_t parse functions.
Definition: command.h:34
Convenience wrapper for the core headers.
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:1351
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:1500
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:1583
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:1188
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:1658
int main_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: keymap.c:863
const struct Mapping Menus[]
NotifyBinding
Key Binding notification types.
Definition: keymap.h:116
@ NT_MACRO_ADD
Key macro has been added.
Definition: keymap.h:121
@ NT_MACRO_DELETE
Key macro has been deleted.
Definition: keymap.h:122
@ NT_MACRO_DELETE_ALL
All key macros have been deleted.
Definition: keymap.h:123
@ NT_BINDING_DELETE
Key binding has been deleted.
Definition: keymap.h:118
@ NT_BINDING_ADD
Key binding has been added.
Definition: keymap.h:117
@ NT_BINDING_DELETE_ALL
All key bindings have been deleted.
Definition: keymap.h:119
enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
keycode_t AbortKey
key to abort edits etc, normally Ctrl-G
Definition: keymap.c:118
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1706
STAILQ_HEAD(KeymapList, Keymap)
void km_init(void)
Initialise all the menu keybindings.
Definition: keymap.c:1005
int LastKey
Last real key pressed, recorded by dokey()
Definition: keymap.c:117
const struct Binding * km_get_table(enum MenuType menu)
Lookup a menu's keybindings.
Definition: keymap.c:1301
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:910
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1132
void mutt_keys_free(void)
Free the key maps.
Definition: keymap.c:1731
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:627
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
Definition: keymap.h:39
const char * mutt_get_func(const struct Binding *bindings, int op)
Get the name of a function.
Definition: keymap.c:508
void init_extended_keys(void)
Initialise map of ncurses extended keys.
Definition: keymap.c:978
enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc)
Bind a key to a macro.
Definition: keymap.c:447
struct KeymapList Keymaps[]
Array of Keymap keybindings, one for each Menu.
Definition: keymap.c:120
void mutt_init_abort_key(void)
Parse the abort_key config string.
Definition: keymap.c:841
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function's mapping in a Menu.
Definition: keymap.c:938
GUI present the user with a selectable list.
Convenience wrapper for the library headers.
Mapping between a user key and a function.
Definition: keymap.h:92
int op
function id number
Definition: keymap.h:94
const char * name
name of the function
Definition: keymap.h:93
const char * seq
default key binding
Definition: keymap.h:95
String manipulation buffer.
Definition: buffer.h:34
A key binding Event.
Definition: keymap.h:102
const char * key
Key string being bound (for new bind/macro)
Definition: keymap.h:104
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
Definition: keymap.h:105
enum MenuType menu
Menu, e.g. MENU_PAGER.
Definition: keymap.h:103
An event such as a keypress.
Definition: keymap.h:65
int op
function op
Definition: keymap.h:67
int ch
raw key pressed
Definition: keymap.h:66
A keyboard mapping.
Definition: keymap.h:49
keycode_t * keys
key sequence
Definition: keymap.h:55
char * macro
macro expansion (op == OP_MACRO)
Definition: keymap.h:50
STAILQ_ENTRY(Keymap) entries
next key in map
short eq
number of leading keys equal to next entry
Definition: keymap.h:53
char * desc
description of a macro for the help menu
Definition: keymap.h:51
short len
length of key sequence (unit: sizeof (keycode_t))
Definition: keymap.h:54
short op
operation to perform
Definition: keymap.h:52
Mapping between user-readable string and a constant.
Definition: mapping.h:32
Data passed to a notification function.
Definition: observer.h:34
MenuType
Types of GUI selections.
Definition: type.h:36