42-archive/42sh/src/line-editing/init_termcaps.c
2017-03-07 17:37:32 +01:00

41 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init_termcaps.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:33:41 by gwojda #+# #+# */
/* Updated: 2017/03/07 17:36:38 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
struct termios *ft_save_termios(int save)
{
static struct termios *term_save = NULL;
if (save < 0)
{
free(term_save);
return (NULL);
}
if (save > 0)
{
term_save = (struct termios *)malloc(sizeof(struct termios));
tcgetattr(0, term_save);
}
return (term_save);
}
void ft_init_termios(void)
{
struct termios term;
tcgetattr(0, &term);
term.c_lflag &= ~(ECHO | ICANON | ISIG);
term.c_cc[VMIN] = 1;
term.c_cc[VTIME] = 0;
tcsetattr(0, TCSANOW, &term);
}