[net.text] nroff driver tables - how-to

perl@rdin.UUCP (Robert Perlberg) (04/06/84)

<>

Since I posted my request for info on constructing an nroff driver
table, I have received an overwhelming number of requests for
this information to be relayed.  I do not have all of the information
yet, but I felt that I should post what I have so that everyone
will know that I have not forgotten them.

The manual page at the end of this article contains a description
of the structure and how to fill it.  Many thanks to the many
people who sent me copies of this page.  It also describes the
procedure for converting this source file into a data file under
System III.  I still do not have the maketerms.c and terms.mk
files which are needed for this procedure.  I would even welcome
a description of the file contents so that I could write my own.

BSD does not require these files.  Under BSD, you simply compile
the source file, and move the ".o" file (sans ".o") to /usr/lib/term.

.TH TERM 5
.SH NAME
term \- terminal driving tables for nroff
.SH DESCRIPTION
.IR Nroff (1)
uses driving tables to customize its output for various types of
output devices, such as printing terminals, special word-processing
terminals (such as Diablo, Qume, or NEC Spinwriter mechanisms),
or special output filter programs.  These driving tables are written
as C programs, compiled, and installed in
\f3/usr/lib/term/tab\f2name\fP ,
where
.I name\^
is the name for that terminal type as given in
.IR term (7).
The structure of the tables is as follows:
.PP
.nf
.ta 5m 10m 15m 20m 25m 30m 35m 40m 45m 50m 55m 60m
#define	INCH	240

