From a80798e281ad1d69e94c43b4183a78475ace0d7d Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Thu, 7 Jul 2022 21:29:38 +0200 Subject: [PATCH] improved Windows command line output --- src/common/main.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/common/main.cxx b/src/common/main.cxx index a4f2dc60c..1354801f7 100644 --- a/src/common/main.cxx +++ b/src/common/main.cxx @@ -161,6 +161,20 @@ void attachConsole() AttachConsole(ATTACH_PARENT_PROCESS); FILE* fDummy; freopen_s(&fDummy, "CONOUT$", "w", stdout); + + // Windows displays a new prompt immediately after starting the app. + // This code tries to hide it before the new output is generated. + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_SCREEN_BUFFER_INFO csbi; + if(GetConsoleScreenBufferInfo(hConsole, &csbi)) + { + COORD pos = {0, csbi.dwCursorPosition.Y}; + SetConsoleCursorPosition(hConsole, pos); + cout << std::setw(160) << ""; // this clears the extra prompt display + SetConsoleCursorPosition(hConsole, pos); + } + else + cout << endl << endl; #endif } @@ -168,7 +182,7 @@ void attachConsole() void freeConsole() { #if defined(BSPF_WINDOWS) - cout << "Press \"Control + C\"" << std::flush; + cout << "Press \"Enter\"" << endl << std::flush; FreeConsole(); #endif }