d4640890cf
* Unfreeze the console while changing the buffer size. Changing the buffer size hangs conhost.exe. See: - https://github.com/rprichard/winpty/issues/31 - https://wpdev.uservoice.com/forums/266908-command-prompt/suggestions/9941292-conhost-exe-hangs-in-win10-if-setconsolescreenbuff * Detect buffer size changes and switch to a "direct mode". Direct mode makes no attempt to track incremental console changes. Instead, the content of the current console window is printed. This mode is intended for full-screen apps that resize the console. * Reopen CONOUT$, which detects apps that change the active screen buffer. Fixes https://github.com/rprichard/winpty/issues/34. * In the scroll scraping (scrollingScrapeOutput), consider a line changed if the new content is truncated relative to the content previously output. Previously, we only compared against the line-buffer up to the current console width. e.g. If this: |C:\Program| turns into: |C:\Prog| |ram | we previously left |C:\Program| in the line-buffer for the first line and did not re-output the first line. We *should* reoutput the first line at this point so that, if the line scrolls upward, and the terminal is later expanded, we will have output an "Erase in Line" CSI command to clear the obscured "ram" text. We need to update the line-buffer for the sake of Windows 10 combined with terminals like xterm and putty. On such a terminal, if the terminal later widened, Windows 10 will restore the console to the first state. At that point, we need to reoutput the line, because xterm and putty do not save and restore truncated line content extending past the current terminal width.
92 lines
2.3 KiB
C++
Executable File
92 lines
2.3 KiB
C++
Executable File
#include <windows.h>
|
|
#include <cassert>
|
|
|
|
#include "../shared/DebugClient.cc"
|
|
#include "TestUtil.cc"
|
|
|
|
void dumpInfoToTrace() {
|
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
|
assert(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info));
|
|
trace("win=(%d,%d,%d,%d)",
|
|
(int)info.srWindow.Left,
|
|
(int)info.srWindow.Top,
|
|
(int)info.srWindow.Right,
|
|
(int)info.srWindow.Bottom);
|
|
trace("buf=(%d,%d)",
|
|
(int)info.dwSize.X,
|
|
(int)info.dwSize.Y);
|
|
trace("cur=(%d,%d)",
|
|
(int)info.dwCursorPosition.X,
|
|
(int)info.dwCursorPosition.Y);
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
if (argc == 1) {
|
|
startChildProcess(L"CHILD");
|
|
return 0;
|
|
}
|
|
|
|
setWindowPos(0, 0, 1, 1);
|
|
|
|
if (false) {
|
|
// Reducing the buffer height can move the window up.
|
|
setBufferSize(80, 25);
|
|
setWindowPos(0, 20, 80, 5);
|
|
Sleep(2000);
|
|
setBufferSize(80, 10);
|
|
}
|
|
|
|
if (false) {
|
|
// Reducing the buffer height moves the window up and the buffer
|
|
// contents up too.
|
|
setBufferSize(80, 25);
|
|
setWindowPos(0, 20, 80, 5);
|
|
setCursorPos(0, 20);
|
|
printf("TEST1\nTEST2\nTEST3\nTEST4\n");
|
|
fflush(stdout);
|
|
Sleep(2000);
|
|
setBufferSize(80, 10);
|
|
}
|
|
|
|
if (false) {
|
|
// Reducing the buffer width can move the window left.
|
|
setBufferSize(80, 25);
|
|
setWindowPos(40, 0, 40, 25);
|
|
Sleep(2000);
|
|
setBufferSize(60, 25);
|
|
}
|
|
|
|
if (false) {
|
|
// Sometimes the buffer contents are shifted up; sometimes they're
|
|
// shifted down. It seems to depend on the cursor position?
|
|
|
|
// setBufferSize(80, 25);
|
|
// setWindowPos(0, 20, 80, 5);
|
|
// setCursorPos(0, 20);
|
|
// printf("TESTa\nTESTb\nTESTc\nTESTd\nTESTe");
|
|
// fflush(stdout);
|
|
// setCursorPos(0, 0);
|
|
// printf("TEST1\nTEST2\nTEST3\nTEST4\nTEST5");
|
|
// fflush(stdout);
|
|
// setCursorPos(0, 24);
|
|
// Sleep(5000);
|
|
// setBufferSize(80, 24);
|
|
|
|
setBufferSize(80, 20);
|
|
setWindowPos(0, 10, 80, 10);
|
|
setCursorPos(0, 18);
|
|
|
|
printf("TEST1\nTEST2");
|
|
fflush(stdout);
|
|
setCursorPos(0, 18);
|
|
|
|
Sleep(2000);
|
|
setBufferSize(80, 18);
|
|
}
|
|
|
|
dumpInfoToTrace();
|
|
Sleep(30000);
|
|
|
|
return 0;
|
|
}
|