fixed linux implementation and added test
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
#include "term.h"
|
||||
#include "../includes/tart.h"
|
||||
|
||||
|
||||
// if windows is defined.
|
||||
|
||||
@@ -23,16 +21,19 @@ struct tart_vec2 term_current_size() {
|
||||
}
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
struct tart_vec2 term_current_size() {
|
||||
struct tart_vec2 ret;
|
||||
|
||||
unsigned int rows = w.ws_row;
|
||||
unsigned int cols = w.ws_col;
|
||||
|
||||
struct winsize w;
|
||||
|
||||
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||
|
||||
unsigned int rows = w.ws_col;
|
||||
unsigned int cols = w.ws_row;
|
||||
|
||||
unsigned short max_short = 0XFFFF;
|
||||
if(rows < max_short && cols < max_short) {
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
|
||||
#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) {
|
||||
@@ -8,11 +15,21 @@ void term_run(struct pickle_shelf* shelf) {
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user