Files
Tart/testing/test_term.cpp

49 lines
1.3 KiB
C++

#if defined(_WIN64) || defined(_WIN32)
#include <Windows.h>
#else
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#endif
#include <iostream>
#include "test_term.h"
void term_run(struct pickle_shelf* shelf) {
struct pickle_shelf __pickle_shelf__ = *shelf; //start
CREATEJAR(Test_Term);
PICKLE(Test_get_window_size) {
#if defined(_WIN64) || defined(_WIN32)
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
int columns = (unsigned int)(csbi.srWindow.Right - csbi.srWindow.Left + 1);
int rows = (unsigned int)(csbi.srWindow.Bottom - csbi.srWindow.Top + 1);
#else
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
unsigned int rows = w.ws_row;
unsigned int columns = w.ws_col;
#endif
std::cout << "\n";
std::cout << term_current_size().x << "term_current_size()\n";
std::cout << columns << " columns\n";
if(term_current_size().x != columns)
ASSERT("current_size.x is not the same as columns", false);
if(term_current_size().y != rows)
ASSERT("current_size.y is not the same as rows", false);
ASSERT("GOOD", true);
}();
ADDPICKLE(Test_Term, Test_get_window_size);
PUTJARONSHELF(Test_Term);
*shelf = __pickle_shelf__; // end
}