comparison src/os_win32.c @ 19599:5eb0ead1415f v8.2.0356

patch 8.2.0356: MS-Windows: feedkeys() with VIMDLL cannot handle CSI Commit: https://github.com/vim/vim/commit/8f027fe470555252b258508c455e93700a969cb1 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 4 23:21:35 2020 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Mar 2020 23:30:04 +0100
parents 08f4dc2ba716
children 25836c21ccf9
comparison
equal deleted inserted replaced
19598:e5054307d4bb 19599:5eb0ead1415f
1780 { 1780 {
1781 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL) 1781 #if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
1782 1782
1783 int len; 1783 int len;
1784 int c; 1784 int c;
1785 # define TYPEAHEADLEN 20 1785 # ifdef VIMDLL
1786 // Extra space for maximum three CSIs. E.g. U+1B6DB -> 0xF0 0x9B 0x9B 0x9B.
1787 # define TYPEAHEADSPACE 6
1788 # else
1789 # define TYPEAHEADSPACE 0
1790 # endif
1791 # define TYPEAHEADLEN (20 + TYPEAHEADSPACE)
1786 static char_u typeahead[TYPEAHEADLEN]; // previously typed bytes. 1792 static char_u typeahead[TYPEAHEADLEN]; // previously typed bytes.
1787 static int typeaheadlen = 0; 1793 static int typeaheadlen = 0;
1788 1794
1789 # ifdef VIMDLL 1795 # ifdef VIMDLL
1790 if (gui.in_use) 1796 if (gui.in_use)
1836 1842
1837 // Keep looping until there is something in the typeahead buffer and more 1843 // Keep looping until there is something in the typeahead buffer and more
1838 // to get and still room in the buffer (up to two bytes for a char and 1844 // to get and still room in the buffer (up to two bytes for a char and
1839 // three bytes for a modifier). 1845 // three bytes for a modifier).
1840 while ((typeaheadlen == 0 || WaitForChar(0L, FALSE)) 1846 while ((typeaheadlen == 0 || WaitForChar(0L, FALSE))
1841 && typeaheadlen + 5 <= TYPEAHEADLEN) 1847 && typeaheadlen + 5 + TYPEAHEADSPACE <= TYPEAHEADLEN)
1842 { 1848 {
1843 if (typebuf_changed(tb_change_cnt)) 1849 if (typebuf_changed(tb_change_cnt))
1844 { 1850 {
1845 // "buf" may be invalid now if a client put something in the 1851 // "buf" may be invalid now if a client put something in the
1846 // typeahead buffer and "buf" is in the typeahead buffer. 1852 // typeahead buffer and "buf" is in the typeahead buffer.
1888 { 1894 {
1889 int n = 1; 1895 int n = 1;
1890 1896
1891 if (ch2 == NUL) 1897 if (ch2 == NUL)
1892 { 1898 {
1893 int i; 1899 int i, j;
1894 char_u *p; 1900 char_u *p;
1895 WCHAR ch[2]; 1901 WCHAR ch[2];
1896 1902
1897 ch[0] = c; 1903 ch[0] = c;
1898 if (c >= 0xD800 && c <= 0xDBFF) // High surrogate 1904 if (c >= 0xD800 && c <= 0xDBFF) // High surrogate
1901 n++; 1907 n++;
1902 } 1908 }
1903 p = utf16_to_enc(ch, &n); 1909 p = utf16_to_enc(ch, &n);
1904 if (p != NULL) 1910 if (p != NULL)
1905 { 1911 {
1906 for (i = 0; i < n; i++) 1912 for (i = 0, j = 0; i < n; i++)
1907 typeahead[typeaheadlen + i] = p[i]; 1913 {
1914 typeahead[typeaheadlen + j++] = p[i];
1915 # ifdef VIMDLL
1916 if (p[i] == CSI)
1917 {
1918 typeahead[typeaheadlen + j++] = KS_EXTRA;
1919 typeahead[typeaheadlen + j++] = KE_CSI;
1920 }
1921 # endif
1922 }
1923 n = j;
1908 vim_free(p); 1924 vim_free(p);
1909 } 1925 }
1910 } 1926 }
1911 else 1927 else
1928 {
1912 typeahead[typeaheadlen] = c; 1929 typeahead[typeaheadlen] = c;
1930 # ifdef VIMDLL
1931 if (c == CSI)
1932 {
1933 typeahead[typeaheadlen + 1] = KS_EXTRA;
1934 typeahead[typeaheadlen + 2] = KE_CSI;
1935 n = 3;
1936 }
1937 # endif
1938 }
1913 if (ch2 != NUL) 1939 if (ch2 != NUL)
1914 { 1940 {
1915 if (c == K_NUL) 1941 if (c == K_NUL)
1916 { 1942 {
1917 switch (ch2) 1943 switch (ch2)