Key helper functions. More...
#include "config.h"
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
Go to the source code of this file.
Functions | |
void | mutt_keymap_free (struct Keymap **ptr) |
Free a Keymap. | |
struct Keymap * | alloc_keys (size_t len, keycode_t *keys) |
Allocate space for a sequence of keys. | |
int | parse_fkey (char *s) |
Parse a function key string. | |
static int | parse_keycode (const char *s) |
Parse a numeric keycode. | |
size_t | parsekeys (const char *str, keycode_t *d, size_t max) |
Parse a key string into key codes. | |
struct Keymap * | km_compare_keys (struct Keymap *k1, struct Keymap *k2, size_t *pos) |
Compare two keymaps' keyscodes and return the bigger one. | |
int | get_op (const struct MenuFuncOp *funcs, const char *start, size_t len) |
Get the function by its name. | |
const char * | mutt_get_func (const struct MenuFuncOp *funcs, int op) |
Get the name of a function. | |
void | escape_macro (const char *macro, struct Buffer *buf) |
Escape any special characters in a macro. | |
bool | is_bound (const struct KeymapList *km_list, int op) |
Does a function have a keybinding? | |
int | binding_sort (const void *a, const void *b, void *sdata) |
Compare two BindingInfo by their keybinding - Implements sort_t -. | |
int | measure_column (struct BindingInfoArray *bia, int col) |
Measure one column of a table. | |
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. | |
void | km_keyname (int c, struct Buffer *buf) |
Get the human name for a key. | |
bool | km_expand_key (struct Keymap *map, struct Buffer *buf) |
Get the key string bound to a Keymap. | |
void | km_expand_key_string (char *str, struct Buffer *buf) |
Get a human-readable key string. | |
struct Keymap * | km_find_func (enum MenuType mtype, int func) |
Find a function's mapping in a Menu. | |
const struct MenuFuncOp * | km_get_table (enum MenuType mtype) |
Lookup a Menu's functions. | |
const char * | help_lookup_function (int op, enum MenuType menu) |
Find a keybinding for an operation. | |
void | gather_menu (enum MenuType menu, struct BindingInfoArray *bia_bind, struct BindingInfoArray *bia_macro) |
Gather info about one menu. | |
Variables | |
const struct MenuFuncOp | OpAlias [] |
Functions for the Alias Menu. | |
const struct MenuFuncOp | OpAttachment [] |
Functions for the Attachment Menu. | |
const struct MenuFuncOp | OpAutocrypt [] |
Functions for the Autocrypt Account. | |
const struct MenuFuncOp | OpBrowser [] |
Functions for the file Browser Menu. | |
const struct MenuFuncOp | OpCompose [] |
Functions for the Compose Menu. | |
const struct MenuFuncOp | OpEditor [] |
Functions for the Editor Menu. | |
const struct MenuFuncOp | OpIndex [] |
Functions for the Index Menu. | |
const struct MenuFuncOp | OpPager [] |
Functions for the Pager Menu. | |
const struct MenuFuncOp | OpPgp [] |
Functions for the Pgp Menu. | |
const struct MenuFuncOp | OpPostponed [] |
Functions for the Postpone Menu. | |
const struct MenuFuncOp | OpQuery [] |
Functions for the external Query Menu. | |
const struct MenuFuncOp | OpSmime [] |
Functions for the Smime Menu. | |
struct Mapping | KeyNames [] |
Key name lookup table. | |
keycode_t | AbortKey |
code of key to abort prompts, normally Ctrl-G | |
struct KeymapList | Keymaps [MENU_MAX] |
Array of key mappings, one for each MenuType. | |
Key helper functions.
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.c.
void mutt_keymap_free | ( | struct Keymap ** | ptr | ) |
Allocate space for a sequence of keys.
len | Number of keys |
keys | Array of keys |
ptr | Sequence of keys |
Definition at line 149 of file lib.c.
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 165 of file lib.c.
|
static |
Parse a numeric keycode.
s | String to parse |
num | Number of the key |
This function parses the string <NNN>
and uses the octal value as the key to bind.
Definition at line 192 of file lib.c.
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 215 of file lib.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 274 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 298 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 320 of file lib.c.
void escape_macro | ( | const char * | macro, |
struct Buffer * | buf | ||
) |
Escape any special characters in a macro.
[in] | macro | Macro string |
[out] | buf | Buffer for the result |
Replace characters, such as <Enter>
with the literal "\n"
Definition at line 338 of file lib.c.
bool is_bound | ( | const struct KeymapList * | km_list, |
int | op | ||
) |
Does a function have a keybinding?
km_list | Keymap to examine |
op | Operation, e.g. OP_DELETE |
true | A key is bound to that operation |
Definition at line 391 of file lib.c.
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 419 of file lib.c.
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 441 of file lib.c.
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 465 of file lib.c.
Get the key string bound to a Keymap.
[in] | map | Keybinding map |
[out] | buf | Buffer for the result |
true | Success |
Definition at line 509 of file lib.c.
void km_expand_key_string | ( | char * | str, |
struct Buffer * | buf | ||
) |
const struct MenuFuncOp * km_get_table | ( | enum MenuType | mtype | ) |
mtype | Menu type, e.g. MENU_EDITOR |
ptr | Array of functions |
Definition at line 557 of file lib.c.
const char * help_lookup_function | ( | int | op, |
enum MenuType | menu | ||
) |
Find a keybinding for an operation.
op | Operation, e.g. OP_DELETE |
menu | Current Menu, e.g. MENU_PAGER |
str | Key binding |
NULL | No key binding found |
Definition at line 603 of file lib.c.
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 624 of file lib.c.
|
extern |
Definition at line 60 of file functions.c.
|
extern |
Functions for the Attachment Menu.
Definition at line 62 of file functions.c.
|
extern |
Functions for the Autocrypt Account.
Definition at line 54 of file functions.c.
|
extern |
Functions for the file Browser Menu.
Definition at line 72 of file functions.c.
|
extern |
Functions for the Compose Menu.
Definition at line 87 of file functions.c.
|
extern |
Functions for the Editor Menu.
Definition at line 53 of file functions.c.
|
extern |
Functions for the Index Menu.
Definition at line 90 of file functions.c.
|
extern |
Functions for the Pager Menu.
Definition at line 71 of file functions.c.
|
extern |
Functions for the Pgp Menu.
Definition at line 42 of file functions.c.
|
extern |
Functions for the Postpone Menu.
Definition at line 52 of file functions.c.
|
extern |
Functions for the external Query Menu.
Definition at line 76 of file functions.c.
|
extern |
Functions for the Smime Menu.
Definition at line 52 of file functions.c.
keycode_t AbortKey |