Manage keymappings. More...
#include "config.h"
#include <stddef.h>
#include <stdint.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "menu/lib.h"
Go to the source code of this file.
Data Structures | |
struct | Keymap |
A keyboard mapping. More... | |
struct | KeyEvent |
An event such as a keypress. More... | |
struct | MenuFuncOp |
Mapping between a function and an operation. More... | |
struct | MenuOpSeq |
Mapping between an operation and a key sequence. More... | |
struct | EventBinding |
A key binding Event. More... | |
Macros | |
#define | MUTT_UNBIND (1 << 0) |
Parse 'unbind' command. | |
#define | MUTT_UNMACRO (1 << 1) |
Parse 'unmacro' command. | |
#define | GETCH_NO_FLAGS 0 |
No flags are set. | |
#define | GETCH_IGNORE_MACRO (1 << 0) |
Don't use MacroEvents. | |
Typedefs | |
typedef uint8_t | GetChFlags |
Flags for mutt_getch(), e.g. GETCH_NO_FLAGS. | |
typedef short | keycode_t |
Type for key storage, the rest of neomutt works fine with int type. | |
Enumerations | |
enum | NotifyBinding { NT_BINDING_ADD = 1 , NT_BINDING_DELETE , NT_BINDING_DELETE_ALL , NT_MACRO_ADD , NT_MACRO_DELETE , NT_MACRO_DELETE_ALL } |
Key Binding notification types. More... | |
Functions | |
STAILQ_HEAD (KeymapList, Keymap) | |
ARRAY_HEAD (KeyEventArray, struct KeyEvent) | |
enum CommandResult | mutt_parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'bind' command - Implements Command::parse() -. | |
enum CommandResult | mutt_parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'exec' command - Implements Command::parse() -. | |
enum CommandResult | mutt_parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'macro' command - Implements Command::parse() -. | |
enum CommandResult | mutt_parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'push' command - Implements Command::parse() -. | |
enum CommandResult | mutt_parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'unbind' command - Implements Command::parse() -. | |
enum CommandResult | mutt_parse_unmacro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
enum CommandResult | km_bind (char *s, enum MenuType menu, int op, char *macro, char *desc) |
Bind a key to a macro. | |
int | km_dokey (enum MenuType menu, GetChFlags flags) |
Determine what a keypress should do. | |
struct KeyEvent | km_dokey_event (enum MenuType menu, GetChFlags flags) |
Determine what a keypress should do. | |
void | km_error_key (enum MenuType menu) |
Handle an unbound key sequence. | |
int | km_expand_key (char *s, size_t len, struct Keymap *map) |
Get the key string bound to a Keymap. | |
int | km_expand_key_string (char *str, char *buf, size_t buflen) |
Get a human-readable key string. | |
struct Keymap * | km_find_func (enum MenuType menu, int func) |
Find a function's mapping in a Menu. | |
const struct MenuFuncOp * | km_get_table (enum MenuType mtype) |
Lookup a Menu's functions. | |
void | km_init (void) |
Initialise all the menu keybindings. | |
const char * | km_keyname (int c) |
Get the human name for a key. | |
void | init_extended_keys (void) |
Initialise map of ncurses extended keys. | |
int | main_config_observer (struct NotifyCallback *nc) |
Notification that a Config Variable has changed - Implements observer_t -. | |
void | mutt_flush_macro_to_endcond (void) |
Drop a macro from the input buffer. | |
void | mutt_init_abort_key (void) |
Parse the abort_key config string. | |
void | mutt_keys_cleanup (void) |
Free the key maps. | |
void | mw_what_key (void) |
Display the value of a key -. | |
struct Keymap * | alloc_keys (size_t len, keycode_t *keys) |
Allocate space for a sequence of keys. | |
enum CommandResult | dump_bind_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse 'bind' and 'macro' commands - Implements Command::parse() -. | |
void | generic_tokenize_push_string (char *s) |
Parse and queue a 'push' command. | |
int | get_op (const struct MenuFuncOp *funcs, const char *start, size_t len) |
Get the function by its name. | |
enum CommandResult | km_bindkey (const char *s, enum MenuType mtype, int op) |
Bind a key in a Menu to an operation. | |
struct Keymap * | km_compare_keys (struct Keymap *k1, struct Keymap *k2, size_t *pos) |
Compare two keymaps' keyscodes and return the bigger one. | |
const char * | mutt_get_func (const struct MenuFuncOp *bindings, int op) |
Get the name of a function. | |
void | mutt_keymap_free (struct Keymap **ptr) |
Free a Keymap. | |
size_t | parsekeys (const char *str, keycode_t *d, size_t max) |
Parse a key string into key codes. | |
Variables | |
struct KeyEventArray | MacroEvents |
These are used for macros and exec/push commands. | |
struct KeymapList | Keymaps [] |
Array of Keymap keybindings, one for each Menu. | |
struct Mapping | KeyNames [] |
Key name lookup table. | |
keycode_t | AbortKey |
key to abort edits etc, normally Ctrl-G | |
const struct Mapping | Menus [] |
Manage keymappings.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file lib.h.
typedef uint8_t GetChFlags |
Flags for mutt_getch(), e.g. GETCH_NO_FLAGS.
typedef short keycode_t |
enum NotifyBinding |
Key Binding notification types.
Observers of NT_BINDING will be passed an EventBinding.
Definition at line 132 of file lib.h.
STAILQ_HEAD | ( | KeymapList | , |
Keymap | |||
) |
ARRAY_HEAD | ( | KeyEventArray | , |
struct KeyEvent | |||
) |
enum CommandResult mutt_parse_unmacro | ( | struct Buffer * | buf, |
struct Buffer * | s, | ||
intptr_t | data, | ||
struct Buffer * | err | ||
) |
enum CommandResult km_bind | ( | char * | s, |
enum MenuType | mtype, | ||
int | op, | ||
char * | macro, | ||
char * | desc | ||
) |
Bind a key to a macro.
s | Key string |
mtype | Menu type, e.g. MENU_EDITOR |
op | Operation, e.g. OP_DELETE |
macro | Macro string |
desc | Description of macro (OPTIONAL) |
CommandResult | Result e.g. MUTT_CMD_SUCCESS |
Definition at line 160 of file parse.c.
int km_dokey | ( | enum MenuType | mtype, |
GetChFlags | flags | ||
) |
Determine what a keypress should do.
mtype | Menu type, e.g. MENU_EDITOR |
flags | Flags, e.g. GETCH_IGNORE_MACRO |
>0 | Function to execute |
OP_NULL | No function bound to key sequence |
-1 | Error occurred while reading input |
-2 | A timeout or sigwinch occurred |
Definition at line 464 of file get.c.
struct KeyEvent km_dokey_event | ( | enum MenuType | mtype, |
GetChFlags | flags | ||
) |
Determine what a keypress should do.
mtype | Menu type, e.g. MENU_EDITOR |
flags | Flags, e.g. GETCH_IGNORE_MACRO |
ptr | Event |
Definition at line 346 of file get.c.
void km_error_key | ( | enum MenuType | mtype | ) |
Handle an unbound key sequence.
mtype | Menu type, e.g. MENU_PAGER |
Definition at line 294 of file get.c.
int km_expand_key | ( | char * | s, |
size_t | len, | ||
struct Keymap * | map | ||
) |
Get the key string bound to a Keymap.
s | Buffer for the key string |
len | Length of buffer |
map | Keybinding map |
1 | Success |
0 | Error |
Definition at line 457 of file lib.c.
int km_expand_key_string | ( | char * | str, |
char * | buf, | ||
size_t | buflen | ||
) |
Get a human-readable key string.
str | Raw key string |
buf | Buffer for the key string |
buflen | Length of buffer |
num | Length of string |
Definition at line 486 of file lib.c.
const struct MenuFuncOp * km_get_table | ( | enum MenuType | mtype | ) |
mtype | Menu type, e.g. MENU_EDITOR |
ptr | Array of functions |
Definition at line 525 of file lib.c.
void km_init | ( | void | ) |
Initialise all the menu keybindings.
Definition at line 177 of file init.c.
const char * km_keyname | ( | int | c | ) |
Get the human name for a key.
c | Key code |
ptr | Name of the key |
Definition at line 410 of file lib.c.
void init_extended_keys | ( | void | ) |
Initialise map of ncurses extended keys.
Determine the keycodes for ncurses extended keys and fill in the KeyNames array.
This function must be called after initscr(), or mutt_tigetstr() fails. This creates a bit of a chicken-and-egg problem because km_init() is called prior to start_curses(). This means that the default keybindings can't include any of the extended keys because they won't be defined until later.
Definition at line 134 of file init.c.
void mutt_flush_macro_to_endcond | ( | void | ) |
Drop a macro from the input buffer.
All the macro text is deleted until an OP_END_COND command, or the buffer is empty.
Definition at line 166 of file get.c.
void mutt_init_abort_key | ( | void | ) |
Parse the abort_key config string.
Parse the string into $abort_key
and put the keycode into AbortKey.
Definition at line 237 of file init.c.
void mutt_keys_cleanup | ( | void | ) |
Free the key maps.
Definition at line 224 of file init.c.
Allocate space for a sequence of keys.
len | Number of keys |
keys | Array of keys |
ptr | Sequence of keys |
Definition at line 150 of file lib.c.
void generic_tokenize_push_string | ( | char * | s | ) |
Parse and queue a 'push' command.
s | String to push into the key queue |
Parses s for <function>
syntax and adds the whole sequence the macro buffer.
Definition at line 338 of file lib.c.
int get_op | ( | const struct MenuFuncOp * | funcs, |
const char * | start, | ||
size_t | len | ||
) |
Get the function by its name.
funcs | Functions table |
start | Name of function to find |
len | Length of string to match |
num | Operation, e.g. OP_DELETE |
Definition at line 299 of file lib.c.
enum CommandResult km_bindkey | ( | const char * | s, |
enum MenuType | mtype, | ||
int | op | ||
) |
Bind a key in a Menu to an operation.
s | Key string |
mtype | Menu type, e.g. MENU_PAGER |
op | Operation, e.g. OP_DELETE |
CommandResult | Result e.g. MUTT_CMD_SUCCESS |
Definition at line 186 of file parse.c.
Compare two keymaps' keyscodes and return the bigger one.
k1 | first keymap to compare |
k2 | second keymap to compare |
pos | position where the two keycodes differ |
ptr | Keymap with a bigger ASCII keycode |
Definition at line 275 of file lib.c.
const char * mutt_get_func | ( | const struct MenuFuncOp * | funcs, |
int | op | ||
) |
Get the name of a function.
funcs | Functions table |
op | Operation, e.g. OP_DELETE |
ptr | Name of function |
NULL | Operation not found |
Definition at line 321 of file lib.c.
void mutt_keymap_free | ( | struct Keymap ** | ptr | ) |
size_t parsekeys | ( | const char * | str, |
keycode_t * | d, | ||
size_t | max | ||
) |
Parse a key string into key codes.
str | Key string |
d | Array for key codes |
max | Maximum length of key sequence |
num | Length of key sequence |
Definition at line 216 of file lib.c.
|
extern |
These are used for macros and exec/push commands.
They can be temporarily ignored by passing GETCH_IGNORE_MACRO
|
extern |
|
extern |
|
extern |