Manage keymappings. More...
#include "config.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "mutt/lib.h"#include "core/lib.h"#include "menu/lib.h"
Include dependency graph for lib.h:
This graph shows which files directly or indirectly include this file: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 | BindingInfo |
| Info about one keybinding. 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. | |
| #define | OP_DEPRECATED true |
| Convenience symbol. | |
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) | |
| ARRAY_HEAD (BindingInfoArray, struct BindingInfo) | |
| static void | init_extended_keys (void) |
| enum CommandResult | km_bind (const char *s, enum MenuType mtype, int op, char *macro, char *desc, struct Buffer *err) |
| Set up a key binding. | |
| enum CommandResult | parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'bind' command - Implements Command::parse() -. | |
| enum CommandResult | parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'exec' command - Implements Command::parse() -. | |
| enum CommandResult | parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'macro' command - Implements Command::parse() -. | |
| enum CommandResult | parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'push' command - Implements Command::parse() -. | |
| enum CommandResult | parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
| Parse the 'unbind' command - Implements Command::parse() -. | |
| void | km_init (void) |
| Initialise all the menu keybindings. | |
| int | main_config_observer (struct NotifyCallback *nc) |
| void | mutt_init_abort_key (void) |
| Parse the abort_key config string. | |
| void | mutt_keys_cleanup (void) |
| Free the key maps. | |
| 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. | |
| void | mutt_flush_macro_to_endcond (void) |
| Drop a macro from the input buffer. | |
| bool | km_expand_key (struct Keymap *map, struct Buffer *buf) |
| Get the key string bound to a Keymap. | |
| 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_keyname (int c, struct Buffer *buf) |
| Get the human name for 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. | |
| 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. | |
| int | parse_fkey (char *s) |
| Parse a function key string. | |
| size_t | parsekeys (const char *str, keycode_t *d, size_t max) |
| Parse a key string into key codes. | |
| void | km_expand_key_string (char *str, struct Buffer *buf) |
| Get a human-readable key string. | |
| struct KeyEvent | mutt_getch (GetChFlags flags) |
| Read a character from the input buffer. | |
| void | mutt_flushinp (void) |
| Empty all the keyboard buffers. | |
| void | mutt_push_macro_event (int ch, int op) |
| Add the character/operation to the macro buffer. | |
| void | mutt_unget_ch (int ch) |
| Return a keystroke to the input buffer. | |
| void | mutt_unget_op (int op) |
| Return an operation to the input buffer. | |
| void | mutt_unget_string (const char *s) |
| Return a string to the input buffer. | |
| int | measure_column (struct BindingInfoArray *bia, int col) |
| Measure one column of a table. | |
| void | gather_menu (enum MenuType menu, struct BindingInfoArray *bia_bind, struct BindingInfoArray *bia_macro) |
| Gather info about one menu. | |
| int | gather_unbound (const struct MenuFuncOp *funcs, const struct KeymapList *km_menu, const struct KeymapList *km_aux, struct BindingInfoArray *bia_unbound) |
| Gather info about unbound functions for one menu. | |
| int | binding_sort (const void *a, const void *b, void *sdata) |
| Compare two BindingInfo by their keybinding - Implements sort_t -. | |
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 147 of file lib.h.
| STAILQ_HEAD | ( | KeymapList | , |
| Keymap | ) |
| ARRAY_HEAD | ( | KeyEventArray | , |
| struct KeyEvent | ) |
| ARRAY_HEAD | ( | BindingInfoArray | , |
| struct BindingInfo | ) |
| enum CommandResult km_bind | ( | const char * | s, |
| enum MenuType | mtype, | ||
| int | op, | ||
| char * | macro, | ||
| char * | desc, | ||
| struct Buffer * | err ) |
Set up a key binding.
| s | Key string |
| mtype | Menu type, e.g. MENU_EDITOR |
| op | Operation, e.g. OP_DELETE |
| macro | Macro string |
| desc | Description of macro (OPTIONAL) |
| err | Buffer for error message |
| CommandResult | Result e.g. MUTT_CMD_SUCCESS |
Insert a key sequence into the specified map. The map is sorted by ASCII value (lowest to highest)
Definition at line 58 of file commands.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void km_init | ( | void | ) |
Initialise all the menu keybindings.
Definition at line 85 of file init.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int main_config_observer | ( | struct NotifyCallback * | nc | ) |
Here is the call graph for this function:| 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 162 of file init.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_keys_cleanup | ( | void | ) |
Free the key maps.
Definition at line 146 of file init.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 537 of file get.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 419 of file get.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
Here is the call graph for this function:
Here is the caller graph for this function:Get the key string bound to a Keymap.
| [in] | map | Keybinding map |
| [out] | buf | Buffer for the result |
| true | Success |
Definition at line 434 of file lib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| const struct MenuFuncOp * km_get_table | ( | enum MenuType | mtype | ) |
| mtype | Menu type, e.g. MENU_EDITOR |
| ptr | Array of functions |
Definition at line 482 of file lib.c.
Here is the caller graph for this function:| void km_keyname | ( | int | c, |
| struct Buffer * | buf ) |
Get the human name for a key.
| [in] | c | Key code |
| [out] | buf | Buffer for the result |
Definition at line 390 of file lib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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 348 of file get.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
Here is the call graph for this function:
Here is the caller graph for this function: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.
Here is the caller graph for this function:| 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.
Here is the caller graph for this function:| void mutt_keymap_free | ( | struct Keymap ** | ptr | ) |
| int parse_fkey | ( | char * | s | ) |
Parse a function key string.
| s | String to parse |
| num | Number of the key |
Given "<f8>", it will return 8.
Definition at line 166 of file lib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| 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.
Here is the call graph for this function:
Here is the caller graph for this function:| void km_expand_key_string | ( | char * | str, |
| struct Buffer * | buf ) |
| struct KeyEvent mutt_getch | ( | GetChFlags | flags | ) |
Read a character from the input buffer.
| flags | Flags, e.g. GETCH_IGNORE_MACRO |
| obj | KeyEvent to process |
The priority for reading events is:
This function can return:
{ 0, OP_ABORT }{ 0, OP_REPAINT }{ 0, OP_TIMEOUT } Definition at line 210 of file get.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_flushinp | ( | void | ) |
Empty all the keyboard buffers.
Definition at line 58 of file get.c.
Here is the caller graph for this function:| void mutt_push_macro_event | ( | int | ch, |
| int | op ) |
Add the character/operation to the macro buffer.
| ch | Character to add |
| op | Operation to add |
Adds the ch/op to the macro buffer. This should be used for macros, push, and exec commands only.
Definition at line 155 of file get.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_unget_ch | ( | int | ch | ) |
| void mutt_unget_op | ( | int | op | ) |
| void mutt_unget_string | ( | const char * | s | ) |
| int measure_column | ( | struct BindingInfoArray * | bia, |
| int | col ) |
Measure one column of a table.
| bia | Array of binding info |
| col | Column to measure |
| num | Width of widest column |
Definition at line 413 of file dump.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void gather_menu | ( | enum MenuType | menu, |
| struct BindingInfoArray * | bia_bind, | ||
| struct BindingInfoArray * | bia_macro ) |
Gather info about one menu.
| menu | Menu type |
| bia_bind | Array for bind results (may be NULL) |
| bia_macro | Array for macro results (may be NULL) |
Definition at line 357 of file dump.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int gather_unbound | ( | const struct MenuFuncOp * | funcs, |
| const struct KeymapList * | km_menu, | ||
| const struct KeymapList * | km_aux, | ||
| struct BindingInfoArray * | bia_unbound ) |
Gather info about unbound functions for one menu.
| funcs | List of functions |
| km_menu | Keymaps for the menu |
| km_aux | Keymaps for generic |
| bia_unbound | Unbound functions |
| num | Number of unbound functions |
Definition at line 363 of file lib.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
extern |
These are used for macros and exec/push commands.
They can be temporarily ignored by passing GETCH_IGNORE_MACRO
|
extern |
|
extern |
Key name lookup table.
Definition at line 58 of file lib.c.
|
extern |
|
extern |