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 |
#define | MUTT_UNMACRO 1<<1 |
#define | MAX_SEQ 8 |
Typedefs | |
typedef short | keycode_t |
Type for key storage, the rest of neomutt works fine with int type. More... | |
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 | |
void | init_extended_keys (void) |
Initialise map of ncurses extended keys. More... | |
STAILQ_HEAD (KeymapList, Keymap) | |
int | km_expand_key (char *s, size_t len, struct Keymap *map) |
Get the key string bound to a Keymap. More... | |
struct Keymap * | km_find_func (enum MenuType menu, int func) |
Find a function's mapping in a Menu. More... | |
void | km_init (void) |
Initialise all the menu keybindings. More... | |
void | km_error_key (enum MenuType menu) |
Handle an unbound key sequence. More... | |
void | mutt_what_key (void) |
Ask the user to press a key. More... | |
void | mutt_init_abort_key (void) |
Parse the abort_key config string. More... | |
int | main_config_observer (struct NotifyCallback *nc) |
Notification that a Config Variable has changed - Implements observer_t -. More... | |
enum CommandResult | km_bind (char *s, enum MenuType menu, int op, char *macro, char *desc) |
Bind a key to a macro. More... | |
int | km_dokey (enum MenuType menu) |
Determine what a keypress should do. More... | |
struct KeyEvent | km_dokey_event (enum MenuType menu) |
Determine what a keypress should do. More... | |
const struct MenuFuncOp * | km_get_table (enum MenuType mtype) |
Lookup a Menu's functions. More... | |
const char * | mutt_get_func (const struct MenuFuncOp *bindings, int op) |
Get the name of a function. More... | |
void | mutt_keys_free (void) |
Free the key maps. More... | |
enum CommandResult | mutt_parse_bind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'bind' command - Implements Command::parse() -. More... | |
enum CommandResult | mutt_parse_exec (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'exec' command - Implements Command::parse() -. More... | |
enum CommandResult | mutt_parse_macro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'macro' command - Implements Command::parse() -. More... | |
enum CommandResult | mutt_parse_push (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'push' command - Implements Command::parse() -. More... | |
enum CommandResult | mutt_parse_unbind (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Parse the 'unbind' command - Implements Command::parse() -. More... | |
enum CommandResult | mutt_parse_unmacro (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) |
Variables | |
struct KeymapList | Keymaps [] |
Array of Keymap keybindings, one for each Menu. More... | |
keycode_t | AbortKey |
key to abort edits etc, normally Ctrl-G More... | |
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 keymap.h.
typedef short keycode_t |
enum NotifyBinding |
Key Binding notification types.
Observers of NT_BINDING will be passed an EventBinding.
Definition at line 123 of file keymap.h.
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 tigetstr() returns -1. 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 997 of file keymap.c.
STAILQ_HEAD | ( | KeymapList | , |
Keymap | |||
) |
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 929 of file keymap.c.
Find a function's mapping in a Menu.
mtype | Menu type, e.g. MENU_PAGER |
func | Function, e.g. OP_DELETE |
ptr | Keymap for the function |
Definition at line 957 of file keymap.c.
void km_init | ( | void | ) |
Initialise all the menu keybindings.
Definition at line 1026 of file keymap.c.
void km_error_key | ( | enum MenuType | mtype | ) |
Handle an unbound key sequence.
mtype | Menu type, e.g. MENU_PAGER |
Definition at line 1062 of file keymap.c.
void mutt_what_key | ( | void | ) |
Ask the user to press a key.
Displays the octal value back to the user.
Definition at line 1877 of file keymap.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 858 of file keymap.c.
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 459 of file keymap.c.
int km_dokey | ( | enum MenuType | mtype | ) |
Determine what a keypress should do.
mtype | Menu type, e.g. MENU_EDITOR |
>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 796 of file keymap.c.
Determine what a keypress should do.
mtype | Menu type, e.g. MENU_EDITOR |
ptr | Event |
Definition at line 638 of file keymap.c.
const struct MenuFuncOp * km_get_table | ( | enum MenuType | mtype | ) |
mtype | Menu type, e.g. MENU_EDITOR |
ptr | Array of functions |
Definition at line 1231 of file keymap.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 519 of file keymap.c.
void mutt_keys_free | ( | void | ) |
Free the key maps.
Definition at line 1907 of file keymap.c.
enum CommandResult mutt_parse_unmacro | ( | struct Buffer * | buf, |
struct Buffer * | s, | ||
intptr_t | data, | ||
struct Buffer * | err | ||
) |
|
extern |
|
extern |
|
extern |