diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-08-07 20:47:16 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-08-07 20:47:16 +0200 |
commit | b1cf16113f7ab67f42fb6822cecdef74a54fa950 (patch) | |
tree | bb9daa2aa32845dd3db1a29edfb7498cf9ec9141 /src/os_win32.c | |
parent | 7ebf4e1c346783b25624258e5bcc599130fd18f9 (diff) | |
download | vim-git-b1cf16113f7ab67f42fb6822cecdef74a54fa950.tar.gz |
patch 8.1.0250: MS-Windows using VTP: windows size change incorrectv8.1.0250
Problem: MS-Windows using VTP: windows size change incorrect.
Solution: Call SetConsoleScreenBufferSize() first. (Nobuhiro Takasaki,
closes #3164)
Diffstat (limited to 'src/os_win32.c')
-rw-r--r-- | src/os_win32.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index f8884e401..63572350b 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -3967,6 +3967,48 @@ mch_get_shellsize(void) } /* + * Resize console buffer to 'COORD' + */ + static void +ResizeConBuf( + HANDLE hConsole, + COORD coordScreen) +{ + if (!SetConsoleScreenBufferSize(hConsole, coordScreen)) + { +#ifdef MCH_WRITE_DUMP + if (fdDump) + { + fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n", + GetLastError()); + fflush(fdDump); + } +#endif + } +} + +/* + * Resize console window size to 'srWindowRect' + */ + static void +ResizeWindow( + HANDLE hConsole, + SMALL_RECT srWindowRect) +{ + if (!SetConsoleWindowInfo(hConsole, TRUE, &srWindowRect)) + { +#ifdef MCH_WRITE_DUMP + if (fdDump) + { + fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n", + GetLastError()); + fflush(fdDump); + } +#endif + } +} + +/* * Set a console window to `xSize' * `ySize' */ static void @@ -4019,32 +4061,20 @@ ResizeConBufAndWindow( } } - if (!SetConsoleWindowInfo(g_hConOut, TRUE, &srWindowRect)) - { -#ifdef MCH_WRITE_DUMP - if (fdDump) - { - fprintf(fdDump, "SetConsoleWindowInfo failed: %lx\n", - GetLastError()); - fflush(fdDump); - } -#endif - } - - /* define the new console buffer size */ + // define the new console buffer size coordScreen.X = xSize; coordScreen.Y = ySize; - if (!SetConsoleScreenBufferSize(hConsole, coordScreen)) + // In the new console call API in reverse order + if (!vtp_working) { -#ifdef MCH_WRITE_DUMP - if (fdDump) - { - fprintf(fdDump, "SetConsoleScreenBufferSize failed: %lx\n", - GetLastError()); - fflush(fdDump); - } -#endif + ResizeWindow(hConsole, srWindowRect); + ResizeConBuf(hConsole, coordScreen); + } + else + { + ResizeConBuf(hConsole, coordScreen); + ResizeWindow(hConsole, srWindowRect); } } |