patch 9.1.0343: 'showcmd' wrong for partial mapping with multibyte
Problem: 'showcmd' is wrong for partial mapping with multibyte char,
and isn't very readable with modifyOtherKeys.
Solution: Decode multibyte char and merge modifiers into the char.
(zeertzjq)
This improves the following situations:
- Multibyte chars whose individual bytes are considered unprintable are
now shown properly in 'showcmd' area.
- Ctrl-W with modifyOtherKeys now shows ^W in 'showcmd' area.
The following situation may still need improvement:
- If the char is a special key or has modifiers that cannot be merged
into it, internal keycodes are shown in 'showcmd' area like before.
This applies to keys typed in Normal mode commands as well, and it's
hard to decide how to make it more readable due to the limited space
taken by 'showcmd', so I'll leave it for later.
closes: #14572
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/normal.c b/src/normal.c
index cfe60ee..fef2826 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1708,6 +1708,7 @@
int extra_len;
int overflow;
int i;
+ char_u mbyte_buf[MB_MAXBYTES];
static int ignore[] =
{
#ifdef FEAT_GUI
@@ -1739,9 +1740,17 @@
if (ignore[i] == c)
return FALSE;
- p = transchar(c);
- if (*p == ' ')
- STRCPY(p, "<20>");
+ if (c <= 0x7f || !vim_isprintc(c))
+ {
+ p = transchar(c);
+ if (*p == ' ')
+ STRCPY(p, "<20>");
+ }
+ else
+ {
+ mbyte_buf[(*mb_char2bytes)(c, mbyte_buf)] = NUL;
+ p = mbyte_buf;
+ }
old_len = (int)STRLEN(showcmd_buf);
extra_len = (int)STRLEN(p);
overflow = old_len + extra_len - SHOWCMD_COLS;
@@ -1810,7 +1819,7 @@
static void
display_showcmd(void)
{
- int len = (int)STRLEN(showcmd_buf);
+ int len = vim_strsize(showcmd_buf);
showcmd_is_clear = (len == 0);
cursor_off();