added set_termios
This commit is contained in:
parent
8b414aac13
commit
7adffb7a60
2 changed files with 34 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 14:58:36 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
33
42sh/src/line-editing/rl_set_termios.c
Normal file
33
42sh/src/line-editing/rl_set_termios.c
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* rl_set_termios.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue