NeoMutt  2022-04-29-215-gc12b98
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
39typedef short keycode_t;
40
41void init_extended_keys(void);
42
48struct Keymap
49{
50 char *macro;
51 char *desc;
52 short op;
53 short eq;
54 short len;
57};
58
59STAILQ_HEAD(KeymapList, Keymap);
60
65{
66 int ch;
67 int op;
68};
69
70int km_expand_key(char *s, size_t len, struct Keymap *map);
71struct Keymap *km_find_func(enum MenuType menu, int func);
72void km_init(void);
73void km_error_key(enum MenuType menu);
74void mutt_what_key(void);
75void mutt_init_abort_key(void);
77
78enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc);
79int km_dokey(enum MenuType menu);
80struct KeyEvent km_dokey_event(enum MenuType menu);
81
82extern struct KeymapList Keymaps[];
83
84extern keycode_t AbortKey;
85
86extern const struct Mapping Menus[];
87
92{
93 const char *name;
94 int op;
95};
96
101{
102 int op;
103 const char *seq;
104};
105
110{
112 const char *key;
113 int op;
114};
115
124{
128
132};
133
134const struct MenuFuncOp *km_get_table(enum MenuType mtype);
135const char *mutt_get_func(const struct MenuFuncOp *bindings, int op);
136
137void mutt_keys_free(void);
138
139enum CommandResult mutt_parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
140enum CommandResult mutt_parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
141enum CommandResult mutt_parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
142enum CommandResult mutt_parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
143enum CommandResult mutt_parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
144enum CommandResult mutt_parse_unmacro(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
145
146#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:1280
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:1430
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:1513
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:1117
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:1588
int main_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: keymap.c:879
const struct Mapping Menus[]
NotifyBinding
Key Binding notification types.
Definition: keymap.h:124
@ NT_MACRO_ADD
Key macro has been added.
Definition: keymap.h:129
@ NT_MACRO_DELETE
Key macro has been deleted.
Definition: keymap.h:130
@ NT_MACRO_DELETE_ALL
All key macros have been deleted.
Definition: keymap.h:131
@ NT_BINDING_DELETE
Key binding has been deleted.
Definition: keymap.h:126
@ NT_BINDING_ADD
Key binding has been added.
Definition: keymap.h:125
@ NT_BINDING_DELETE_ALL
All key bindings have been deleted.
Definition: keymap.h:127
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:124
struct KeyEvent km_dokey_event(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:637
void mutt_what_key(void)
Ask the user to press a key.
Definition: keymap.c:1638
STAILQ_HEAD(KeymapList, Keymap)
void km_init(void)
Initialise all the menu keybindings.
Definition: keymap.c:1025
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function's mapping in a Menu.
Definition: keymap.c:956
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:928
const char * mutt_get_func(const struct MenuFuncOp *bindings, int op)
Get the name of a function.
Definition: keymap.c:518
void km_error_key(enum MenuType menu)
Handle an unbound key sequence.
Definition: keymap.c:1061
void mutt_keys_free(void)
Free the key maps.
Definition: keymap.c:1668
int km_dokey(enum MenuType menu)
Determine what a keypress should do.
Definition: keymap.c:795
short keycode_t
Type for key storage, the rest of neomutt works fine with int type.
Definition: keymap.h:39
const struct MenuFuncOp * km_get_table(enum MenuType mtype)
Lookup a Menu's functions.
Definition: keymap.c:1230
void init_extended_keys(void)
Initialise map of ncurses extended keys.
Definition: keymap.c:996
enum CommandResult km_bind(char *s, enum MenuType menu, int op, char *macro, char *desc)
Bind a key to a macro.
Definition: keymap.c:458
struct KeymapList Keymaps[]
Array of Keymap keybindings, one for each Menu.
Definition: keymap.c:126
void mutt_init_abort_key(void)
Parse the abort_key config string.
Definition: keymap.c:857
GUI present the user with a selectable list.
Convenience wrapper for the library headers.
String manipulation buffer.
Definition: buffer.h:34
A key binding Event.
Definition: keymap.h:110
const char * key
Key string being bound (for new bind/macro)
Definition: keymap.h:112
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
Definition: keymap.h:113
enum MenuType menu
Menu, e.g. MENU_PAGER.
Definition: keymap.h:111
An event such as a keypress.
Definition: keymap.h:65
int op
Function opcode, e.g. OP_HELP.
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
Mapping between a function and an operation.
Definition: keymap.h:92
const char * name
Name of the function.
Definition: keymap.h:93
int op
Operation, e.g. OP_DELETE.
Definition: keymap.h:94
Mapping between an operation and a key sequence.
Definition: keymap.h:101
int op
Operation, e.g. OP_DELETE.
Definition: keymap.h:102
const char * seq
Default key binding.
Definition: keymap.h:103
Data passed to a notification function.
Definition: observer.h:34
MenuType
Types of GUI selections.
Definition: type.h:36