aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/digraph.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-03-14 11:49:46 +0100
committerbfredl <bjorn.linse@gmail.com>2023-03-14 13:37:43 +0100
commitd6ecead36406233cc56353dd05f3380f0497630f (patch)
tree6adad28d9a446e422f114d285107595c563760a8 /src/nvim/digraph.c
parentef31444cccdd93f515a8b7a968268cb04e680370 (diff)
downloadrneovim-d6ecead36406233cc56353dd05f3380f0497630f.tar.gz
rneovim-d6ecead36406233cc56353dd05f3380f0497630f.tar.bz2
rneovim-d6ecead36406233cc56353dd05f3380f0497630f.zip
refactor(screen): screen.c delenda est
drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now.
Diffstat (limited to 'src/nvim/digraph.c')
-rw-r--r--src/nvim/digraph.c40
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;
+}