From 0bc14060d26317692d960c39e7e64b74d8963e61 Mon Sep 17 00:00:00 2001 From: hackbard Date: Thu, 6 May 2004 19:16:39 +0000 Subject: [PATCH] canoncial mode fixes --- src/input.c | 16 ++++++---------- src/input.h | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/input.c b/src/input.c index 1403017..30f60b9 100644 --- a/src/input.c +++ b/src/input.c @@ -18,11 +18,14 @@ int input_init(t_input *input) { } input->c_count=0; + tcgetattr(0,&(input->tios)); + tios=input->tios; + if(!(input->mode&LINE_BUFFERED)) { - tcgetattr(0,&tios); - /* switch off canonical mode */ tios.c_lflag&=(~ICANON); tios.c_lflag&=(~ECHO); + tios.c_cc[VTIME]=0; + tios.c_cc[VMIN]=1; tcsetattr(0,TCSANOW,&tios); } @@ -31,15 +34,8 @@ int input_init(t_input *input) { int input_shutdown(t_input *input) { - struct termios tios; - free(input->content); - - tcgetattr(0,&tios); - tios.c_lflag|=ICANON; - tios.c_lflag|=ECHO; - tcsetattr(0,TCSANOW,&tios); - + tcsetattr(0,TCSANOW,&(input->tios)); puts("[input] shutdown"); return I_SUCCESS; diff --git a/src/input.h b/src/input.h index a3d8dd4..b4929fb 100644 --- a/src/input.h +++ b/src/input.h @@ -28,6 +28,7 @@ typedef struct s_input { char *content; int c_count; unsigned char mode; + struct termios tios; } t_input; /* function prototypes */ -- 2.39.2