More Windows tweaks

This commit is contained in:
Marcus Holland-Moritz 2023-06-22 12:47:13 +02:00
parent e2cd0b641f
commit eec62aa620

View File

@ -39,9 +39,13 @@
#include <utility>
#include <vector>
#ifdef _WIN32
#include <folly/portability/Windows.h>
#else
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
@ -191,10 +195,17 @@ int parse_order_option(std::string const& ordname, std::string const& opt,
return 0;
}
// TODO: move elsewhere
size_t get_term_width() {
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
return csbi.srWindow.Right - csbi.srWindow.Left + 1;
#else
struct ::winsize w;
::ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
return w.ws_col;
#endif
}
struct level_defaults {