Patch 8.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)
Files:      src/getchar.c, src/os_win32.c, src/testdir/test_popupwin.vim


*** ../vim-8.2.0355/src/getchar.c       2020-02-18 21:32:55.854340478 +0100
--- src/getchar.c       2020-03-04 23:18:26.897701301 +0100
***************
*** 1623,1629 ****
            // Get two extra bytes for special keys
            if (c == K_SPECIAL
  #ifdef FEAT_GUI
!                   || (gui.in_use && c == CSI)
  #endif
               )
            {
--- 1623,1629 ----
            // Get two extra bytes for special keys
            if (c == K_SPECIAL
  #ifdef FEAT_GUI
!                   || (c == CSI)
  #endif
               )
            {
***************
*** 1678,1700 ****
                }
  #endif
  #ifdef FEAT_GUI
!               if (gui.in_use)
                {
!                   // Handle focus event here, so that the caller doesn't
!                   // need to know about it.  Return K_IGNORE so that we loop
!                   // once (needed if 'lazyredraw' is set).
!                   if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
!                   {
!                       ui_focus_change(c == K_FOCUSGAINED);
!                       c = K_IGNORE;
!                   }
! 
!                   // Translate K_CSI to CSI.  The special key is only used
!                   // to avoid it being recognized as the start of a special
!                   // key.
!                   if (c == K_CSI)
!                       c = CSI;
                }
  #endif
            }
            // a keypad or special function key was not mapped, use it like
--- 1678,1696 ----
                }
  #endif
  #ifdef FEAT_GUI
!               // Handle focus event here, so that the caller doesn't need to
!               // know about it.  Return K_IGNORE so that we loop once (needed
!               // if 'lazyredraw' is set).
!               if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
                {
!                   ui_focus_change(c == K_FOCUSGAINED);
!                   c = K_IGNORE;
                }
+ 
+               // Translate K_CSI to CSI.  The special key is only used to
+               // avoid it being recognized as the start of a special key.
+               if (c == K_CSI)
+                   c = CSI;
  #endif
            }
            // a keypad or special function key was not mapped, use it like
***************
*** 1772,1782 ****
                    buf[i] = vgetorpeek(TRUE);
                    if (buf[i] == K_SPECIAL
  #ifdef FEAT_GUI
!                           || (
! # ifdef VIMDLL
!                               gui.in_use &&
! # endif
!                               buf[i] == CSI)
  #endif
                            )
                    {
--- 1768,1774 ----
                    buf[i] = vgetorpeek(TRUE);
                    if (buf[i] == K_SPECIAL
  #ifdef FEAT_GUI
!                           || (buf[i] == CSI)
  #endif
                            )
                    {
*** ../vim-8.2.0355/src/os_win32.c      2020-02-15 23:06:40.822770278 +0100
--- src/os_win32.c      2020-03-04 23:18:26.897701301 +0100
***************
*** 1782,1788 ****
  
      int               len;
      int               c;
! # define TYPEAHEADLEN 20
      static char_u   typeahead[TYPEAHEADLEN];  // previously typed bytes.
      static int            typeaheadlen = 0;
  
--- 1782,1794 ----
  
      int               len;
      int               c;
! # 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,1844 ****
      // 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)
      {
        if (typebuf_changed(tb_change_cnt))
        {
--- 1844,1850 ----
      // 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 + TYPEAHEADSPACE <= TYPEAHEADLEN)
      {
        if (typebuf_changed(tb_change_cnt))
        {
***************
*** 1890,1896 ****
  
                if (ch2 == NUL)
                {
!                   int     i;
                    char_u  *p;
                    WCHAR   ch[2];
  
--- 1896,1902 ----
  
                if (ch2 == NUL)
                {
!                   int     i, j;
                    char_u  *p;
                    WCHAR   ch[2];
  
***************
*** 1903,1915 ****
                    p = utf16_to_enc(ch, &n);
                    if (p != NULL)
                    {
!                       for (i = 0; i < n; i++)
!                           typeahead[typeaheadlen + i] = p[i];
                        vim_free(p);
                    }
                }
                else
                    typeahead[typeaheadlen] = c;
                if (ch2 != NUL)
                {
                    if (c == K_NUL)
--- 1909,1941 ----
                    p = utf16_to_enc(ch, &n);
                    if (p != NULL)
                    {
!                       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)
*** ../vim-8.2.0355/src/testdir/test_popupwin.vim       2020-02-28 
22:44:43.493320733 +0100
--- src/testdir/test_popupwin.vim       2020-03-04 23:18:26.897701301 +0100
***************
*** 3284,3294 ****
    call feedkeys("\u3000", 'xt')
    call assert_equal([0xe3, 0x80, 0x80], g:bytes)
  
!   if has('gui')
!     " UTF-8: E3 80 9B, including CSI(0x9B)
!     call feedkeys("\u301b", 'xt')
!     call assert_equal([0xe3, 0x80, 0x9b], g:bytes)
!   endif
  
    call popup_clear()
    delfunc MyPopupFilter
--- 3284,3292 ----
    call feedkeys("\u3000", 'xt')
    call assert_equal([0xe3, 0x80, 0x80], g:bytes)
  
!   " UTF-8: E3 80 9B, including CSI(0x9B)
!   call feedkeys("\u301b", 'xt')
!   call assert_equal([0xe3, 0x80, 0x9b], g:bytes)
  
    call popup_clear()
    delfunc MyPopupFilter
*** ../vim-8.2.0355/src/version.c       2020-03-04 22:20:23.366900841 +0100
--- src/version.c       2020-03-04 23:20:40.629253990 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     356,
  /**/

-- 
If Apple would build a car...
... it would be powered by the sun, be reliable, five times
as fast and twice as easy to drive; but would only run on
five percent of the roads.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202003042222.024MM71s020879%40masaka.moolenaar.net.

Raspunde prin e-mail lui