struct {
	int bset;
	int breset;
	int Hor;
	int Vert;
	int Newline;
	int Char;
	int Em;
	int Halfline;
	int Adj;
	char *twinit;
	char *twrest;
	char *twnl;
	char *hlr;
	char *hlf;
	char *flr;
	char *bdon;
	char *bdoff;
	char *iton;
	char *itoff;
	char *ploton;
	char *plotoff;
	char *up;
	char *down;
	char *right;
	char *left;
	char *codetab[256\-32];
	char *zzz;
} t;
.fi
.DT
.PP
The meanings of the various fields are as follows:
.TP 10
.I bset\^
bits to set in the
.I c_oflag\^
field of the
.I termio\^
structure (see
.IR tty (4))
before output.
.TP 10
.I breset\^
bits to reset in the
.I c_oflag\^
field of the
.I termio\^
structure
before output.
.TP 10
.I Hor\^
horizontal resolution in fractions of an inch.
.TP 10
.I Vert\^
vertical resolution in fractions of an inch.
.TP 10
.I Newline\^
space moved by a newline (linefeed) character in fractions
of an inch.
.TP 10
.I Char\^
quantum of character sizes, in fractions of an inch.
(i.e., a character is a multiple of Char units wide)
.TP 10
.I Em\^
size of an em in fractions of an inch.
.TP 10
.I Halfline\^
space moved by a half-linefeed (or half-reverse-linefeed)
character in fractions of an inch.
.TP 10
.I Adj\^
quantum of white space, in fractions of an inch.
(i.e., white spaces are a multiple of Adj units wide)
.IP
Note: if this is less than the size of the space
character (in units of Char; see below for how the
sizes of characters are defined),
.I nroff\^
will output
fractional spaces using plot mode.  Also, if the
.B \-e
switch to
.I nroff\^
is used, Adj is set equal to Hor by
.IR nroff .
.TP 10
.I twinit\^
set of characters used to initialize the terminal
in a mode suitable for
.IR nroff .
.TP 10
.I twrest\^
set of characters used to restore the terminal to
normal mode.
.TP 10
.I twnl\^
set of characters used to move down one line.
.TP 10
.I hlr\^
set of characters used to move up one-half line.
.TP 10
.I hlf\^
set of characters used to move down one-half line.
.TP 10
.I flr\^
set of characters used to move up one line.
.TP 10
.I bdon\^
set of characters used to turn on hardware boldface mode,
if any.
.I Nroff\^
assumes that boldface mode is reset automatically by the
.I twnl\^
string, because many letter-quality printers reset the boldface
mode when they receive a carriage return;
the
.I twnl\^
string should include whatever characters are necessary to
reset the boldface mode.
.TP 10
.I bdoff\^
set of characters used to turn off hardware boldface mode,
if any.
.TP 10
.I iton\^
set of characters used to turn on hardware italics mode,
if any.
.TP 10
.I itoff\^
set of characters used to turn off hardware italics mode,
if any.
.TP 10
.I ploton\^
set of characters used to turn on hardware plot mode
(for Diablo type mechanisms), if any.
.TP 10
.I plotoff\^
set of characters used to turn off hardware plot mode
(for Diablo type mechanisms), if any.
.TP 10
.I up\^
set of characters used to move up one resolution unit
(Vert) in plot mode, if any.
.TP 10
.I down\^
set of characters used to move down one resolution unit
(Vert) in plot mode, if any.
.TP 10
.I right\^
set of characters used to move right one resolution unit
(Hor) in plot mode, if any.
.TP 10
.I left\^
set of characters used to move left one resolution unit
(Hor) in plot mode, if any.
.TP 10
.I codetab\^
definition of characters needed to print an
.I nroff\^
character
on the terminal.
The first byte is the number of character units (Char) needed to hold the
character; i.e., ``\\001'' is one unit wide, ``\\002'' is two
units wide, etc.  The high-order bit (0200) is on if
the character is to be underlined in underline mode
(.ul).
The rest of the bytes are the characters used to produce the character in
question.  If the character has the sign (0200) bit on,
it is a code to move the terminal in plot mode.  It is
encoded as:
.RS
.IP "0100 bit on" 15
vertical motion.
.IP "0100 bit off" 15
horizontal motion.
.IP "040 bit on" 15
negative (up or left) motion.
.IP "040 bit off" 15
positive (down or right) motion.
.IP "037 bits" 15
number of such motions to make.
.RE
.TP 10
.I zzz\^
a zero terminator at the end.
.PP
All quantities which are in units of fractions of an inch should
be expressed as
.RI INCH* num / denom ,
where
.I num\^
and
.I denom\^
are respectively the numerator and denominator of the fraction; i.e.,
1/48 of an inch would be written as ``INCH/48''.
.PP
If any sequence of characters does not pertain to the output device,
that sequence should be given as a null string.
.PP
The source code for the terminal
.I name\^
is in
.BI /usr/src/cmd/text/roff.d/terms.d/tab name .c.
When a new terminal type is added, the file
.I maketerms.c\^
should be updated to `#include' the source to that driving table;
note that the various terminal types are grouped into ``parts'' labelled
.BR PART1 ,
.BR PART2 ,
and
.BR PART3 .
If necessary, more parts can be added.  Other changes necessary to
.I maketerms.c\^
are left as an exercise to the reader.
The makefile
.I terms.mk\^
in that directory should then be updated.
.SH FILES
/usr/lib/term/tab\f2name\fP	driving tables
.br
tab\f2name\fP.c	source for driving tables
.SH SEE ALSO
troff(1), term(7)

------------------------------------------------------------------
Here is the sequence of the characters in the codetab:

/*codetab*/
"\001 ",	/*space*/
"\001!",	/*!*/
"\001\"",	/*"*/
"\001#",	/*#*/
"\001$",	/*$*/
"\001%",	/*%*/
"\001&",	/*&*/
"\001'",	/*' close*/
"\001(",	/*(*/
"\001)",	/*)*/
"\001*",	/***/
"\001+",	/*+*/
"\001,",	/*,*/
"\001-",	/*- hyphen*/
"\001.",	/*.*/
"\001/",	/*/*/
"\2010",	/*0*/
"\2011",	/*1*/
"\2012",	/*2*/
"\2013",	/*3*/
"\2014",	/*4*/
"\2015",	/*5*/
"\2016",	/*6*/
"\2017",	/*7*/
"\2018",	/*8*/
"\2019",	/*9*/
"\001:",	/*:*/
"\001;",	/*;*/
"\001<",	/*<*/
"\001=",	/*=*/
"\001>",	/*>*/
"\001?",	/*?*/
"\001@",	/*@*/
"\201A",	/*A*/
"\201B",	/*B*/
"\201C",	/*C*/
"\201D",	/*D*/
"\201E",	/*E*/
"\201F",	/*F*/
"\201G",	/*G*/
"\201H",	/*H*/
"\201I",	/*I*/
"\201J",	/*J*/
"\201K",	/*K*/
"\201L",	/*L*/
"\201M",	/*M*/
"\201N",	/*N*/
"\201O",	/*O*/
"\201P",	/*P*/
"\201Q",	/*Q*/
"\201R",	/*R*/
"\201S",	/*S*/
"\201T",	/*T*/
"\201U",	/*U*/
"\201V",	/*V*/
"\201W",	/*W*/
"\201X",	/*X*/
"\201Y",	/*Y*/
"\201Z",	/*Z*/
"\001[",	/*[*/
"\001\\",	/*\*/
"\001]",	/*]*/
"\001^",	/*^*/
"\001_",	/*_ dash*/
"\001`",	/*` open*/
"\201a",	/*a*/
"\201b",	/*b*/
"\201c",	/*c*/
"\201d",	/*d*/
"\201e",	/*e*/
"\201f",	/*f*/
"\201g",	/*g*/
"\201h",	/*h*/
"\201i",	/*i*/
"\201j",	/*j*/
"\201k",	/*k*/
"\201l",	/*l*/
"\201m",	/*m*/
"\201n",	/*n*/
"\201o",	/*o*/
"\201p",	/*p*/
"\201q",	/*q*/
"\201r",	/*r*/
"\201s",	/*s*/
"\201t",	/*t*/
"\201u",	/*u*/
"\201v",	/*v*/
"\201w",	/*w*/
"\201x",	/*x*/
"\201y",	/*y*/
"\201z",	/*z*/
"\001{",	/*{*/
"\001|",	/*|*/
"\001}",	/*}*/
"\001~",	/*~*/
/* Fill in the rest of these as they pertain to your printer */
"",	/*narrow sp*/
"",	 /*hyphen*/
"",	 /*bullet*/
"",	 /*square*/
"",	 /*3/4 em*/
"",	 /*rule*/
"",	 /*1/4*/
"",	 /*1/2*/
"",	 /*3/4*/
"",	 /*minus*/
"",	 /*fi*/
"",	 /*fl*/
"",	 /*ff*/
"",	 /*ffi*/
"",	 /*ffl*/
"",	 /*degree*/
"",	 /*dagger*/
"",	 /*section*/
"",	 /*foot mark*/
"",	 /*acute accent*/
"",	 /*grave accent*/
"",	 /*underrule*/
"",	 /*slash (longer)*/
"",	/*half narrow space*/
"",	/*unpaddable space*/
"",	/*alpha*/
"",	/*beta*/
"",	/*gamma*/
"",	/*delta*/
"",	/*epsilon*/
"",	/*zeta*/
"",	/*eta*/
"",	/*theta*/
"",	/*iota*/
"",	/*kappa*/
"",	/*lambda*/
"",	/*mu*/
"",	/*nu*/
"",	/*xi*/
"",	/*omicron*/
"",	/*pi*/
"",	/*rho*/
"",	/*sigma*/
"",	/*tau*/
"",	/*upsilon*/
"",	/*phi*/
"",	/*chi*/
"",	/*psi*/
"",	/*omega*/
"",	/*Gamma*/
"",	/*Delta*/
"",	/*Theta*/
"",	/*Lambda*/
"",	/*Xi*/
"",	/*Pi*/
"",	/*Sigma*/
"",	/*Tau*/
"",			/*Upsilon*/
"",	/*Phi*/
"",	/*Psi*/
"",	/*Omega*/
"",	/*square root*/
"",	 /*terminal sigma*/
"",	 /*root en*/
"",	 /*>=*/
"",	 /*<=*/
"",	/*identically equal*/
"",	 /*equation minus*/
"",	 /*approx =*/
"",	 /*approximates*/
"",	/*not equal*/
"",	/*right arrow*/
"",	/*left arrow*/
"",	/*up arrow*/
"",	/*down arrow*/
"",	/*eqn equals*/
"",	 /*multiply*/
"",	/*divide*/
"",	/*plus-minus*/
"",	 /*cup (union)*/
"",	 /*cap (intersection)*/
"",	 /*subset of*/
"",	 /*superset of*/
"",	 /*improper subset*/
"",	 /* improper superset*/
"",	/*infinity*/
"",	/*pt deriv*/
"",	/*gradient*/
"",	/*not*/
"",	/*integral*/
"",	/*proportional to*/
"",	 /*empty set*/
"",	 /*member of*/
"",	 /*equation plus*/
"",	/*registration mk*/
"",	/*copyright mk*/
"",	/*box rule*/
"",	 /*cent sign*/
"",	/*dbl dagger*/
"",	 /*right hand*/
"",	 /*left hand*/
"",	 /*math * */
"",	 /*bell system sign*/
"",	 /*or (was star)*/
"",	 /*circle*/
"",	/*left top of big curly*/
"",	/*left bot of big curly*/
"",	/*right top of big curly*/
"",	/*right bot of big curly*/
"",	/*left ctr of big curly*/
"",	/*right ctr of big curly*/
"",	/*bold vertical*/
"",	/*left floor of big bract*/
"",	/*right floor of big bract*/
"",	/*left ceil of big bract*/
""};	/*right ceil of big bract*/



