-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathother_functions.c
40 lines (36 loc) · 1.52 KB
/
other_functions.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* other_functions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aulamber <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/05/04 20:18:57 by aulamber #+# #+# */
/* Updated: 2014/05/04 20:54:30 by aulamber ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <termios.h>
#include <termcap.h>
#include "ft_select.h"
void restore_term(t_env *envir)
{
tputs(tgetstr("ve", NULL), ENT, tputs_putchar);
tputs(tgetstr("te", NULL), ENT, tputs_putchar);
tcsetattr(0, TCSANOW, &envir->act);
}
int init_shell(t_env *envir)
{
char buffer[2048];
if (tgetent(buffer, "linux") < 1)
return (-1);
if (tcgetattr(1, &envir->act) != 0)
return (-1);
envir->act.c_lflag &= ~(ECHO | ICANON);
envir->act.c_cc[VMIN] = 1;
envir->act.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &envir->act);
tputs(tgetstr("ti", NULL), ENT, tputs_putchar);
tputs(tgetstr("vi", NULL), ENT, tputs_putchar);
return (0);
}