Browse Source
Measure Windows console size for metrics UI
Co-authored-by: David Mercer <radix42@gmail.com>
pull/4/head
Jack Grigg
6 years ago
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
1 changed files with
10 additions and
0 deletions
-
src/metrics.cpp
|
|
@ -16,7 +16,11 @@ |
|
|
|
#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) { |
|
|
|