0
0
mirror of https://github.com/vim/vim.git synced 2025-10-05 05:34:07 -04:00

patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI

Problem:    MS-Windows: feedkeys() with VIMDLL cannot handle CSI correctly.
Solution:   Modify mch_inchar() to encode CSI bytes. (Ozaki Kiichi, Ken
            Takata, closes #5726)
This commit is contained in:
Bram Moolenaar
2020-03-04 23:21:35 +01:00
parent a471eeae75
commit 8f027fe470
4 changed files with 49 additions and 31 deletions

View File

@@ -1782,7 +1782,13 @@ mch_inchar(
int len;
int c;
# define TYPEAHEADLEN 20
# ifdef VIMDLL
// Extra space for maximum three CSIs. E.g. U+1B6DB -> 0xF0 0x9B 0x9B 0x9B.
# define TYPEAHEADSPACE 6
# else
# define TYPEAHEADSPACE 0
# endif
# define TYPEAHEADLEN (20 + TYPEAHEADSPACE)
static char_u typeahead[TYPEAHEADLEN]; // previously typed bytes.
static int typeaheadlen = 0;
@@ -1838,7 +1844,7 @@ mch_inchar(
// to get and still room in the buffer (up to two bytes for a char and
// three bytes for a modifier).
while ((typeaheadlen == 0 || WaitForChar(0L, FALSE))
&& typeaheadlen + 5 <= TYPEAHEADLEN)
&& typeaheadlen + 5 + TYPEAHEADSPACE <= TYPEAHEADLEN)
{
if (typebuf_changed(tb_change_cnt))
{
@@ -1890,7 +1896,7 @@ mch_inchar(
if (ch2 == NUL)
{
int i;
int i, j;
char_u *p;
WCHAR ch[2];
@@ -1903,13 +1909,33 @@ mch_inchar(
p = utf16_to_enc(ch, &n);
if (p != NULL)
{
for (i = 0; i < n; i++)
typeahead[typeaheadlen + i] = p[i];
for (i = 0, j = 0; i < n; i++)
{
typeahead[typeaheadlen + j++] = p[i];
# ifdef VIMDLL
if (p[i] == CSI)
{
typeahead[typeaheadlen + j++] = KS_EXTRA;
typeahead[typeaheadlen + j++] = KE_CSI;
}
# endif
}
n = j;
vim_free(p);
}
}
else
{
typeahead[typeaheadlen] = c;
# ifdef VIMDLL
if (c == CSI)
{
typeahead[typeaheadlen + 1] = KS_EXTRA;
typeahead[typeaheadlen + 2] = KE_CSI;
n = 3;
}
# endif
}
if (ch2 != NUL)
{
if (c == K_NUL)