[comp.unix.questions] How to make nroff boldface on a terminal that can highlight?

justice@dao.nrc.ca (Gerald Justice) (08/03/89)

I am writing some local man pages and was wondering if it was possible
to have nroff pass information about boldfaced text to a user's terminal
to have it appear as highlighted text.  Currently nroff'ed man pages
do show italicized items as underlined, but since most terminals
support other highlighting (inverse video, high intensity, or blinking)
it would be nice if boldface could appear as one of these.  More does put
its '--more--' prompt in inverse video on my terminal so it seems that
more could/should be able to do this.

Questions:
Is the reason this doesn't already work lie in nroff, in /etc/termcap, in 
/usr/lib/term/tab*, or in more?  Is this problem solvable?  Is it solvable
without source for nroff or more?
Are there other paging programs that do more highlighting than more?
(I have heard of a program called less but never seen it.)

Thank you, in advance.
 =-=-=-=-SOFTCOPY-=-=-=-=-=-=-=-|-=-=-HARDCOPY-=-=-=-=-=-=-=
Phone:     (604) 388-0055       | Fax:    (604) 388-0045
Internet:  justice@dao.nrc.ca   | Telex:  049-7295
      or:  justice@134.87.150.7	| Mail:   Dominion Astrophysical Observatory
BITNET:    justice@nrcdao       |         5071 W. Saanich Road
VAX PSI:   68100434::justice    |         Victoria, B.C.
SPAN,UUCP: (not yet available)  |         CANADA  V8X 4M6

duane@anasaz.UUCP (Duane Morse) (08/03/89)

In article <20477@adm.BRL.MIL>, justice@dao.nrc.ca (Gerald Justice) writes:
> I am writing some local man pages and was wondering if it was possible
> to have nroff pass information about boldfaced text to a user's terminal
> to have it appear as highlighted text.

There are a couple of approaches to this problem.

First, you can use the -T option of nroff when you format you man pages.
You would need to compile a translation table for the specified terminal;
there's public domain software to do this, by the way. The disadvantage
is that the escape sequences for one terminal don't necessarily apply
to the next. If you have more than one type of terminal at you're company,
you've got a problem. Further, you wouldn't be able to print that
version, either, because the printer probably has yet another idea of
how to do bold face and underlining.

Some terminals are smart enough to take the standard char-backspace-char
sequence and do boldface.  The public domain 'less' program is smart
enough to take these sequences and use inverse video for highlighting.

We keep formatted man pages under /usr/catman, like a lot of other
systems, to avoid the overhead of formatting the pages every time someone
wants to look something up. Using the standard 'man' command and piping
the stuff to 'less' works fine for us.

In order to print the formatted man pages, we have a locally-written
print filter program, and invoking that filter with the appropriate
printer-specific option is part of each lp interface script (we have
more than one type of printer and, with System V Rel 2, no convenient
way of doing printer control).
-- 

Duane Morse	...{asuvax or mcdphx}!anasaz!duane
(602) 861-7609

jba@harald.ruc.dk (Jan B. Andersen) (08/04/89)

$ man 1 ul | ul
-- 
Jan B. Andersen                              ("SIMULA does it with CLASS")

bink@aplcen.apl.jhu.edu (Ubben Greg) (08/05/89)

In article <537@anasaz.UUCP> duane@anasaz.UUCP (Duane Morse) writes:
> In article <20477@adm.BRL.MIL>, justice@dao.nrc.ca (Gerald Justice) writes:
> > I am writing some local man pages and was wondering if it was possible
> > to have nroff pass information about boldfaced text to a user's terminal
> > to have it appear as highlighted text.
>...
> Some terminals are smart enough to take the standard char-backspace-char
> sequence and do boldface.  The public domain 'less' program is smart
> enough to take these sequences and use inverse video for highlighting.
> We keep formatted man pages under /usr/catman, like a lot of other
> systems, to avoid the overhead of formatting the pages every time someone
> wants to look something up.
>...

Jan Anderson also mentions a BSD filter called "ul" which converts the
italics and bolding overstrikes used in default (-T37) nroff output into
highlighting commands for a particular output device.  If you don't have
access to this program (System V users), I've found that one can easily
create a filter for any particular device using a simple lex(1) program.
As an example, the following lex program (eproff.l) will create a filter
to format nroff output for an Epson printer:

%start ITALIC BOLD
%%
<INITIAL>_\b			    { printf("\0334"); BEGIN ITALIC; }
<INITIAL>.\b			    { printf("\033E"); BEGIN BOLD;   }
.\b				    ;
<ITALIC>./[^_]			    { ECHO; printf("\0335"); BEGIN INITIAL; }
<BOLD>./[\t\n ]*([!-~][^\b]|_\b)    { ECHO; printf("\033F"); BEGIN INITIAL; }

You would compile it by
	lex eproff.l && cc lex.yy.c -ll -o eproff
and might use it as
	man lex | eproff | lp -dep ...

If the input were:
	It does _^Hi_^Ht_^Ha_^Hl_^Hi_^Hc_^Hs
	_^Ht_^He_^Hx_^Ht and b^Hb^Hb^Hbo^Ho^Ho^Hol^Hl^Hl^Hld^Hd^Hd^Hd
	t^Ht^Ht^Hte^He^He^Hex^Hx^Hx^Hxt^Ht^Ht^Ht correctly.
The output would be:
	It does ^[4italics^[5
	^[4text^[5 and ^[Ebold
	text^[F correctly.

Notice the program maximizes the text between bolding commands in order to
simplify the output -- this might be undesirable for reverse-video on display
devices.  It doesn't do so for italics because this was converted from a
version which changed italics to continuous underlining for a Xerox 2700-II
laser printer.

You can create a filter for other devices by simply changing the printf()
arguments.  Or make it more general by adding a main() which looks up TERM
or a -T argument in the terminfo to get the appropriate codes.  My laser
printer version also recognizes the line motions ^[7, ^[8, and ^[9.
E-mail questions or feedback are welcome.

						-- Greg Ubben
						   bink@aplcen.apl.jhu.edu