]> granicus.if.org Git - vim/commitdiff
patch 8.1.0940: MS-Windows console resizing not handled properly v8.1.0940
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Feb 2019 14:00:52 +0000 (15:00 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Feb 2019 14:00:52 +0000 (15:00 +0100)
Problem:    MS-Windows console resizing not handled properly.
Solution:   Handle resizing the console better. (Nobuhiro Takasaki,
            closes #3968, closes #3611)

src/ex_docmd.c
src/normal.c
src/os_win32.c
src/proto/os_win32.pro
src/version.c

index ccca2f98fa31eee8226378a8e5860cce311ab433..8cdb046747920a9c860b83af40b981ce9f6301e0 100644 (file)
@@ -9852,6 +9852,9 @@ ex_redraw(exarg_T *eap)
 #ifdef FEAT_TITLE
     if (need_maketitle)
        maketitle();
+#endif
+#if defined(WIN3264) && !defined(FEAT_GUI_W32)
+    resize_console_buf();
 #endif
     RedrawingDisabled = r;
     p_lz = p;
index 624e34751cfbcd9a7a6ef0c3c8522b91d77e174d..ca0d8ff87664f3b02ca4726e065fc23838424546 100644 (file)
@@ -5401,6 +5401,9 @@ nv_clear(cmdarg_T *cap)
 # endif
 #endif
        redraw_later(CLEAR);
+#if defined(WIN3264) && !defined(FEAT_GUI_W32)
+       resize_console_buf();
+#endif
     }
 }
 
index 97fc2a401b5e281f75e27f12d043a01118ba1d8b..a392d13b27a7e3444c237a0a6f09ea89a892b8ac 100644 (file)
@@ -1492,6 +1492,8 @@ handle_focus_event(INPUT_RECORD ir)
     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,11 +1659,18 @@ WaitForChar(long msec, int ignore_input)
                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)
+               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,7 +6336,7 @@ write_chars(
             * character was written, otherwise we get stuck. */
            if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length,
                        coord, &cchwritten) == 0
-                   || cchwritten == 0)
+                   || cchwritten == 0 || cchwritten == (DWORD)-1)
                cchwritten = 1;
        }
        else
@@ -6361,7 +6370,7 @@ write_chars(
             * character was written, otherwise we get stuck. */
            if (WriteConsoleOutputCharacter(g_hConOut, (LPCSTR)pchBuf, cbToWrite,
                        coord, &written) == 0
-                   || written == 0)
+                   || written == 0 || written == (DWORD)-1)
                written = 1;
        }
        else
@@ -7707,7 +7716,7 @@ vtp_flag_init(void)
 
 }
 
-#ifndef FEAT_GUI_W32
+#if !defined(FEAT_GUI_W32) || defined(PROTO)
 
     static void
 vtp_init(void)
@@ -7931,3 +7940,28 @@ is_conpty_stable(void)
 {
     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
index 6157e011fdc2d42fea4882ed2d0d37b29ee79c69..ca5bad629c7b11974bceaf5308b0917b1a237c94 100644 (file)
@@ -75,4 +75,5 @@ int is_term_win32(void);
 int has_vtp_working(void);
 int has_conpty_working(void);
 int is_conpty_stable(void);
+void resize_console_buf(void);
 /* vim: set ft=c : */
index 06500bd7906b3ae4b31b65de08131f8e02a9a8bb..e042578cca3e98c013a70a8524b29b0b9592b3e5 100644 (file)
@@ -779,6 +779,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    940,
 /**/
     939,
 /**/