fixed linux implementation and added test

This commit is contained in:
2025-01-29 23:29:15 +00:00
parent a3a392ceaa
commit 81d664f45e
2 changed files with 23 additions and 5 deletions

View File

@@ -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) {