mirror of
https://github.com/open-goal/jak-project
synced 2026-08-21 23:00:45 -04:00
tests: make the offline tests aware of the current terminals row count (#2105)
This fixes the hideous output when your terminal would be too small to hold all the threads.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include "term_util.h"
|
||||
|
||||
#if defined _WIN32
|
||||
#define NOMINMAX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#elif defined(__LINUX__) || defined(__gnu_linux__) || defined(__linux__) || defined(__APPLE__)
|
||||
#include <cstdlib>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
namespace term_util {
|
||||
void clear() {
|
||||
#if defined _WIN32
|
||||
system("cls");
|
||||
#elif defined(__LINUX__) || defined(__gnu_linux__) || defined(__linux__) || defined(__APPLE__)
|
||||
system("clear");
|
||||
#endif
|
||||
}
|
||||
|
||||
int row_count() {
|
||||
#if defined _WIN32
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
||||
return csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
|
||||
#elif defined(__LINUX__) || defined(__gnu_linux__) || defined(__linux__) || defined(__APPLE__)
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
return w.ws_row;
|
||||
#endif
|
||||
}
|
||||
|
||||
int col_count() {
|
||||
#if defined _WIN32
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
||||
return csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
||||
#elif defined(__LINUX__) || defined(__gnu_linux__) || defined(__linux__) || defined(__APPLE__)
|
||||
struct winsize w;
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
return w.ws_col;
|
||||
#endif
|
||||
}
|
||||
} // namespace term_util
|
||||
Reference in New Issue
Block a user