mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
2f4146d469
This fixes the hideous output when your terminal would be too small to hold all the threads.
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#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
|