diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-03-14 14:00:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 14:00:56 +0100 |
commit | d1e0f7454b5fc61d26db5af5ce00c1894e7c49fc (patch) | |
tree | ef972775c047745b19db5c06e1e490090d3a26f0 /src/nvim/digraph.c | |
parent | 4f7879dff0f0dc22ddf4cb2a2095b88605a3bab0 (diff) | |
parent | d6ecead36406233cc56353dd05f3380f0497630f (diff) | |
download | rneovim-d1e0f7454b5fc61d26db5af5ce00c1894e7c49fc.tar.gz rneovim-d1e0f7454b5fc61d26db5af5ce00c1894e7c49fc.tar.bz2 rneovim-d1e0f7454b5fc61d26db5af5ce00c1894e7c49fc.zip |
Merge pull request #22666 from bfredl/unscreen
refactor(screen): screen.c delenda est
Diffstat (limited to 'src/nvim/digraph.c')
-rw-r--r-- | src/nvim/digraph.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index ae13164191..2066151564 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -15,6 +15,7 @@ #include "nvim/charset.h" #include "nvim/digraph.h" #include "nvim/drawscreen.h" +#include "nvim/eval.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" @@ -2180,3 +2181,42 @@ static void keymap_unload(void) curbuf->b_kmap_state &= ~KEYMAP_LOADED; status_redraw_curbuf(); } + +/// Get the value to show for the language mappings, active 'keymap'. +/// +/// @param fmt format string containing one %s item +/// @param buf buffer for the result +/// @param len length of buffer +bool get_keymap_str(win_T *wp, char *fmt, char *buf, int len) +{ + char *p; + + if (wp->w_buffer->b_p_iminsert != B_IMODE_LMAP) { + return false; + } + + buf_T *old_curbuf = curbuf; + win_T *old_curwin = curwin; + char *s; + + curbuf = wp->w_buffer; + curwin = wp; + STRCPY(buf, "b:keymap_name"); // must be writable + emsg_skip++; + s = p = eval_to_string(buf, NULL, false); + emsg_skip--; + curbuf = old_curbuf; + curwin = old_curwin; + if (p == NULL || *p == NUL) { + if (wp->w_buffer->b_kmap_state & KEYMAP_LOADED) { + p = wp->w_buffer->b_p_keymap; + } else { + p = "lang"; + } + } + if (vim_snprintf(buf, (size_t)len, fmt, p) > len - 1) { + buf[0] = NUL; + } + xfree(s); + return buf[0] != NUL; +} |