Win32: Fix for mangled output on the terminal on exit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/main.c b/main.c
index 0c7b844..7a9d64a 100644
--- a/main.c
+++ b/main.c
@@ -993,13 +993,31 @@ static void workio_cmd_free(struct workio_cmd *wc)
static void disable_curses(void)
{
if (test_and_clear(&curses_active)) {
+#ifdef WIN32
+ leaveok(logwin, false);
+ leaveok(statuswin, false);
+ leaveok(mainwin, false);
+#endif
nocbreak();
echo();
delwin(logwin);
delwin(statuswin);
delwin(mainwin);
endwin();
- refresh();
+ refresh();
+
+#ifdef WIN32
+ // Move the cursor to after curses output.
+ HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ COORD coord;
+
+ if (GetConsoleScreenBufferInfo(hout, &csbi)) {
+ coord.X = 0;
+ coord.Y = csbi.dwSize.Y - 1;
+ SetConsoleCursorPosition(hout, coord);
+ }
+#endif
}
}