]> Git Repo - VerusCoin.git/commitdiff
Measure Windows console size for metrics UI
authorJack Grigg <[email protected]>
Sat, 14 Apr 2018 05:17:52 +0000 (23:17 -0600)
committerJack Grigg <[email protected]>
Fri, 17 Aug 2018 15:43:43 +0000 (16:43 +0100)
Co-authored-by: David Mercer <[email protected]>
src/metrics.cpp

index 23f005a3e5f8557cb405925df22ed8e995897702..6f238e94760b638c0eafc0a33d220d0f5c708751 100644 (file)
 #include <boost/thread.hpp>
 #include <boost/thread/synchronized_value.hpp>
 #include <string>
+#ifdef WIN32
+#include <io.h>
+#else
 #include <sys/ioctl.h>
+#endif
 #include <unistd.h>
 
 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) {
This page took 0.023606 seconds and 4 git commands to generate.