Robert Perlberg
Resource Dynamics Inc.
New York
philabs!rdin!rdin2!perl

guy@rlgvax.UUCP (Guy Harris) (04/15/84)

> It also describes the procedure for converting this source file
> into a data file under System III.  I still do not have the maketerms.c
> and terms.mk files which are needed for this procedure.  I would even
> welcome a description of the file contents so that I could write my own.

Unfortunately, those files are part of the *roff source distribution, so
you'd have to have a source license to get them.

> BSD does not require these files.  Under BSD, you simply compile
> the source file, and move the ".o" file (sans ".o") to /usr/lib/term.

V7 doesn't require them either.  (There seems to be a common assumption that
there's BSD UNIX and there's USG UNIX.  Many forget that there was a V7 UNIX
which actually ran on PDP-11s and preceded both BSD and USG UNIX.)

Also note:

1) under V7 and 4.xBSD, "bset" and "breset" are the bits to turn on and off
in the "sg_flags" field;

2) the remark about boldface mode being reset automatically by the "twnl"
string is *not* generically true; it was a local modification made here due
to the braindamage of the Spinwriter printers we have - a carriage return
turns off boldfacing on those printers,

and 3) the V7/4.xBSD "nroff" does not have the "iton" or "itoff" sequences
for turning on and off "italic" mode.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy