diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-08-14 10:03:17 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-14 10:03:17 -0400 |
| commit | 3ccdbc570d856ee3ff1f64204e352a40b9030ac2 (patch) | |
| tree | e73d198bef4dce52bfd990dc57ea419e8b1fc703 /src/nvim/keymap.c | |
| parent | aa48c1c724f7164485782a3a5a8ff7a94373f607 (diff) | |
| download | rneovim-3ccdbc570d856ee3ff1f64204e352a40b9030ac2.tar.gz rneovim-3ccdbc570d856ee3ff1f64204e352a40b9030ac2.tar.bz2 rneovim-3ccdbc570d856ee3ff1f64204e352a40b9030ac2.zip | |
lua: add vim.register_keystroke_callback (#12536)
* feat: Add vim.register_keystroke_callback
* fixup: Forgot to remove mention of old option
* fixup: Answer jamessan comments
* fixup: Answer norcalli comments
* fixup: portability
* Update runtime/doc/lua.txt
Co-authored-by: Ashkan Kiani <ashkan.k.kiani@gmail.com>
Diffstat (limited to 'src/nvim/keymap.c')
| -rw-r--r-- | src/nvim/keymap.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index a553110552..2b6f022d9d 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -530,13 +530,24 @@ unsigned int trans_special(const char_u **srcp, const size_t src_len, { int modifiers = 0; int key; - unsigned int dlen = 0; key = find_special_key(srcp, src_len, &modifiers, keycode, false, in_string); if (key == 0) { return 0; } + return special_to_buf(key, modifiers, keycode, 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. +unsigned int special_to_buf(int key, int modifiers, bool keycode, char_u *dst) +{ + unsigned int dlen = 0; + // Put the appropriate modifier in a string. if (modifiers != 0) { dst[dlen++] = K_SPECIAL; |