canoncial mode fixes
authorhackbard <hackbard>
Thu, 6 May 2004 19:16:39 +0000 (19:16 +0000)
committerhackbard <hackbard>
Thu, 6 May 2004 19:16:39 +0000 (19:16 +0000)
src/input.c
src/input.h

index 1403017..30f60b9 100644 (file)
@@ -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;
index a3d8dd4..b4929fb 100644 (file)
@@ -28,6 +28,7 @@ typedef struct s_input {
   char *content;
   int c_count;
   unsigned char mode;
+  struct termios tios;
 } t_input;
 
 /* function prototypes */