summaryrefslogtreecommitdiff
path: root/src/os_win32.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-04 23:21:35 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-04 23:21:35 +0100
commit8f027fe470555252b258508c455e93700a969cb1 (patch)
tree073ea9753872a8345c43a07e77b7c52c4e618259 /src/os_win32.c
parenta471eeae75cda982bb6ddffbb0cbb71d868b97bf (diff)
downloadvim-git-8f027fe470555252b258508c455e93700a969cb1.tar.gz
patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSIv8.2.0356
Problem: MS-Windows: feedkeys() with VIMDLL cannot handle CSI correctly. Solution: Modify mch_inchar() to encode CSI bytes. (Ozaki Kiichi, Ken Takata, closes #5726)
Diffstat (limited to 'src/os_win32.c')
-rw-r--r--src/os_win32.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index df63fb7f3..e9d22e417 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -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)