Mercurial > vim
comparison src/os_win32.c @ 15866:6ddcd10aa7af v8.1.0940
patch 8.1.0940: MS-Windows console resizing not handled properly
commit https://github.com/vim/vim/commit/78d21dae9c3a39efb30316d3e38dce120bc1abbd
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 17 15:00:52 2019 +0100
patch 8.1.0940: MS-Windows console resizing not handled properly
Problem: MS-Windows console resizing not handled properly.
Solution: Handle resizing the console better. (Nobuhiro Takasaki,
closes #3968, closes #3611)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 17 Feb 2019 15:15:06 +0100 |
parents | 2ab6321fd355 |
children | 7fad90423bd2 |
comparison
equal
deleted
inserted
replaced
15865:bf72955a2d0f | 15866:6ddcd10aa7af |
---|---|
1490 { | 1490 { |
1491 g_fJustGotFocus = ir.Event.FocusEvent.bSetFocus; | 1491 g_fJustGotFocus = ir.Event.FocusEvent.bSetFocus; |
1492 ui_focus_change((int)g_fJustGotFocus); | 1492 ui_focus_change((int)g_fJustGotFocus); |
1493 } | 1493 } |
1494 | 1494 |
1495 static void ResizeConBuf(HANDLE hConsole, COORD coordScreen); | |
1496 | |
1495 /* | 1497 /* |
1496 * Wait until console input from keyboard or mouse is available, | 1498 * Wait until console input from keyboard or mouse is available, |
1497 * or the time is up. | 1499 * or the time is up. |
1498 * When "ignore_input" is TRUE even wait when input is available. | 1500 * When "ignore_input" is TRUE even wait when input is available. |
1499 * Return TRUE if something is available FALSE if not. | 1501 * Return TRUE if something is available FALSE if not. |
1655 | 1657 |
1656 if (ir.EventType == FOCUS_EVENT) | 1658 if (ir.EventType == FOCUS_EVENT) |
1657 handle_focus_event(ir); | 1659 handle_focus_event(ir); |
1658 else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT) | 1660 else if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT) |
1659 { | 1661 { |
1660 /* Only call shell_resized() when the size actually change to | 1662 COORD dwSize = ir.Event.WindowBufferSizeEvent.dwSize; |
1661 * avoid the screen is cleard. */ | 1663 |
1662 if (ir.Event.WindowBufferSizeEvent.dwSize.X != Columns | 1664 // Only call shell_resized() when the size actually change to |
1663 || ir.Event.WindowBufferSizeEvent.dwSize.Y != Rows) | 1665 // avoid the screen is cleard. |
1666 if (dwSize.X != Columns || dwSize.Y != Rows) | |
1667 { | |
1668 CONSOLE_SCREEN_BUFFER_INFO csbi; | |
1669 GetConsoleScreenBufferInfo(g_hConOut, &csbi); | |
1670 dwSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; | |
1671 ResizeConBuf(g_hConOut, dwSize); | |
1664 shell_resized(); | 1672 shell_resized(); |
1673 } | |
1665 } | 1674 } |
1666 #ifdef FEAT_MOUSE | 1675 #ifdef FEAT_MOUSE |
1667 else if (ir.EventType == MOUSE_EVENT | 1676 else if (ir.EventType == MOUSE_EVENT |
1668 && decode_mouse_event(&ir.Event.MouseEvent)) | 1677 && decode_mouse_event(&ir.Event.MouseEvent)) |
1669 return TRUE; | 1678 return TRUE; |
6325 coord, &written); | 6334 coord, &written); |
6326 /* When writing fails or didn't write a single character, pretend one | 6335 /* When writing fails or didn't write a single character, pretend one |
6327 * character was written, otherwise we get stuck. */ | 6336 * character was written, otherwise we get stuck. */ |
6328 if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length, | 6337 if (WriteConsoleOutputCharacterW(g_hConOut, unicodebuf, length, |
6329 coord, &cchwritten) == 0 | 6338 coord, &cchwritten) == 0 |
6330 || cchwritten == 0) | 6339 || cchwritten == 0 || cchwritten == (DWORD)-1) |
6331 cchwritten = 1; | 6340 cchwritten = 1; |
6332 } | 6341 } |
6333 else | 6342 else |
6334 { | 6343 { |
6335 if (WriteConsoleW(g_hConOut, unicodebuf, length, &cchwritten, | 6344 if (WriteConsoleW(g_hConOut, unicodebuf, length, &cchwritten, |
6359 coord, &written); | 6368 coord, &written); |
6360 /* When writing fails or didn't write a single character, pretend one | 6369 /* When writing fails or didn't write a single character, pretend one |
6361 * character was written, otherwise we get stuck. */ | 6370 * character was written, otherwise we get stuck. */ |
6362 if (WriteConsoleOutputCharacter(g_hConOut, (LPCSTR)pchBuf, cbToWrite, | 6371 if (WriteConsoleOutputCharacter(g_hConOut, (LPCSTR)pchBuf, cbToWrite, |
6363 coord, &written) == 0 | 6372 coord, &written) == 0 |
6364 || written == 0) | 6373 || written == 0 || written == (DWORD)-1) |
6365 written = 1; | 6374 written = 1; |
6366 } | 6375 } |
6367 else | 6376 else |
6368 { | 6377 { |
6369 if (WriteConsole(g_hConOut, (LPCSTR)pchBuf, cbToWrite, &written, | 6378 if (WriteConsole(g_hConOut, (LPCSTR)pchBuf, cbToWrite, &written, |
7705 if (ver >= CONPTY_STABLE_BUILD) | 7714 if (ver >= CONPTY_STABLE_BUILD) |
7706 conpty_stable = 1; | 7715 conpty_stable = 1; |
7707 | 7716 |
7708 } | 7717 } |
7709 | 7718 |
7710 #ifndef FEAT_GUI_W32 | 7719 #if !defined(FEAT_GUI_W32) || defined(PROTO) |
7711 | 7720 |
7712 static void | 7721 static void |
7713 vtp_init(void) | 7722 vtp_init(void) |
7714 { | 7723 { |
7715 HMODULE hKerneldll; | 7724 HMODULE hKerneldll; |
7929 int | 7938 int |
7930 is_conpty_stable(void) | 7939 is_conpty_stable(void) |
7931 { | 7940 { |
7932 return conpty_stable; | 7941 return conpty_stable; |
7933 } | 7942 } |
7943 | |
7944 #if !defined(FEAT_GUI_W32) || defined(PROTO) | |
7945 void | |
7946 resize_console_buf(void) | |
7947 { | |
7948 CONSOLE_SCREEN_BUFFER_INFO csbi; | |
7949 COORD coord; | |
7950 SMALL_RECT newsize; | |
7951 | |
7952 if (GetConsoleScreenBufferInfo(g_hConOut, &csbi)) | |
7953 { | |
7954 coord.X = SRWIDTH(csbi.srWindow); | |
7955 coord.Y = SRHEIGHT(csbi.srWindow); | |
7956 SetConsoleScreenBufferSize(g_hConOut, coord); | |
7957 | |
7958 newsize.Left = 0; | |
7959 newsize.Top = 0; | |
7960 newsize.Right = coord.X - 1; | |
7961 newsize.Bottom = coord.Y - 1; | |
7962 SetConsoleWindowInfo(g_hConOut, TRUE, &newsize); | |
7963 | |
7964 SetConsoleScreenBufferSize(g_hConOut, coord); | |
7965 } | |
7966 } | |
7967 #endif |