]>
diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/uip/trmsbr.c
1 /* trmsbr.c - minor termcap support (load with -ltermlib) */
3 static char ident
[] = "@(#)$Id: trmsbr.c,v 2.5 1992/12/15 00:20:22 jromine Exp $";
10 #if defined(ULTRIX) && !defined(BSD43)
14 #include <sys/types.h>
17 #include <sys/ioctl.h>
37 int tgetent (), tgetnum ();
44 static int initLI
= 0;
46 static int initCO
= 0;
48 static char *CL
= NULL
;
49 static char *SE
= NULL
;
50 static char *SO
= NULL
;
52 static char termcap
[TXTSIZ
];
56 static read_termcap () {
66 static int inited
= 0;
71 if ((term
= getenv ("TERM")) == NULL
|| tgetent (myterm
, term
) <= OK
)
75 ospeed
= ioctl (fileno (stdout
), TIOCGETP
, (char *) &sg
) != NOTOK
78 ospeed
= ioctl (fileno (stdout
), TCGETA
, &sg
) != NOTOK
79 ? sg
.c_cflag
& CBAUD
: 0;
84 if (!initCO
&& (CO
= tgetnum ("co")) <= 0)
86 if (!initLI
&& (LI
= tgetnum ("li")) <= 0)
90 CL
= tgetstr ("cl", &cp
);
91 if (bp
= tgetstr ("pc", &cp
))
93 if (tgetnum ("sg") <= 0) {
94 SE
= tgetstr ("se", &cp
);
95 SO
= tgetstr ("so", &cp
);
106 if (ioctl (fileno (stderr
), TIOCGWINSZ
, &win
) != NOTOK
107 && (width
= win
.ws_col
) > 0) {
111 #endif /* TIOCGWINSZ */
122 if (ioctl (fileno (stderr
), TIOCGWINSZ
, &win
) != NOTOK
123 && (LI
= win
.ws_row
) > 0)
126 #endif /* TIOCGWINSZ */
141 void clear_screen () {
145 tputs (CL
, LI
, outc
);
152 (void) fflush (stdout
);
159 int SOprintf (fmt
, a
, b
, c
, d
, e
, f
)
169 if (SO
== NULL
|| SE
== NULL
)
173 printf (fmt
, a
, b
, c
, d
, e
, f
);