head 2.5; access; symbols; locks; strict; comment @ * @; 2.5 date 92.12.15.00.20.22; author jromine; state Exp; branches; next 2.4; 2.4 date 92.11.02.22.52.56; author jromine; state Exp; branches; next 2.3; 2.3 date 92.10.16.21.37.46; author jromine; state Exp; branches; next 2.2; 2.2 date 90.04.05.14.57.28; author sources; state Exp; branches; next 2.1; 2.1 date 90.02.05.15.03.14; author sources; state Exp; branches; next 2.0; 2.0 date 89.11.17.15.58.13; author sources; state Exp; branches; next 1.1; 1.1 date 89.11.17.15.44.56; author sources; state Exp; branches; next ; desc @@ 2.5 log @endif sugar @ text @/* trmsbr.c - minor termcap support (load with -ltermlib) */ #ifndef lint static char ident[] = "@@(#)$Id: trmsbr.c,v 2.4 1992/11/02 22:52:56 jromine Exp jromine $"; #endif /* lint */ #include "../h/mh.h" #include #ifndef SYS5 #include #if defined(ULTRIX) && !defined(BSD43) #undef TIOCGWINSZ #endif #else /* SYS5 */ #include #include #ifndef NOIOCTLH #include #endif /* NOIOCTLH */ #undef TIOCGWINSZ #endif /* SYS5 */ #if BUFSIZ<2048 #define TXTSIZ 2048 #else #define TXTSIZ BUFSIZ #endif #ifndef SYS5 extern char PC; extern short ospeed; #else /* SYS5 */ char PC; short ospeed; #endif /* SYS5 */ int tgetent (), tgetnum (); char *tgetstr (); /* */ static int HC = 0; static int initLI = 0; static int LI = 40; static int initCO = 0; static int CO = 80; static char *CL = NULL; static char *SE = NULL; static char *SO = NULL; static char termcap[TXTSIZ]; /* */ static read_termcap () { register char *bp, *term; char *cp, myterm[TXTSIZ]; #ifndef SYS5 struct sgttyb sg; #else /* SYS5 */ struct termio sg; #endif /* SYS5 */ static int inited = 0; if (inited++) return; if ((term = getenv ("TERM")) == NULL || tgetent (myterm, term) <= OK) return; #ifndef SYS5 ospeed = ioctl (fileno (stdout), TIOCGETP, (char *) &sg) != NOTOK ? sg.sg_ospeed : 0; #else /* SYS5 */ ospeed = ioctl (fileno (stdout), TCGETA, &sg) != NOTOK ? sg.c_cflag & CBAUD : 0; #endif /* SYS5 */ HC = tgetflag ("hc"); if (!initCO && (CO = tgetnum ("co")) <= 0) CO = 80; if (!initLI && (LI = tgetnum ("li")) <= 0) LI = 24; cp = termcap; CL = tgetstr ("cl", &cp); if (bp = tgetstr ("pc", &cp)) PC = *bp; if (tgetnum ("sg") <= 0) { SE = tgetstr ("se", &cp); SO = tgetstr ("so", &cp); } } /* */ int sc_width () { #ifdef TIOCGWINSZ struct winsize win; int width; if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK && (width = win.ws_col) > 0) { CO = width; initCO++; } else #endif /* TIOCGWINSZ */ read_termcap (); return CO; } int sc_length () { #ifdef TIOCGWINSZ struct winsize win; if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK && (LI = win.ws_row) > 0) initLI++; else #endif /* TIOCGWINSZ */ read_termcap (); return LI; } /* */ static int outc (c) register char c; { (void) putchar (c); } void clear_screen () { read_termcap (); if (CL && ospeed) tputs (CL, LI, outc); else { printf ("\f"); if (ospeed) printf ("\200"); } (void) fflush (stdout); } /* */ /* VARARGS1 */ int SOprintf (fmt, a, b, c, d, e, f) char *fmt, *a, *b, *c, *d, *e, *f; { read_termcap (); if (SO == NULL || SE == NULL) return NOTOK; tputs (SO, 1, outc); printf (fmt, a, b, c, d, e, f); tputs (SE, 1, outc); return OK; } /* */ int sc_hardcopy () { read_termcap (); return HC; } @ 2.4 log @delete fflush -- it makes output look jumpy @ text @d3 2 a4 2 static char ident[] = "@@(#)$Id: trmsbr.c,v 2.3 1992/10/16 21:37:46 jromine Exp jromine $"; #endif lint d13 1 a13 1 #else SYS5 d18 1 a18 1 #endif NOIOCTLH d20 1 a20 1 #endif SYS5 d32 1 a32 1 #else SYS5 d35 1 a35 1 #endif SYS5 d63 1 a63 1 #else SYS5 d65 1 a65 1 #endif SYS5 d77 1 a77 1 #else SYS5 d80 1 a80 1 #endif SYS5 d111 1 a111 1 #endif TIOCGWINSZ d126 1 a126 1 #endif TIOCGWINSZ @ 2.3 log @add fflush() @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id: trmsbr.c,v 2.2 1990/04/05 14:57:28 sources Exp jromine $"; a174 1 (void) fflush (stdout); @ 2.2 log @add ID @ text @d3 1 a3 1 static char ident[] = "@@(#)$Id:$"; d175 1 @ 2.1 log @*** empty log message *** @ text @d2 3 @ 2.0 log @changes for SUN40 shared libraries and NNTP under bbc @ text @d13 1 d15 1 @ 1.1 log @Initial revision @ text @d14 1 @