From 877089972b094824890dc241ad8b11b0ed433408 Mon Sep 17 00:00:00 2001 From: Dustin Boyd Date: Fri, 15 Feb 2019 18:20:04 -0600 Subject: [PATCH] Minor bugs fixed in clear_console functions - Windows: cursor returns to top-left of console screen buffer - Non-Windows: isatty(stdout) check to prevent CLS from working when stdout is redirected --- internal/c/libqb.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 413f7b1e3..94210896b 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -11217,7 +11217,8 @@ static bool clear_console(void) return false; ret = (GetConsoleScreenBufferInfo(hConsole, &csbi) && FillConsoleOutputCharacterA(console, ' ', - csbi.dwSize.X * csbi.dwSize.Y, origin, &nCharsWritten)); + csbi.dwSize.X * csbi.dwSize.Y, origin, &nCharsWritten) && + SetConsoleCursorPosition(hConsole, origin)); CloseHandle(console); return ret; } @@ -11240,6 +11241,8 @@ static int putc_tty(int c) static bool clear_console(void) { int err; + if (!isatty(fileno(stdout))) + return false; ttyfd = open("/dev/tty", O_RDWR); if (ttyfd == -1) { // No controlling TTY for the process?