ul.c revision 50477
11590Srgrimes/*
21590Srgrimes * Copyright (c) 1980, 1993
31590Srgrimes *	The Regents of the University of California.  All rights reserved.
41590Srgrimes *
51590Srgrimes * Redistribution and use in source and binary forms, with or without
61590Srgrimes * modification, are permitted provided that the following conditions
71590Srgrimes * are met:
81590Srgrimes * 1. Redistributions of source code must retain the above copyright
91590Srgrimes *    notice, this list of conditions and the following disclaimer.
101590Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111590Srgrimes *    notice, this list of conditions and the following disclaimer in the
121590Srgrimes *    documentation and/or other materials provided with the distribution.
131590Srgrimes * 3. All advertising materials mentioning features or use of this software
141590Srgrimes *    must display the following acknowledgement:
151590Srgrimes *	This product includes software developed by the University of
161590Srgrimes *	California, Berkeley and its contributors.
171590Srgrimes * 4. Neither the name of the University nor the names of its contributors
181590Srgrimes *    may be used to endorse or promote products derived from this software
191590Srgrimes *    without specific prior written permission.
201590Srgrimes *
211590Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221590Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231590Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241590Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251590Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261590Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271590Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281590Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291590Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301590Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311590Srgrimes * SUCH DAMAGE.
321590Srgrimes */
331590Srgrimes
341590Srgrimes#ifndef lint
351590Srgrimesstatic const char copyright[] =
361590Srgrimes"@(#) Copyright (c) 1980, 1993\n\
3762833Swsanchez	The Regents of the University of California.  All rights reserved.\n";
3862833Swsanchez#endif /* not lint */
391590Srgrimes
401590Srgrimes#ifndef lint
4162833Swsanchez#if 0
4294587Sobrienstatic char sccsid[] = "@(#)ul.c	8.1 (Berkeley) 6/6/93";
431590Srgrimes#endif
441590Srgrimesstatic const char rcsid[] =
451590Srgrimes  "$FreeBSD: head/usr.bin/ul/ul.c 50477 1999-08-28 01:08:13Z peter $";
461590Srgrimes#endif /* not lint */
471590Srgrimes
481590Srgrimes#include <err.h>
491590Srgrimes#include <stdio.h>
501590Srgrimes#include <stdlib.h>
511590Srgrimes#include <string.h>
521590Srgrimes#include <termcap.h>
531590Srgrimes#include <unistd.h>
541590Srgrimes
551590Srgrimes#define	IESC	'\033'
561590Srgrimes#define	SO	'\016'
571590Srgrimes#define	SI	'\017'
581590Srgrimes#define	HFWD	'9'
591590Srgrimes#define	HREV	'8'
601590Srgrimes#define	FREV	'7'
611590Srgrimes#define	MAXBUF	512
621590Srgrimes
631590Srgrimes#define	NORMAL	000
641590Srgrimes#define	ALTSET	001	/* Reverse */
651590Srgrimes#define	SUPERSC	002	/* Dim */
661590Srgrimes#define	SUBSC	004	/* Dim | Ul */
671590Srgrimes#define	UNDERL	010	/* Ul */
681590Srgrimes#define	BOLD	020	/* Bold */
691590Srgrimes
701590Srgrimesint	must_use_uc, must_overstrike;
711590Srgrimeschar	*CURS_UP, *CURS_RIGHT, *CURS_LEFT,
7249938Shoek	*ENTER_STANDOUT, *EXIT_STANDOUT, *ENTER_UNDERLINE, *EXIT_UNDERLINE,
731590Srgrimes	*ENTER_DIM, *ENTER_BOLD, *ENTER_REVERSE, *UNDER_CHAR, *EXIT_ATTRIBUTES;
741590Srgrimes
751590Srgrimesstruct	CHAR	{
761590Srgrimes	char	c_mode;
771590Srgrimes	char	c_char;
781590Srgrimes} ;
791590Srgrimes
801590Srgrimesstruct	CHAR	obuf[MAXBUF];
811590Srgrimesint	col, maxcol;
821590Srgrimesint	mode;
831590Srgrimesint	halfpos;
841590Srgrimesint	upln;
851590Srgrimesint	iflag;
861590Srgrimes
871590Srgrimesstatic void usage __P((void));
881590Srgrimesvoid setnewmode __P((int));
891590Srgrimesvoid initcap __P((void));
9092921Simpvoid reverse __P((void));
9192921Simpint outchar __P((int));
9292921Simpvoid fwd __P((void));
9392921Simpvoid initbuf __P((void));
9492921Simpvoid iattr __P((void));
9592921Simpvoid overstrike __P((void));
96138232Shartivoid flushln __P((void));
971590Srgrimesvoid filter __P((FILE *));
981590Srgrimesvoid outc __P((int));
991590Srgrimes
1001590Srgrimes#define	PRINT(s)	if (s == NULL) /* void */; else tputs(s, 1, outchar)
1018874Srgrimes
1021590Srgrimesint
1031590Srgrimesmain(argc, argv)
1048874Srgrimes	int argc;
1051590Srgrimes	char **argv;
1061590Srgrimes{
1071590Srgrimes	int c;
1081590Srgrimes	char *termtype;
1091590Srgrimes	FILE *f;
1101590Srgrimes	char termcap[1024];
1111590Srgrimes
112138232Sharti	termtype = getenv("TERM");
1131590Srgrimes	if (termtype == NULL || (argv[0][0] == 'c' && !isatty(1)))
114138232Sharti		termtype = "lpr";
1151590Srgrimes	while ((c=getopt(argc, argv, "it:T:")) != -1)
1161590Srgrimes		switch(c) {
1171590Srgrimes
1181590Srgrimes		case 't':
1191590Srgrimes		case 'T': /* for nroff compatibility */
1205814Sjkh				termtype = optarg;
1215814Sjkh			break;
122138232Sharti		case 'i':
1235814Sjkh			iflag = 1;
124138232Sharti			break;
125138232Sharti		default:
1265814Sjkh			usage();
127138232Sharti		}
1281590Srgrimes
1291590Srgrimes	switch(tgetent(termcap, termtype)) {
1301590Srgrimes
1311590Srgrimes	case 1:
1321590Srgrimes		break;
1331590Srgrimes
1341590Srgrimes	default:
1351590Srgrimes		warnx("trouble reading termcap");
1361590Srgrimes		/* fall through to ... */
1371590Srgrimes
1381590Srgrimes	case 0:
1398874Srgrimes		/* No such terminal type - assume dumb */
1401590Srgrimes		(void)strcpy(termcap, "dumb:os:col#80:cr=^M:sf=^J:am:");
1411590Srgrimes		break;
1421590Srgrimes	}
1431590Srgrimes	initcap();
1441590Srgrimes	if (    (tgetflag("os") && ENTER_BOLD==NULL ) ||
1451590Srgrimes		(tgetflag("ul") && ENTER_UNDERLINE==NULL && UNDER_CHAR==NULL))
1461590Srgrimes			must_overstrike = 1;
147138232Sharti	initbuf();
1481590Srgrimes	if (optind == argc)
1491590Srgrimes		filter(stdin);
1501590Srgrimes	else for (; optind<argc; optind++) {
1511590Srgrimes		f = fopen(argv[optind],"r");
1521590Srgrimes		if (f == NULL)
1531590Srgrimes			err(1, "%s", argv[optind]);
1541590Srgrimes		else
155138232Sharti			filter(f);
156138232Sharti	}
157103508Sjmallett	exit(0);
158103545Sjmallett}
159103508Sjmallett
160103545Sjmallettstatic void
1611590Srgrimesusage()
1621590Srgrimes{
1631590Srgrimes	fprintf(stderr, "usage: ul [-i] [-t terminal] file...\n");
1641590Srgrimes	exit(1);
1651590Srgrimes}
1661590Srgrimes
1671590Srgrimesvoid
1681590Srgrimesfilter(f)
1691590Srgrimes	FILE *f;
1701590Srgrimes{
1711590Srgrimes	register c;
1721590Srgrimes
1731590Srgrimes	while ((c = getc(f)) != EOF) switch(c) {
1741590Srgrimes
1751590Srgrimes	case '\b':
1761590Srgrimes		if (col > 0)
1771590Srgrimes			col--;
1781590Srgrimes		continue;
1791590Srgrimes
1801590Srgrimes	case '\t':
1811590Srgrimes		col = (col+8) & ~07;
1821590Srgrimes		if (col > maxcol)
183103545Sjmallett			maxcol = col;
1841590Srgrimes		continue;
1851590Srgrimes
186103545Sjmallett	case '\r':
1875814Sjkh		col = 0;
1885814Sjkh		continue;
1895814Sjkh
1905814Sjkh	case SO:
1915814Sjkh		mode |= ALTSET;
192138232Sharti		continue;
1935814Sjkh
1941590Srgrimes	case SI:
1951590Srgrimes		mode &= ~ALTSET;
1961590Srgrimes		continue;
1971590Srgrimes
1981590Srgrimes	case IESC:
199103545Sjmallett		switch (c = getc(f)) {
2001590Srgrimes
20118730Ssteve		case HREV:
2021590Srgrimes			if (halfpos == 0) {
2031590Srgrimes				mode |= SUPERSC;
2041590Srgrimes				halfpos--;
2051590Srgrimes			} else if (halfpos > 0) {
206103508Sjmallett				mode &= ~SUBSC;
207103545Sjmallett				halfpos--;
208103508Sjmallett			} else {
209103545Sjmallett				halfpos = 0;
210103508Sjmallett				reverse();
211103545Sjmallett			}
2121590Srgrimes			continue;
2131590Srgrimes
2141590Srgrimes		case HFWD:
2151590Srgrimes			if (halfpos == 0) {
2161590Srgrimes				mode |= SUBSC;
2171590Srgrimes				halfpos++;
2181590Srgrimes			} else if (halfpos < 0) {
2191590Srgrimes				mode &= ~SUPERSC;
2201590Srgrimes				halfpos++;
2211590Srgrimes			} else {
2221590Srgrimes				halfpos = 0;
2231590Srgrimes				fwd();
2241590Srgrimes			}
225103508Sjmallett			continue;
226103545Sjmallett
227103508Sjmallett		case FREV:
228103545Sjmallett			reverse();
229103508Sjmallett			continue;
230103545Sjmallett
2311590Srgrimes		default:
2321590Srgrimes			errx(1, "unknown escape sequence in input: %o, %o", IESC, c);
233104375Sjmallett		}
2341590Srgrimes		continue;
2351590Srgrimes
2361590Srgrimes	case '_':
2371590Srgrimes		if (obuf[col].c_char)
2381590Srgrimes			obuf[col].c_mode |= UNDERL | mode;
2391590Srgrimes		else
2401590Srgrimes			obuf[col].c_char = '_';
2411590Srgrimes	case ' ':
2421590Srgrimes		col++;
2431590Srgrimes		if (col > maxcol)
244138232Sharti			maxcol = col;
2451590Srgrimes		continue;
2461590Srgrimes
2471590Srgrimes	case '\n':
2481590Srgrimes		flushln();
249138232Sharti		continue;
2501590Srgrimes
2511590Srgrimes	case '\f':
2521590Srgrimes		flushln();
2531590Srgrimes		putchar('\f');
2541590Srgrimes		continue;
2551590Srgrimes
2561590Srgrimes	default:
2571590Srgrimes		if (c < ' ')	/* non printing */
2581590Srgrimes			continue;
2591590Srgrimes		if (obuf[col].c_char == '\0') {
2601590Srgrimes			obuf[col].c_char = c;
2611590Srgrimes			obuf[col].c_mode = mode;
2621590Srgrimes		} else if (obuf[col].c_char == '_') {
2631590Srgrimes			obuf[col].c_char = c;
264138232Sharti			obuf[col].c_mode |= UNDERL|mode;
2651590Srgrimes		} else if (obuf[col].c_char == c)
266138232Sharti			obuf[col].c_mode |= BOLD|mode;
267138232Sharti		else
26849938Shoek			obuf[col].c_mode = mode;
2691590Srgrimes		col++;
270138232Sharti		if (col > maxcol)
2711590Srgrimes			maxcol = col;
2721590Srgrimes		continue;
2731590Srgrimes	}
274138232Sharti	if (maxcol)
2751590Srgrimes		flushln();
2761590Srgrimes}
2771590Srgrimes
2781590Srgrimesvoid
2791590Srgrimesflushln()
2801590Srgrimes{
2811590Srgrimes	register lastmode;
2821590Srgrimes	register i;
2831590Srgrimes	int hadmodes = 0;
2841590Srgrimes
2851590Srgrimes	lastmode = NORMAL;
2861590Srgrimes	for (i=0; i<maxcol; i++) {
2871590Srgrimes		if (obuf[i].c_mode != lastmode) {
2881590Srgrimes			hadmodes++;
2891590Srgrimes			setnewmode(obuf[i].c_mode);
2901590Srgrimes			lastmode = obuf[i].c_mode;
2911590Srgrimes		}
2921590Srgrimes		if (obuf[i].c_char == '\0') {
2931590Srgrimes			if (upln)
2941590Srgrimes				PRINT(CURS_RIGHT);
2951590Srgrimes			else
2961590Srgrimes				outc(' ');
2971590Srgrimes		} else
2981590Srgrimes			outc(obuf[i].c_char);
299138232Sharti	}
3001590Srgrimes	if (lastmode != NORMAL) {
30194584Sobrien		setnewmode(0);
30294584Sobrien	}
3031590Srgrimes	if (must_overstrike && hadmodes)
3041590Srgrimes		overstrike();
3051590Srgrimes	putchar('\n');
3061590Srgrimes	if (iflag && hadmodes)
3071590Srgrimes		iattr();
3081590Srgrimes	(void)fflush(stdout);
3091590Srgrimes	if (upln)
310138232Sharti		upln--;
3111590Srgrimes	initbuf();
3128874Srgrimes}
313138232Sharti
314138232Sharti/*
315138232Sharti * For terminals that can overstrike, overstrike underlines and bolds.
3161590Srgrimes * We don't do anything with halfline ups and downs, or Greek.
317138232Sharti */
318138232Shartivoid
319138232Shartioverstrike()
3201590Srgrimes{
3211590Srgrimes	register int i;
3221590Srgrimes	char lbuf[256];
323138232Sharti	register char *cp = lbuf;
3241590Srgrimes	int hadbold=0;
3258874Srgrimes
326138232Sharti	/* Set up overstrike buffer */
3271590Srgrimes	for (i=0; i<maxcol; i++)
3281590Srgrimes		switch (obuf[i].c_mode) {
3291590Srgrimes		case NORMAL:
3301590Srgrimes		default:
3311590Srgrimes			*cp++ = ' ';
3321590Srgrimes			break;
3331590Srgrimes		case UNDERL:
3341590Srgrimes			*cp++ = '_';
3351590Srgrimes			break;
33649938Shoek		case BOLD:
3371590Srgrimes			*cp++ = obuf[i].c_char;
3381590Srgrimes			hadbold=1;
3391590Srgrimes			break;
3401590Srgrimes		}
341138232Sharti	putchar('\r');
3425814Sjkh	for (*cp=' '; *cp==' '; cp--)
343138232Sharti		*cp = 0;
3445814Sjkh	for (cp=lbuf; *cp; cp++)
345138232Sharti		putchar(*cp);
346138232Sharti	if (hadbold) {
3475814Sjkh		putchar('\r');
348138232Sharti		for (cp=lbuf; *cp; cp++)
3491590Srgrimes			putchar(*cp=='_' ? ' ' : *cp);
3501590Srgrimes		putchar('\r');
3511590Srgrimes		for (cp=lbuf; *cp; cp++)
3521590Srgrimes			putchar(*cp=='_' ? ' ' : *cp);
3531590Srgrimes	}
3548874Srgrimes}
3551590Srgrimes
3561590Srgrimesvoid
3571590Srgrimesiattr()
3581590Srgrimes{
3591590Srgrimes	register int i;
3601590Srgrimes	char lbuf[256];
3611590Srgrimes	register char *cp = lbuf;
3621590Srgrimes
3631590Srgrimes	for (i=0; i<maxcol; i++)
3641590Srgrimes		switch (obuf[i].c_mode) {
3651590Srgrimes		case NORMAL:	*cp++ = ' '; break;
3661590Srgrimes		case ALTSET:	*cp++ = 'g'; break;
3671590Srgrimes		case SUPERSC:	*cp++ = '^'; break;
3681590Srgrimes		case SUBSC:	*cp++ = 'v'; break;
3691590Srgrimes		case UNDERL:	*cp++ = '_'; break;
3701590Srgrimes		case BOLD:	*cp++ = '!'; break;
3711590Srgrimes		default:	*cp++ = 'X'; break;
3721590Srgrimes		}
3731590Srgrimes	for (*cp=' '; *cp==' '; cp--)
3741590Srgrimes		*cp = 0;
375138232Sharti	for (cp=lbuf; *cp; cp++)
3761590Srgrimes		putchar(*cp);
37794584Sobrien	putchar('\n');
37894584Sobrien}
37994584Sobrien
38094584Sobrienvoid
3811590Srgrimesinitbuf()
382138232Sharti{
383105826Sjmallett
3841590Srgrimes	bzero((char *)obuf, sizeof (obuf));	/* depends on NORMAL == 0 */
3851590Srgrimes	col = 0;
3861590Srgrimes	maxcol = 0;
3871590Srgrimes	mode &= ALTSET;
3881590Srgrimes}
3891590Srgrimes
3901590Srgrimesvoid
3911590Srgrimesfwd()
3921590Srgrimes{
3931590Srgrimes	register oldcol, oldmax;
3941590Srgrimes
3951590Srgrimes	oldcol = col;
3961590Srgrimes	oldmax = maxcol;
3971590Srgrimes	flushln();
3981590Srgrimes	col = oldcol;
3991590Srgrimes	maxcol = oldmax;
4001590Srgrimes}
4011590Srgrimes
4021590Srgrimesvoid
4031590Srgrimesreverse()
4041590Srgrimes{
4051590Srgrimes	upln++;
4061590Srgrimes	fwd();
4071590Srgrimes	PRINT(CURS_UP);
4081590Srgrimes	PRINT(CURS_UP);
4091590Srgrimes	upln++;
4101590Srgrimes}
4111590Srgrimes
4121590Srgrimesvoid
4131590Srgrimesinitcap()
4141590Srgrimes{
4151590Srgrimes	static char tcapbuf[512];
4161590Srgrimes	char *bp = tcapbuf;
4171590Srgrimes
4181590Srgrimes	/* This nonsense attempts to work with both old and new termcap */
4191590Srgrimes	CURS_UP =		tgetstr("up", &bp);
4201590Srgrimes	CURS_RIGHT =		tgetstr("ri", &bp);
4211590Srgrimes	if (CURS_RIGHT == NULL)
4221590Srgrimes		CURS_RIGHT =	tgetstr("nd", &bp);
4231590Srgrimes	CURS_LEFT =		tgetstr("le", &bp);
4241590Srgrimes	if (CURS_LEFT == NULL)
4251590Srgrimes		CURS_LEFT =	tgetstr("bc", &bp);
4261590Srgrimes	if (CURS_LEFT == NULL && tgetflag("bs"))
4271590Srgrimes		CURS_LEFT =	"\b";
4281590Srgrimes
4291590Srgrimes	ENTER_STANDOUT =	tgetstr("so", &bp);
4301590Srgrimes	EXIT_STANDOUT =		tgetstr("se", &bp);
4311590Srgrimes	ENTER_UNDERLINE =	tgetstr("us", &bp);
4321590Srgrimes	EXIT_UNDERLINE =	tgetstr("ue", &bp);
4331590Srgrimes	ENTER_DIM =		tgetstr("mh", &bp);
4341590Srgrimes	ENTER_BOLD =		tgetstr("md", &bp);
4351590Srgrimes	ENTER_REVERSE =		tgetstr("mr", &bp);
4361590Srgrimes	EXIT_ATTRIBUTES =	tgetstr("me", &bp);
4371590Srgrimes
4381590Srgrimes	if (!ENTER_BOLD && ENTER_REVERSE)
4391590Srgrimes		ENTER_BOLD = ENTER_REVERSE;
4401590Srgrimes	if (!ENTER_BOLD && ENTER_STANDOUT)
4411590Srgrimes		ENTER_BOLD = ENTER_STANDOUT;
4421590Srgrimes	if (!ENTER_UNDERLINE && ENTER_STANDOUT) {
4431590Srgrimes		ENTER_UNDERLINE = ENTER_STANDOUT;
4441590Srgrimes		EXIT_UNDERLINE = EXIT_STANDOUT;
4451590Srgrimes	}
446103545Sjmallett	if (!ENTER_DIM && ENTER_STANDOUT)
4471590Srgrimes		ENTER_DIM = ENTER_STANDOUT;
4481590Srgrimes	if (!ENTER_REVERSE && ENTER_STANDOUT)
4498874Srgrimes		ENTER_REVERSE = ENTER_STANDOUT;
450138232Sharti	if (!EXIT_ATTRIBUTES && EXIT_STANDOUT)
451138232Sharti		EXIT_ATTRIBUTES = EXIT_STANDOUT;
452138232Sharti
4531590Srgrimes	/*
4541590Srgrimes	 * Note that we use REVERSE for the alternate character set,
4551590Srgrimes	 * not the as/ae capabilities.  This is because we are modelling
456138232Sharti	 * the model 37 teletype (since that's what nroff outputs) and
4571590Srgrimes	 * the typical as/ae is more of a graphics set, not the greek
4581590Srgrimes	 * letters the 37 has.
4591590Srgrimes	 */
4601590Srgrimes
4611590Srgrimes	UNDER_CHAR =		tgetstr("uc", &bp);
4621590Srgrimes	must_use_uc = (UNDER_CHAR && !ENTER_UNDERLINE);
463138232Sharti}
4641590Srgrimes
4651590Srgrimesint
4661590Srgrimesoutchar(c)
4671590Srgrimes	int c;
4681590Srgrimes{
4691590Srgrimes	return(putchar(c & 0177));
4701590Srgrimes}
471138232Sharti
4721590Srgrimesstatic int curmode = 0;
473138232Sharti
4741590Srgrimesvoid
4751590Srgrimesoutc(c)
4761590Srgrimes	int c;
477138232Sharti{
4781590Srgrimes	putchar(c);
4791590Srgrimes	if (must_use_uc && (curmode&UNDERL)) {
4801590Srgrimes		PRINT(CURS_LEFT);
4811590Srgrimes		PRINT(UNDER_CHAR);
4821590Srgrimes	}
4831590Srgrimes}
4841590Srgrimes
48569527Swillvoid
4861590Srgrimessetnewmode(newmode)
4871590Srgrimes	int newmode;
4881590Srgrimes{
48969531Swill	if (!iflag) {
4901590Srgrimes		if (curmode != NORMAL && newmode != NORMAL)
491138232Sharti			setnewmode(NORMAL);
4921590Srgrimes		switch (newmode) {
4931590Srgrimes		case NORMAL:
4948874Srgrimes			switch(curmode) {
4951590Srgrimes			case NORMAL:
4961590Srgrimes				break;
4971590Srgrimes			case UNDERL:
4981590Srgrimes				PRINT(EXIT_UNDERLINE);
499138232Sharti				break;
500104121Sjmallett			default:
501104121Sjmallett				/* This includes standout */
5021590Srgrimes				PRINT(EXIT_ATTRIBUTES);
503138232Sharti				break;
5041590Srgrimes			}
5051590Srgrimes			break;
506138232Sharti		case ALTSET:
507138232Sharti			PRINT(ENTER_REVERSE);
5081590Srgrimes			break;
5091590Srgrimes		case SUPERSC:
510105826Sjmallett			/*
511138232Sharti			 * This only works on a few terminals.
5121590Srgrimes			 * It should be fixed.
5131590Srgrimes			 */
514138232Sharti			PRINT(ENTER_UNDERLINE);
5151590Srgrimes			PRINT(ENTER_DIM);
5161590Srgrimes			break;
5171590Srgrimes		case SUBSC:
5181590Srgrimes			PRINT(ENTER_DIM);
5191590Srgrimes			break;
5201590Srgrimes		case UNDERL:
5211590Srgrimes			PRINT(ENTER_UNDERLINE);
5221590Srgrimes			break;
5231590Srgrimes		case BOLD:
5241590Srgrimes			PRINT(ENTER_BOLD);
5251590Srgrimes			break;
5261590Srgrimes		default:
5271590Srgrimes			/*
5281590Srgrimes			 * We should have some provision here for multiple modes
5291590Srgrimes			 * on at once.  This will have to come later.
5301590Srgrimes			 */
5311590Srgrimes			PRINT(ENTER_STANDOUT);
5321590Srgrimes			break;
5331590Srgrimes		}
5341590Srgrimes	}
5351590Srgrimes	curmode = newmode;
536138232Sharti}
5371590Srgrimes