diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index 34a8f115..b4df9de0 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ -/* Updated: 2017/01/10 17:06:23 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 17:07:29 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/rl_set_termios.c b/42sh/src/line-editing/rl_set_termios.c new file mode 100644 index 00000000..3aacb524 --- /dev/null +++ b/42sh/src/line-editing/rl_set_termios.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* rl_set_termios.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/10 17:00:16 by jhalford #+# #+# */ +/* Updated: 2017/01/10 17:02:50 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int rl_set_termios(int input_mode) +{ + struct termios term; + + if (tcgetattr(0, &term) == -1) + { + DG("tcgetattr failed, errno=%i", errno); + return (-1); + } + if (input_mode) + term.c_lflag &= ~(ICANON) & ~(ISIG) & ~(ECHO); + else + term.c_lflag |= ICANON | ISIG | ECHO; + term.c_cc[VMIN] = 1; + term.c_cc[VTIME] = 0; + if (tcsetattr(0, TCSADRAIN, &term) == -1) + return (-1); + return (0); +}