diff options
Diffstat (limited to 'lib/libcurses/tty.c')
-rw-r--r-- | lib/libcurses/tty.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/lib/libcurses/tty.c b/lib/libcurses/tty.c index e2693fb..db031d5 100644 --- a/lib/libcurses/tty.c +++ b/lib/libcurses/tty.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1992, 1993 + * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,15 +32,15 @@ */ #ifndef lint -static char sccsid[] = "@(#)tty.c 8.2 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)tty.c 8.6 (Berkeley) 1/10/95"; #endif /* not lint */ -#include <sys/ioctl.h> - -#include <curses.h> +#include <stdlib.h> #include <termios.h> #include <unistd.h> +#include "curses.h" + /* * In general, curses should leave tty hardware settings alone (speed, parity, * word size). This is most easily done in BSD by using TCSASOFT on all @@ -126,7 +126,7 @@ raw() useraw = __pfast = __rawmode = 1; curt = &rawt; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -135,7 +135,7 @@ noraw() useraw = __pfast = __rawmode = 0; curt = &__baset; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -145,7 +145,7 @@ cbreak() __rawmode = 1; curt = useraw ? &rawt : &cbreakt; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -155,7 +155,7 @@ nocbreak() __rawmode = 0; curt = useraw ? &rawt : &__baset; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -167,7 +167,7 @@ echo() __echoit = 1; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -179,7 +179,7 @@ noecho() __echoit = 0; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -194,7 +194,7 @@ nl() __pfast = __rawmode; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } int @@ -209,14 +209,31 @@ nonl() __pfast = 1; return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, curt)); + TCSASOFT | TCSADRAIN : TCSADRAIN, curt) ? ERR : OK); } void __startwin() { + static char *stdbuf; + static size_t len; + (void)fflush(stdout); - (void)setvbuf(stdout, NULL, _IOFBF, 0); + + /* + * Some C libraries default to a 1K buffer when talking to a tty. + * With a larger screen, especially across a network, we'd like + * to get it to all flush in a single write. Make it twice as big + * as just the characters (so that we have room for cursor motions + * and standout information) but no more than 8K. + */ + if (stdbuf == NULL) { + if ((len = LINES * COLS * 2) > 8192) + len = 8192; + if ((stdbuf = malloc(len)) == NULL) + len = 0; + } + (void)setvbuf(stdout, stdbuf, _IOFBF, len); tputs(TI, 0, __cputchar); tputs(VS, 0, __cputchar); @@ -232,7 +249,7 @@ endwin() tputs(SE, 0, __cputchar); curscr->flags &= ~__WSTANDOUT; } - __mvcur(curscr->cury, curscr->cury, curscr->maxy - 1, 0, 0); + __mvcur(curscr->cury, curscr->curx, curscr->maxy - 1, 0, 0); } (void)tputs(VE, 0, __cputchar); @@ -241,7 +258,7 @@ endwin() (void)setvbuf(stdout, NULL, _IOLBF, 0); return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios)); + TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios) ? ERR : OK); } /* @@ -253,12 +270,12 @@ static struct termios savedtty; int savetty() { - return (tcgetattr(STDIN_FILENO, &savedtty)); + return (tcgetattr(STDIN_FILENO, &savedtty) ? ERR : OK); } int resetty() { return (tcsetattr(STDIN_FILENO, __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, &savedtty)); + TCSASOFT | TCSADRAIN : TCSADRAIN, &savedtty) ? ERR : OK); } |