aboutsummaryrefslogtreecommitdiff
path: root/client/term_linux.c
blob: cdab99d6b41eddffbda5f7473cdaf01675c51195 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifdef W2_HOST_LINUX

#include <fcntl.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>

#include "term.h"
#include "ui.h"

void w2_term_raw_mode() {
	fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
	struct termios term;
	tcgetattr(STDIN_FILENO, &term);
	term.c_lflag &= ~(ECHO | ICANON);
	term.c_cc[VTIME] = 0;
	term.c_cc[VMIN]	 = 1;
	tcsetattr(STDIN_FILENO, 0, &term);
}

void w2_term_props() {
	struct winsize window;
	ioctl(STDOUT_FILENO, TIOCGWINSZ, &window);

	g_w2_ui_canvas.width  = window.ws_col;
	g_w2_ui_canvas.height = window.ws_row;
}

#endif