summaryrefslogtreecommitdiffstats
path: root/src/misc.c
blob: 91d1266e35a54e70a0c3e38b3c3faa6c3d0b8c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

#include <termios.h>
#include <unistd.h>

int set_term(int set_init)
{
	struct termios new_settings;
	static struct termios init_settings;

	if (set_init)
		return tcsetattr(0, TCSANOW, &init_settings);

	tcgetattr(0, &init_settings);
	new_settings = init_settings;
	new_settings.c_lflag &= ~ICANON;
	new_settings.c_lflag &= ~ECHO;

	return tcsetattr(0, TCSANOW, &new_settings);
}