From 9eb259ab93a96e34d4233f3e94235cc96ef6cc26 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 16 Apr 1994 08:14:50 +0000 Subject: [PATCH] Added TERMIOS support. --- usr.bin/more/Makefile | 4 +-- usr.bin/more/screen.c | 58 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/usr.bin/more/Makefile b/usr.bin/more/Makefile index b78552e08788..1f7e341e854c 100644 --- a/usr.bin/more/Makefile +++ b/usr.bin/more/Makefile @@ -1,8 +1,8 @@ # from: @(#)Makefile 5.6 (Berkeley) 3/12/91 -# $Id: Makefile,v 1.5 1993/11/11 01:30:28 jtc Exp $ +# $Id: Makefile,v 1.6 1994/04/16 08:14:50 andrew Exp $ PROG= more -CFLAGS+=-I${.CURDIR} -DREGEX +CFLAGS+=-I${.CURDIR} -DREGEX -DTERMIOS SRCS= ch.c command.c decode.c filename.c help.c input.c line.c \ linenum.c main.c option.c os.c output.c position.c prim.c \ screen.c signal.c tags.c ttyin.c diff --git a/usr.bin/more/screen.c b/usr.bin/more/screen.c index 6e2ed490d187..e1ee4abd64bd 100644 --- a/usr.bin/more/screen.c +++ b/usr.bin/more/screen.c @@ -34,7 +34,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)screen.c 5.8 (Berkeley) 6/28/92"; */ -static char *rcsid = "$Id: screen.c,v 1.2 1993/11/09 05:13:02 cgd Exp $"; +static char *rcsid = "$Id: screen.c,v 1.3 1994/04/16 08:14:52 andrew Exp $"; #endif /* not lint */ /* @@ -47,11 +47,15 @@ static char *rcsid = "$Id: screen.c,v 1.2 1993/11/09 05:13:02 cgd Exp $"; #include #include -#if TERMIO +#ifdef TERMIOS +#include +#else +#ifdef TERMIO #include #else #include #endif +#endif #ifdef TIOCGWINSZ #include @@ -103,7 +107,11 @@ int so_width, se_width; /* Printing width of standout sequences */ * and needed by, the termcap library. * It may be necessary on some systems to declare them extern here. */ +#ifdef TERMIOS +/*extern*/ speed_t ospeed; /* Terminal output baud rate */ +#else /*extern*/ short ospeed; /* Terminal output baud rate */ +#endif /*extern*/ char PC; /* Pad character */ extern int back_scroll; @@ -124,7 +132,50 @@ char *tgoto(); raw_mode(on) int on; { -#if TERMIO +#ifdef TERMIOS + struct termios s; + static struct termios save_term; + + if (on) + { + /* + * Get terminal modes. + */ + (void)tcgetattr(2, &s); + + /* + * Save modes and set certain variables dependent on modes. + */ + save_term = s; + ospeed = cfgetospeed(&s); + erase_char = s.c_cc[VERASE]; + kill_char = s.c_cc[VKILL]; + werase_char = s.c_cc[VWERASE]; + + /* + * Set the modes to the way we want them. + */ + s.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL); + s.c_oflag |= (OPOST|ONLCR +#ifdef TAB3 + |TAB3 +#endif + ); +#ifdef OCRNL + s.c_oflag &= ~(OCRNL|ONLRET|ONOCR); +#endif + s.c_cc[VMIN] = 1; + s.c_cc[VTIME] = 0; + } else + { + /* + * Restore saved modes. + */ + s = save_term; + } + (void)tcsetattr(2, TCSADRAIN, &s); +#else +#ifdef TERMIO struct termio s; static struct termio save_term; @@ -196,6 +247,7 @@ raw_mode(on) } (void)ioctl(2, TIOCSETN, &s); #endif +#endif } /*