-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterm.c
49 lines (44 loc) · 1.65 KB
/
term.c
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* term.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ctreton <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/05 10:07:37 by ctreton #+# #+# */
/* Updated: 2014/01/10 20:04:17 by ctreton ### ########.fr */
/* */
/* ************************************************************************** */
#include "select.h"
void init_term(void)
{
t_elem *e;
char *name;
e = g_all.c.start;
name = getenv("TERM");
if (name == NULL)
print_error(1);
tgetent(NULL, name);
tcgetattr(0, &(g_all.term));
start_term();
}
void start_term(void)
{
g_all.term.c_lflag &= ~(ICANON | ECHO);
g_all.term.c_lflag |= (ISIG);
g_all.term.c_cc[VMIN] = 1;
g_all.term.c_cc[VTIME] = 0;
tcsetattr(0, TCSADRAIN, &(g_all.term));
tputs(tgetstr("ti", NULL), 1, ft_tputs);
tputs(tgetstr("vi", NULL), 1, ft_tputs);
}
void close_term(void)
{
tputs(tgetstr("cl", NULL), 1, ft_tputs);
tputs(tgetstr("te", NULL), 1, ft_tputs);
tputs(tgetstr("ve", NULL), 1, ft_tputs);
g_all.term.c_lflag |= (ICANON | ECHO | ISIG);
g_all.term.c_cc[VMIN] = 1;
g_all.term.c_cc[VTIME] = 0;
tcsetattr(0, TCSADRAIN, &(g_all.term));
}