From ceca40d68f5908e6c2179da5760a9a5d77ca2fb0 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 13 Apr 2018 23:17:52 -0600 Subject: [PATCH] Measure Windows console size for metrics UI Co-authored-by: David Mercer --- src/metrics.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/metrics.cpp b/src/metrics.cpp index 23f005a3e..6f238e947 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -16,7 +16,11 @@ #include #include #include +#ifdef WIN32 +#include +#else #include +#endif #include void AtomicTimer::start() @@ -444,11 +448,17 @@ void ThreadShowMetricsScreen() // Get current window size if (isTTY) { +#ifdef WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); + cols = csbi.srWindow.Right - csbi.srWindow.Left + 1; +#else struct winsize w; w.ws_col = 0; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1 && w.ws_col != 0) { cols = w.ws_col; } +#endif } if (isScreen) {