diff options
author | TJ DeVries <timothydvrs1234@gmail.com> | 2017-05-25 05:41:53 -0500 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2017-05-25 12:41:53 +0200 |
commit | 45626de63f2b8057c13df0466406c43f04d6a1e6 (patch) | |
tree | 8d7b632a2be423f21d93d895cafe22e1a3ce60fa /src/nvim/getchar.c | |
parent | f4fddbfb778ad5c6600af90d323156e42ee13450 (diff) | |
download | rneovim-45626de63f2b8057c13df0466406c43f04d6a1e6.tar.gz rneovim-45626de63f2b8057c13df0466406c43f04d6a1e6.tar.bz2 rneovim-45626de63f2b8057c13df0466406c43f04d6a1e6.zip |
get_keymap API (#6236)
* Add api function get keymap
nvim_get_keymap(mode)
nvim_buf_get_keymap(buffer, mode)
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index c3c393f1ec..382caa8548 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -18,6 +18,7 @@ #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/getchar.h" +#include "nvim/buffer_defs.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/edit.h" @@ -47,6 +48,7 @@ #include "nvim/event/loop.h" #include "nvim/os/input.h" #include "nvim/os/os.h" +#include "nvim/api/private/handle.h" /* * These buffers are used for storing: @@ -102,11 +104,10 @@ static int block_redo = FALSE; (NORMAL + VISUAL + SELECTMODE + \ OP_PENDING)) ? (c1) : ((c1) ^ 0x80)) -/* - * Each mapping is put in one of the 256 hash lists, to speed up finding it. - */ -static mapblock_T *(maphash[256]); -static int maphash_valid = FALSE; +// Each mapping is put in one of the MAX_MAPHASH hash lists, +// to speed up finding it. +static mapblock_T *(maphash[MAX_MAPHASH]); +static bool maphash_valid = false; /* * List used for abbreviations. @@ -4237,3 +4238,17 @@ static bool typebuf_match_len(const uint8_t *str, int *mlen) *mlen = i; return str[i] == NUL; // matched the whole string } + +/// Retrieve the mapblock at the index either globally or for a certain buffer +/// +/// @param index The index in the maphash[] +/// @param buf The buffer to get the maphash from. NULL for global +mapblock_T *get_maphash(int index, buf_T *buf) + FUNC_ATTR_PURE +{ + if (index > MAX_MAPHASH) { + return NULL; + } + + return (buf == NULL) ? maphash[index] : buf->b_maphash[index]; +} |