Patch 8.1.0940
Problem:    MS-Windows console resizing not handled properly.
Solution:   Handle resizing the console better. (Nobuhiro Takasaki,
            closes #3968, closes #3611)
Files:      src/ex_docmd.c, src/normal.c, src/os_win32.c,
            src/proto/os_win32.pro


*** ../vim-8.1.0939/src/ex_docmd.c      2019-02-08 14:33:54.818762019 +0100
--- src/ex_docmd.c      2019-02-17 14:53:03.973230504 +0100
***************
*** 9853,9858 ****
--- 9853,9861 ----
      if (need_maketitle)
        maketitle();
  #endif
+ #if defined(WIN3264) && !defined(FEAT_GUI_W32)
+     resize_console_buf();
+ #endif
      RedrawingDisabled = r;
      p_lz = p;
  
*** ../vim-8.1.0939/src/normal.c        2019-02-16 15:09:21.209946237 +0100
--- src/normal.c        2019-02-17 14:53:03.973230504 +0100
***************
*** 5401,5406 ****
--- 5401,5409 ----
  # endif
  #endif
        redraw_later(CLEAR);
+ #if defined(WIN3264) && !defined(FEAT_GUI_W32)
+       resize_console_buf();
+ #endif
      }
  }
  
*** ../vim-8.1.0939/src/os_win32.c      2019-02-17 14:10:52.105754303 +0100
--- src/os_win32.c      2019-02-17 15:00:20.974791478 +0100
***************
*** 1492,1497 ****
--- 1492,1499 ----
      ui_focus_change((int)g_fJustGotFocus);
  }
  
+ static void ResizeConBuf(HANDLE hConsole, COORD coordScreen);
+ 
  /*
   * Wait until console input from keyboard or mouse is available,
   * or the time is up.
***************
*** 1657,1667 ****
                handle_focus_event(ir);
            else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT)
            {
!               /* Only call shell_resized() when the size actually change to
!                * avoid the screen is cleard. */
!               if (ir.Event.WindowBufferSizeEvent.dwSize.X != Columns
!                       || ir.Event.WindowBufferSizeEvent.dwSize.Y != Rows)
                    shell_resized();
            }
  #ifdef FEAT_MOUSE
            else if (ir.EventType == MOUSE_EVENT
--- 1659,1676 ----
                handle_focus_event(ir);
            else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT)
            {
!               COORD dwSize = ir.Event.WindowBufferSizeEvent.dwSize;
! 
!               // Only call shell_resized() when the size actually change to
!               // avoid the screen is cleard.
!               if (dwSize.X != Columns || dwSize.Y != Rows)
!               {
!                   CONSOLE_SCREEN_BUFFER_INFO csbi;
!                   GetConsoleScreenBufferInfo(g_hConOut, &csbi);
!                   dwSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
!                   ResizeConBuf(g_hConOut, dwSize);
                    shell_resized();
+               }
            }
  #ifdef FEAT_MOUSE
            else if (ir.EventType == MOUSE_EVENT
***************
*** 6327,6333 ****
             * character was written, otherwise we get stuck. */
            if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length,
                        coord, &cchwritten) == 0
!                   || cchwritten == 0)
                cchwritten = 1;
        }
        else
--- 6336,6342 ----
             * character was written, otherwise we get stuck. */
            if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length,
                        coord, &cchwritten) == 0
!                   || cchwritten == 0 || cchwritten == (DWORD)-1)
                cchwritten = 1;
        }
        else
***************
*** 6361,6367 ****
             * character was written, otherwise we get stuck. */
            if (WriteConsoleOutputCharacter(g_hConOut, (LPCSTR)pchBuf, 
cbToWrite,
                        coord, &written) == 0
!                   || written == 0)
                written = 1;
        }
        else
--- 6370,6376 ----
             * character was written, otherwise we get stuck. */
            if (WriteConsoleOutputCharacter(g_hConOut, (LPCSTR)pchBuf, 
cbToWrite,
                        coord, &written) == 0
!                   || written == 0 || written == (DWORD)-1)
                written = 1;
        }
        else
***************
*** 7707,7713 ****
  
  }
  
! #ifndef FEAT_GUI_W32
  
      static void
  vtp_init(void)
--- 7716,7722 ----
  
  }
  
! #if !defined(FEAT_GUI_W32) || defined(PROTO)
  
      static void
  vtp_init(void)
***************
*** 7931,7933 ****
--- 7940,7967 ----
  {
      return conpty_stable;
  }
+ 
+ #if !defined(FEAT_GUI_W32) || defined(PROTO)
+     void
+ resize_console_buf(void)
+ {
+     CONSOLE_SCREEN_BUFFER_INFO csbi;
+     COORD coord;
+     SMALL_RECT newsize;
+ 
+     if (GetConsoleScreenBufferInfo(g_hConOut, &csbi))
+     {
+       coord.X = SRWIDTH(csbi.srWindow);
+       coord.Y = SRHEIGHT(csbi.srWindow);
+       SetConsoleScreenBufferSize(g_hConOut, coord);
+ 
+       newsize.Left = 0;
+       newsize.Top = 0;
+       newsize.Right = coord.X - 1;
+       newsize.Bottom = coord.Y - 1;
+       SetConsoleWindowInfo(g_hConOut, TRUE, &newsize);
+ 
+       SetConsoleScreenBufferSize(g_hConOut, coord);
+     }
+ }
+ #endif
*** ../vim-8.1.0939/src/proto/os_win32.pro      2019-02-13 19:23:04.734816702 
+0100
--- src/proto/os_win32.pro      2019-02-17 14:53:03.977230484 +0100
***************
*** 75,78 ****
--- 75,79 ----
  int has_vtp_working(void);
  int has_conpty_working(void);
  int is_conpty_stable(void);
+ void resize_console_buf(void);
  /* vim: set ft=c : */
*** ../vim-8.1.0939/src/version.c       2019-02-17 14:50:22.438125825 +0100
--- src/version.c       2019-02-17 14:56:57.147933610 +0100
***************
*** 781,782 ****
--- 781,784 ----
  {   /* Add new patch number below this line */
+ /**/
+     940,
  /**/

-- 
The word "leader" is derived from the word "lead", as in the material that
bullets are made out of.  The term "leader" was popularized at about the same
time as the invention of firearms.  It grew out of the observation that the
person in charge of every organization was the person whom everyone wanted to
fill with hot lead.
   I don't recomment this; it's just a point of historical interest.
                                (Scott Adams - The Dilbert principle)

 /// 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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui