added term_get_current_size()
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
// if windows is defined.
|
||||
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
struct tart_vec2 term_current_size() {
|
||||
struct tart_vec2 ret;
|
||||
@@ -20,3 +21,24 @@ struct tart_vec2 term_current_size() {
|
||||
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
#include <sys/ioctl.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 short max_short = 0XFFFF;
|
||||
if(rows < max_short && cols < max_short) {
|
||||
|
||||
ret = (struct tart_vec2){(unsigned short) rows ,(unsigned short) cols};
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user