Data Structures | Macros | Functions
keymap.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
#include "nvim/ascii.h"
#include "nvim/charset.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/keymap.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/strings.h"
#include "nvim/vim.h"

Data Structures

struct  modmasktable
struct  key_name_entry
struct  mousetable




int simplify_key (const int key, int *modifiers) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
int handle_x_keys (const int key) FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT
 Change <xKey> to <Key> More...
char_uget_special_key_name (int c, int modifiers)
unsigned int trans_special (const char_u **srcp, const size_t src_len, char_u *const dst, const bool keycode, const bool in_string) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
unsigned int special_to_buf (int key, int modifiers, bool keycode, char_u *dst)
int find_special_key (const char_u **srcp, const size_t src_len, int *const modp, const bool keycode, const bool keep_x_key, const bool in_string) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
int find_special_key_in_table (int c)
int get_special_key_code (const char_u *name) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
int get_mouse_button (int code, bool *is_click, bool *is_drag)
char_ureplace_termcodes (const char_u *from, const size_t from_len, char_u **bufp, const bool from_part, const bool do_lt, const bool special, int cpo_flags) FUNC_ATTR_NONNULL_ALL
void log_key (int log_level, int key)
 Logs a single key as a human-readable keycode. More...

Macro Definition Documentation



Function Documentation

◆ find_special_key()

int find_special_key ( const char_u **  srcp,
const size_t  src_len,
int *const  modp,
const bool  keycode,
const bool  keep_x_key,
const bool  in_string 

Try translating a <> name

[in,out]srcpTranslated <> name. Is advanced to after the <> name.
[in]src_lensrcp length.
[out]modpLocation where information about modifiers is saved.
[in]keycodePrefer key code, e.g. K_DEL in place of DEL.
[in]keep_x_keyDon’t translate xHome to Home key.
[in]in_stringIn string, double quote is escaped
Key and modifiers or 0 if there is no match.

◆ find_special_key_in_table()

int find_special_key_in_table ( int  c)

◆ get_mouse_button()

int get_mouse_button ( int  code,
bool is_click,
bool is_drag 

◆ get_special_key_code()

int get_special_key_code ( const char_u name)

Find the special key with the given name

[in]nameName of the special. Does not have to end with NUL, it is assumed to end before the first non-idchar. If name starts with "t_" the next two characters are interpreted as a termcap name.
Key code or 0 if not found.

◆ get_special_key_name()

char_u* get_special_key_name ( int  c,
int  modifiers 

◆ handle_x_keys()

int handle_x_keys ( const int  key)

Change <xKey> to <Key>

◆ log_key()

void log_key ( int  log_level,
int  key 

Logs a single key as a human-readable keycode.

◆ name_to_mod_mask()

int name_to_mod_mask ( int  c)

Return the modifier mask bit (#MOD_MASK_*) corresponding to mod name

E.g. 'S' for shift, 'C' for ctrl.

◆ replace_termcodes()

char_u* replace_termcodes ( const char_u from,
const size_t  from_len,
char_u **  bufp,
const bool  from_part,
const bool  do_lt,
const bool  special,
int  cpo_flags 

Replace any terminal code strings with the equivalent internal representation

Used for the "from" and "to" part of a mapping, and the "to" part of a menu command. Any strings like "<C-UP>" are also replaced, unless special is false. K_SPECIAL by itself is replaced by K_SPECIAL KS_SPECIAL KE_FILLER.

[in]fromWhat characters to replace.
[in]from_lenLength of the "from" argument.
[out]bufpLocation where results were saved in case of success (allocated). Will be set to NULL in case of failure.
[in]do_ltIf true, also translate <lt>.
[in]from_partIf true, trailing <C-v> is included, otherwise it is removed (to make ":map xx ^V" map xx to nothing). When cpo_flags contains FLAG_CPO_BSLASH, a backslash can be used in place of <C-v>. All other <C-v> characters are removed.
[in]specialReplace keycodes, e.g. <CR> becomes a "\n" char.
[in]cpo_flagsRelevant flags derived from p_cpo, see CPO_TO_CPO_FLAGS.
Pointer to an allocated memory in case of success, "from" in case of failure. In case of success returned pointer is also saved to "bufp".

◆ simplify_key()

int simplify_key ( const int  key,
int *  modifiers 

Check if there is a special key code for "key" with specified modifiers

[in]keyInitial key code.
[in,out]modifiersInitial modifiers, is adjusted to have simplified modifiers.
Simplified key code.

◆ special_to_buf()

unsigned int special_to_buf ( int  key,
int  modifiers,
bool  keycode,
char_u dst 

Put the character sequence for "key" with "modifiers" into "dst" and return the resulting length. When "keycode" is true prefer key code, e.g. K_DEL instead of DEL. The sequence is not NUL terminated. This is how characters in a string are encoded.

◆ trans_special()

unsigned int trans_special ( const char_u **  srcp,
const size_t  src_len,
char_u *const  dst,
const bool  keycode,
const bool  in_string 

Try translating a <> name ("keycode").

[in,out]srcpSource from which <> are translated. Is advanced to after the <> name if there is a match.
[in]src_lenLength of the srcp.
[out]dstLocation where translation result will be kept. It must
[in]keycodePrefer key code, e.g. K_DEL in place of DEL.
[in]in_stringInside a double quoted string
Number of characters added to dst, zero for no match.