summaryrefslogtreecommitdiff
path: root/usr.bin/mg/ttyio.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-02-27 17:24:13 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-02-27 17:24:13 +0000
commit18a040bd4a1b0c4af47664286b5603c755ce7569 (patch)
tree154dfc63708a4ae426786b5585c5a76debdf2b2c /usr.bin/mg/ttyio.c
parentc78789fa4ec8214c53515e6421628fe79c419d8d (diff)
Better setting of terminal 'raw' mode, cribbed from BSD curses.
We no longer try to put the terminal into 8bit, no parity mode and instead use the TCSASOFT flag to tcsetattr() as per the discussion of this in lib/libocurses/tty.c.
Diffstat (limited to 'usr.bin/mg/ttyio.c')
-rw-r--r--usr.bin/mg/ttyio.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index 2360b8410ef..5870d6cb901 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -47,19 +47,18 @@ ttopen()
if (tcgetattr(0, &ot) < 0)
abort();
nt = ot; /* save entry state */
- nt.c_cc[VMIN] = 1; /* one character read is OK */
- nt.c_cc[VTIME] = 0; /* Never time out. */
+ /* Set terminal to 'raw' mode and ignore a 'break' */
+ nt.c_cc[VMIN] = 1;
+ nt.c_cc[VTIME] = 0;
nt.c_iflag |= IGNBRK;
- nt.c_iflag &= ~( ICRNL | INLCR | ISTRIP | IXON | IXOFF );
+ nt.c_iflag &= ~(BRKINT|PARMRK|INLCR|IGNCR|ICRNL|IXON);
nt.c_oflag &= ~OPOST;
- nt.c_cflag |= CS8; /* allow 8th bit on input */
- nt.c_cflag &= ~PARENB; /* Don't check parity */
- nt.c_lflag &= ~( ECHO | ICANON | ISIG );
+ nt.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
ttysavedp = TRUE;
}
- if (tcsetattr(0, TCSAFLUSH, &nt) < 0)
+ if (tcsetattr(0, TCSASOFT | TCSADRAIN, &nt) < 0)
abort();
ttyactivep = TRUE;
@@ -75,7 +74,7 @@ ttclose()
if(!ttysavedp || !ttyactivep)
return;
ttflush();
- if (tcsetattr(0, TCSAFLUSH, &ot) < 0)
+ if (tcsetattr(0, TCSASOFT | TCSADRAIN, &ot) < 0)
abort();
ttyactivep = FALSE;
}