[net.misc] nroff terminal tables -- documentation!

henry (08/17/82)

V7 nroff (and some earlier ones) has an option, -T, to specify what
type of terminal you are outputting to.  Not many people know just what
this option does, because the details are undocumented.  It selects
a "terminal table" file from /usr/lib/term.  This file tells nroff
how to run the terminal, including the details of how to print each
character in nroff's internal character set (which has 200+ characters
including all the special math symbols).

The format of these tables is not documented anywhere, which is sad
because adapting nroff for best results on a new terminal is best done
by writing a new terminal table.  Post-processors are cumbersome and
slow by comparison, although they can do things the terminal table can't.
The tables that come with V7 nroff by no means cover all the terminals
one might wish to print on.

Here is the V7-manual-macros source of a locally-written manual page
describing the insides of terminal tables.  This page is written
for the nroff that came with V7;  the only other version this is
definitely applicable to is the "Phototypesetter" nroff, which differs
from the V7 one only in trivial ways.

Given this manual page and some inspection of /usr/src/cmd/troff/term,
writing new terminal tables shouldn't present too much of a problem.
It is usually better to work from an existing terminal table rather
than starting from scratch, if for no other reason than to get the
ordering of the character set right.

-----
.TH TERM 5
.SH NAME
term \- nroff terminal table
.SH SYNOPSIS
.nf
.ft B
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 *ploton;
	char *plotoff;
	char *up;
	char *down;
	char *right;
	char *left;
	char *codetab[256\-32];
	int zzz;
	};
.ft R
.SH DESCRIPTION
A terminal table describes to \fInroff\fR what the capabilities of
a given terminal are, and what must be sent to it to exploit those
capabilities.
The terminal table is the compiled object module of an initialized C
structure.
.PP
The fields are as follows.
Sizes are in 240ths of an inch.
Sequences generally are the empty string if the capability does not exist.
.nr a \w'Halfline '
.TP \nau
\fBbset\fR
Mask specifying what bits in the tty mode are to be \fIstty\fRed to \fB1\fR
during initialization.
.TP
\fBbreset\fR
Mask specifying what bits in the tty mode are to be \fIstty\fRed to \fB0\fR
during initialization.
.TP
\fBHor\fR
Unit of horizontal resolution and motion.
.TP
\fBVert\fR
Unit of vertical resolution and motion.
.TP
\fBNewline\fR
Vertical size of newline motion.
.TP
\fBChar\fR
Unit of width used in \fIcodetab\fR.
.TP
\fBEm\fR
Size of an em.
.TP
\fBHalfline\fR
Vertical size of half-line motions.
.TP
\fBAdj\fR
Quantum of margin adjustment in absence of \fB\-e\fR.
.TP
\fBtwinit\fR
Initialization sequence, emitted before any other output.
.TP
\fBtwrest\fR
Reset sequence, emitted after all other output.
.TP
\fBtwnl\fR
Newline sequence.
.TP
\fBhlr\fR
Halfline-up sequence.
.TP
\fBhlf\fR
Halfline-down sequence.
.TP
\fBflr\fR
Reverse newline (whole line up) sequence.
.TP
\fBbdon\fR
Sequence to turn boldface on.
.TP
\fBbdoff\fR
Sequence to turn boldface off.
.TP
\fBploton\fR
Sequence to turn plot mode on.
This is ``classical'' plot mode, where everything prints normally
except that no motion follows printing, and explicit motions are in
units of \fIHor\fR and \fIVert\fR.
.TP
\fBplotoff\fR
Sequence to turn plot mode off.
.TP
\fBup\fR
Plot-mode motion up one \fIVert\fR.
.TP
\fBdown\fR
Plot-mode motion down one \fIVert\fR.
.TP
\fBright\fR
Plot-mode motion right one \fIHor\fR.
.TP
\fBleft\fR
Plot-mode motion left one \fIHor\fR.
.TP
\fBcodetab\fR
Array of sequences to print individual characters.
Order is \fInroff\fR's crazy internal ordering.
See below for contents of sequence.
.TP
\fBzzz\fR
Endmarker for table, no other significance.
.PP
The \fIcodetab\fR sequences each begin with
a flag byte.
The top bit indicates whether the sequence should be underlined in
the \fB\&.ul\fR font.
The rest of the byte is the width of the sequence in units of \fIChar\fR.
.PP
The remainder of each \fIcodetab\fR sequence
is a sequence of characters to be output.
Characters with the top bit off are output as given;  characters
with the top bit on indicate escape into plot mode.
When such an escape character is encountered, \fInroff\fR shifts
into plot mode, emitting \fIploton\fR,
and skips to the next character if the escape character
was '\\200'.
.PP
When in plot mode, characters with the top bit off are output as given.
A character with the top bit on indicates a motion.
The next bit indicates coordinate, with \fB1\fR being vertical and
\fB0\fR being horizontal.
The next bit indicates direction, with \fB1\fR meaning up or left.
The remaining five bits give the amount of the motion.
An amount of zero causes exit from plot mode.
.PP
When plot mode is exited, either at the end of the string or via
the amount-zero exit, \fIplotoff\fR is emitted followed by a blank.
.SH FILES
/usr/lib/term/tab*
.br
/usr/src/cmd/troff/term/chartst
.SH SEE ALSO
nroff(1), term(7)
.SH HISTORY
This writeup by Henry Spencer at U of Toronto.
.SH BUGS
All this should really be integrated (somehow) with
.IR termcap (5).
.PP
The ever-growing diversity of terminals and the stupid inability
of manufacturers to understand the need for standardization
combine to produce an increasing number of terminals whose
features cannot be effectively characterized by this simple (!) scheme.
-----