diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-17 21:28:54 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-17 21:28:54 +0200 |
commit | acdfb8a97995e0f81832207e39564ba795281108 (patch) | |
tree | 43ac60dc7ab26bc680c9949af1dfca66a73731e5 /src/normal.c | |
parent | ae7e61c928b4adaa220e59ecebc75ef630674207 (diff) |
patch 9.1.0343: 'showcmd' wrong for partial mapping with multibytev9.1.0343
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>
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/normal.c b/src/normal.c index cfe60eec32..fef282647f 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1708,6 +1708,7 @@ add_to_showcmd(int c) int extra_len; int overflow; int i; + char_u mbyte_buf[MB_MAXBYTES]; static int ignore[] = { #ifdef FEAT_GUI @@ -1739,9 +1740,17 @@ add_to_showcmd(int c) 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 @@ pop_showcmd(void) static void display_showcmd(void) { - int len = (int)STRLEN(showcmd_buf); + int len = vim_strsize(showcmd_buf); showcmd_is_clear = (len == 0); cursor_off(); |