[comp.text] nroff transparent mode

holder@druhi.ATT.COM (HolderML) (02/19/88)

I'm trying to send some escape sequences through nroff (the DWB 2.0 version
running on System V.2 on Amdahl UTS) to generate some special characters
and to do some highlighting (shading) on a Xerox 9700 printer.  The
Nroff/Troff User's Manual indicates that to have text transparently copied
to the output, I should use the \! at the beginning of the line.  However,
it looks like nroff is not copying the text transparently.  For instance,
when I give it the following input:

	.DS
	\!This is shaded text.

	\!\033\033\017This is shaded text.\033\033\016
	.DE

(where the <ESC><ESC>^O is shading on and <ESC><ESC>^N is shading off) gives

	This is shaded text.				(unshaded)

	33 33 17This is shaded text.33 33 16		(unshaded)

Does anybody know the trick to having the escape sequences sent transparently
to the device?  I seem to recall this being discussed a few months ago in
this newsgroup, but I don't remember the conclusion.

Mike Holder
AT&T Denver
..!ihnp4!druhi!holder

bamford@ihlpg.ATT.COM (Harold E. Bamford) (02/19/88)

In article <2694@druhi.ATT.COM> holder@druhi.ATT.COM (HolderML) writes:
>I'm trying to send some escape sequences through nroff (the DWB 2.0 version
>running on System V.2 on Amdahl UTS) to generate some special characters
>and to do some highlighting (shading) on a Xerox 9700 printer.
>Nroff/Troff User's Manual indicates that to have text transparently copied
>to the output, I should use the \! at the beginning of the line.  However,
>it looks like nroff is not copying the text transparently.  For instance,
>when I give it the following input:
>
>	.DS
>	\!This is shaded text.
>
>	\!\033\033\017This is shaded text.\033\033\016
>	.DE

I think there may be two problems here:

1) The character sequence "\033" is recognized as the special character
   \0 followed by the two characters 33.  If you want an escape char,
   then you must use an escape char, not a 4-char sequence that we
   generally recognize as MEANING escape.  In this respect, nroff is not
   as smart as echo(1) or ed(1).

2) I recognize "<ESC><^O>" as being an escape sequence used by the
   xerox(1) or x9700(1) programs.  These programs format card images for
   the 9700 printer, but the card images don't actually contain the
   escape sequence.  Are you running the output of nroff through one
   of these filters?


Finally, you should be aware that the \! sequence appends a newline to
the literal string that you provide; the newline used to terminate the
literal string is also output.  If you are trying to output an escape
sequence to turn on some mode, and this mode is then reset by a newline,
you are doomed.  I would be happy to be proved wrong on this as it has 
proved to be a problem for me.

				Harold Bamford
-- 
				Harold Bamford, AT&T Bell Labs
				IHP 2F-524 (312) 416-7397
				ihnp4!ihlpg!bamford

dre@cs.nott.ac.uk (David Evans) (02/24/88)

In article <2694@druhi.ATT.COM> holder@druhi.ATT.COM (HolderML) writes:
>The Nroff/Troff User's Manual indicates that to have text transparently copied
>to the output, I should use the \! at the beginning of the line.  However,
>it looks like nroff is not copying the text transparently.  For instance,
>when I give it the following input:
>
>	.DS
>	\!This is shaded text.
>
>	\!\033\033\017This is shaded text.\033\033\016
>	.DE

Funny things happen with interpretation of the escape character (\) in
diversions, such as when using .DS / .DE.  It would be better to leave out
the .DS / .DE pair altogether since it is unnecessary in this instance.

David R Evans,				JANET:  dre@cs.nott.ac.uk
Electronic Publishing Research Group,	ARPA:	dre%nott.cs@cs.ucl.ac.uk
Department of Computer Science,		UUCP:	... !mcvax!ukc!nott-cs!dre
University of Nottingham,		Tel.	NOTTINGHAM(0602) 506101
NOTTINGHAM, ENGLAND, NG7 2RD.			Ext. 2765

holder@druhi.ATT.COM (HolderML) (02/24/88)

In article <2694@druhi.ATT.COM>, holder@druhi.ATT.COM (HolderML) writes:
> I'm trying to send some escape sequences through nroff (the DWB 2.0 version
> running on System V.2 on Amdahl UTS) to generate some special characters
> and to do some highlighting (shading) on a Xerox 9700 printer.  The
> 
> 	.DS
> 	\!This is shaded text.
> 
> 	\!\033\033\017This is shaded text.\033\033\016
> 	.DE
> 

First, let me thank those who tried to help, either via mail or by posting
a reply.  Second, let me apologize for not noticing that our mailer here
stripped out the embedded escape sequences I had placed in the message.
(The first line of the display should have looked something like:
	\!^]^]^OThis is shaded text.^]^]^N
where ^] is the ASCII escape character and ^O and ^N are the ASCII
shift out/shift in characters.)  This confused the issue quite a bit.
The other line of the display would never have worked anyway, since
nroff takes the \0 as a null.

Some people pointed out that being in a display (diversion) caused nroff
to handle things slightly differently, so I took the .DS/.DE away, and
lo and behold: nothing changed.  Nroff still ate the escape sequences.

Now for the answer!

It turns out the the DWB 2.0 nroff is supposed to eat escape sequences
(even though that fact didn't show up in the documentation).  DWB 2.0 nroff
handles device specific control sequences via device specific tables that
are read in at run time.  (The one for the -TX97 option to nroff exists
in /usr/lib/nterm/tab.X97 on our system.)  All device specific control
sequences are defined as nroff strings, and the user must use the appropriate
string name to generate the appropriate action.  For instance, the bullet
character is the nroff string \(bu and is defined for the X97 device as
^]^]W (whereas for some other device the bullet character might be some other
escape sequence, an asterisk or possibly even null).  For the X97 device,
there are strings \(ds and \(ls to darken and lighten shading.  For other
devices, those strings are undefined and hence null.

I'm still at something of a loss as to why the escapes were being eaten
while in transparent mode, but since I've found the way to do what I want,
I'm not going to pursue it.

Mike Holder
AT&T Denver
..!ihnp4!druhi!holder