summaryrefslogtreecommitdiff
path: root/math/calctool/files/patch-tty.c
blob: 3ca66993a29fb61540e1202a0f2bb00d677e935b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--- ./tty.c.orig	1990-02-06 05:47:47.000000000 +0100
+++ ./tty.c	2012-08-24 12:55:15.782915559 +0200
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <strings.h>
 #include <signal.h>
+#include <termios.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
@@ -30,7 +31,7 @@
 char *getenv(), *tgetstr(), *tgoto() ;
 int destroy_frame(), outc() ;
 
-struct sgttyb in_new, in_old ;
+struct termios in_new, in_old ;
 
 
 SIGRET
@@ -90,7 +91,7 @@
     }
   do_move(0, 0) ;
   SIGNAL(SIGINT, SIG_IGN) ;
-  IOCTL(0, TIOCSETP, &in_old) ;
+  tcsetattr(0, TCSANOW, &in_old) ;
   exit(0) ;
 }
 
@@ -128,6 +129,7 @@
 }
 
 
+void
 drawline(x1, y1, x2, y2)
 int x1, y1, x2, y2 ;
 {
@@ -315,11 +317,14 @@
 
   SIGNAL(SIGINT, cleanup) ;
 
-  IOCTL(0, TIOCGETP, &in_old) ;        /* Setup standard input. */
+  tcgetattr(0, &in_old) ;	/* Setup standard input. */
   in_new = in_old ;
-  in_new.sg_flags |= RAW ;
-  in_new.sg_flags &= ~(ECHO | CRMOD) ;
-  IOCTL(0, TIOCSETP, &in_new) ;
+  in_new.c_iflag |= IGNBRK;
+  in_new.c_iflag &= ~ICRNL;
+  in_new.c_lflag &= ~(ECHOCTL|ISIG|ICANON|IEXTEN);
+  in_new.c_oflag &= ~ONLCR;
+  in_new.c_lflag &= ~ECHO;
+  tcsetattr(0, TCSANOW, &in_new) ;
 
   setbuf(stdout, (char *) NULL) ;