8000 minix/minix/man/man5/termcap.5 at R3.3.0 · devinblood/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1865 lines (1865 loc) · 49.4 KB

termcap.5

File metadata and controls

1865 lines (1865 loc) · 49.4 KB
affected;
this is always 1 unless the terminal has
.B in
and the software uses it.)
When an `*' is specified, it is sometimes useful to give a delay of the form
`3.5' to specify a delay per line to tenths of milliseconds.
(Only one decimal place is allowed.)
.PP
A number of escape sequences are provided in the string-valued capabilities
for easy encoding of control characters there.
.B \eE
maps to an \s-2ESC\s0
character,
.B ^X
maps to a control-X for any appropriate X,
and the sequences
.B \en
.B \er
.B \et
.B \eb
.B \ef
map to linefeed, return, tab, backspace, and formfeed, respectively.
Finally, characters may be given as three octal digits after a
.BR \e ,
and the characters
.B ^
and
.B \e
may be given as
.B \e^
and
.BR \e\e .
If it is necessary to place a
.B :
in a capability it must be escaped in
octal as
.BR \e072 .
If it is necessary to place a \s-2NUL\s0
character in a string capability it
must be encoded as
.BR \e200 .
(The routines that deal with
.B termcap\^
use C strings and strip the high bits of the output very late, so that
a
.B \e200
comes out as a
.B \e000
would.)
.PP
Sometimes individual capabilities must be commented out.
To do this, put a period before the capability name.
For example, see the first
.B cr
and
.B ta
in the example above.
.br
.ne 5
.PP
.B Preparing Descriptions
.PP
We now outline how to prepare descriptions of terminals.
The most effective way to prepare a terminal description is by imitating
the description of a similar terminal in
.B termcap\^
and to build up a description gradually, using partial descriptions
with
.B vi\^
to check that they are correct.
Be aware that a very unusual terminal may expose deficiencies in
the ability of the
.B termcap\^
file to describe it
or bugs in
.BR vi\^ .
To easily test a new terminal description you can set the environment variable
.B
.SM TERMCAP
to the absolute pathname of a file containing the description you are working
on and programs will look there rather than in
.BR /etc/termcap\^ .
.B
.SM TERMCAP
can also be set to the
.B termcap\^
entry itself
to avoid reading the file when starting up a program.
.PP
To get the padding for insert-line right
(if the terminal manufacturer did not document it),
a severe test is to use
.B vi\^
to edit
.B /etc/passwd\^
at 9600 baud, delete roughly 16 lines from the middle of the screen,
then hit the `u' key several times quickly.
If the display messes up, more padding is usually needed.
A similar test can be used for insert-character.
.br
.ne 5
.PP
.B Basic Capabilities
.PP
The number of columns on each line of the display is given by the
.B co
numeric capability.
If the display is a \s-1CRT\s0, then the
number of lines on the screen is given by the
.B li
capability.
If the display wraps around to the beginning of the next line when
the cursor reaches the right margin, then it should have the
.B am
capability.
If the terminal can clear its screen,
the code to do this is given by the
.B cl
string capability.
If the terminal overstrikes
(rather than clearing the position when a character is overwritten),
it should have the
.B os
capability.
If the terminal is a printing terminal,
with no soft copy unit,
give it both
.B hc
and
.BR os .
.RB ( os
applies to storage scope terminals,
such as the Tektronix 4010 series,
as well as to hard copy and
.SM APL
terminals.)
If there is a code to move the cursor to the left edge of the current row,
give this as
.BR cr .
(Normally this will be carriage-return,
.BR ^M .)
If there is a code to produce an audible signal (bell, beep,
.IR etc.\^ ),
give this as
.BR bl .
.PP
If there is a code (such as backspace)
to move the cursor one position to the left,
that capability should be given as
.BR le .
Similarly,
codes to move to the right, up, and down
should be given as
.BR nd ,
.BR up ,
and
.BR do ,
respectively.
These
.I local cursor motions\^
should not alter the text they pass over;
for example, you would not normally use
\*(lqnd=\ \*(rq
unless the terminal has the
.B os
capability,
because the space would erase the character moved over.
.PP
A very important point here is that the local cursor motions encoded
in
.B termcap\^
have undefined behavior at the left and top edges of a
.SM CRT
display.
Programs should never attempt to backspace around the left edge,
unless
.B bw
is given, and never attempt to go up off the top
using local cursor motions.
.PP
In order to scroll text up,
a program goes to the bottom left corner of the screen and sends the
.B sf
(index) string.
To scroll text down,
a program goes to the top left corner of the screen and sends the
.B sr
(reverse index) string.
The strings
.B sf
and
.B sr
have undefined behavior
when not on their respective corners of the screen.
Parameterized versions of the scrolling sequences are
.B SF
and
.BR SR ,
which have the same semantics as
.B sf
and
.B sr
except that they take one parameter
and scroll that many lines.
They also have undefined behavior
except at the appropriate corner of the screen.
.PP
The
.B am
capability tells whether the cursor sticks at the right
edge of the screen when text is output there,
but this does not necessarily apply to
.B nd
from the last column.
Leftward local motion is defined from the left edge only when
.B bw
is given; then an
.B le
from the left edge will move to the right edge of the previous row.
This is useful for drawing a box around the edge of the screen,
for example.
If the terminal has switch-selectable automatic margins,
the
.B termcap\^
description usually assumes that this feature is on,
.IR i.e. ,
.BR am .
If the terminal has a command
that moves to the first column of the next line,
that command can be given as
.B nw
(newline).
It is permissible for this to clear the remainder of the current line,
so if the terminal has no correctly-working \s-2CR\s0 and \s-2LF\s0
it may still be possible to craft a working
.B nw
out of one or both of them.
.PP
These capabilities suffice to describe hardcopy and \*(lqglass-tty\*(rq terminals.
Thus the Teletype model 33 is described as
.PP
.nf
T3\||\|tty33\||\|33\||\|tty\||\|Teletype model 33:\e
:bl=^G:co#72:cr=^M:do=^J:hc:os:
.fi
.PP
and the Lear Siegler \s-1ADM\s0\-3 is described as
.PP
.nf
l3\||\|adm3\||\|3\||\|LSI \s-1ADM\s0-3:\e
:am:bl=^G:cl=^Z:co#80:cr=^M:do=^J:le=^H:li#24:sf=^J:
.fi
.br
.ne 5
.PP
.B Parameterized Strings
.PP
Cursor addressing and other strings requiring parameters
are described by a
parameterized string capability, with
.BR printf\^ (3)-like
escapes
.B %x
in it,
while other characters are passed through unchanged.
For example, to address the cursor the
.B cm
capability is given, using two parameters: the row and column to move to.
(Rows and columns are numbered from zero and refer to the physical screen
visible to the user, not to any unseen memory.
If the terminal has memory-relative cursor addressing,
that can be indicated by an analogous
.B CM
capability.)
.PP
The
.B %
< D640 /div>
encodings have the following meanings:
.PP
.in +16n
.ta +8n
.ti -8n
%% output `%'
.ti -8n
%d output value as in \fBprintf\^\fP %d
.ti -8n
%2 output value as in \fBprintf\^\fP %2d
.ti -8n
%3 output value as in \fBprintf\^\fP %3d
.ti -8n
%. output value as in \fBprintf\^\fP %c
.ti -8n
%+\fIx\fP add \fIx\^\fP to value, then do %.
.ti -8n
%>\fIxy\fP if value > \fIx\^\fP then add \fIy\^\fP, no output
.ti -8n
%r reverse order of two parameters, no output
.ti -8n
%i increment by one, no output
.ti -8n
%n exclusive-or all parameters with 0140 (Datamedia 2500)
.ti -8n
%B BCD (16*(value/10)) + (value%10), no output
.ti -8n
%D Reverse coding (value \- 2*(value%16)), no output (Delta Data)
.ti -16n
.fi
.PP
Consider the Hewlett-Packard 2645, which, to get to row 3 and column 12, needs
to be sent \*(lq\eE&a12c03Y\*(rq padded for 6 milliseconds.
Note that the order
of the row and column coordinates is reversed here
and that the row and column
are sent as two-digit integers.
Thus its
.B cm
capability is \*(lqcm=6\eE&%r%2c%2Y\*(rq.
.PP
The Microterm
.SM ACT-IV
needs the current row and column sent
simply encoded in binary
preceded by a
.BR ^T ,
\*(lqcm=^T%.%.\*(rq.
Terminals that use \*(lq%.\*(rq need to be able to
backspace the cursor
.RB ( le )
and to move the cursor up one line on the screen
.RB ( up ).
This is necessary because it is not always safe to transmit
.BR \en ,
.BR ^D ,
and
.BR \er ,
as the system may change or discard them.
(Programs using
.B termcap\^
must set terminal modes so that tabs are not expanded, so
.B \et
is safe to send.
This turns out to be essential for the Ann Arbor 4080.)
.PP
A final example is the Lear Siegler \s-1ADM\s0\-3a,
which offsets row and column
by a blank character, thus \*(lqcm=\eE=%+ %+ \*(rq.
.PP
Row or column absolute cursor addressing
can be given as single parameter capabilities
.B ch
(horizontal position absolute) and
.B cv
(vertical position absolute).
Sometimes these are shorter than the more general two-parameter sequence
(as with the Hewlett-Packard 2645) and can be used in preference to
.BR cm .
If there are parameterized local motions
.RI ( e.g. ,
move
.I n\^
positions to the right)
these can be given as
.BR DO ,
.BR LE ,
.BR RI ,
and
.B UP
with a single parameter indicating how many positions to move.
These are primarily useful if the terminal does not have
.BR cm ,
such as the Tektronix 4025.
.br
.ne 5
.PP
.B Cursor Motions
.PP
If the terminal has a fast way to home the cursor
(to the very upper left corner of the screen), this can be given as
.BR ho .
Similarly, a fast way of getting to the lower left-hand corner
can be given as
.BR ll ;
this may involve going up with
.B up
from the home position,
but a program should never do this itself (unless
.B ll
does), because it can
make no assumption about the effect of moving up from the home position.
Note that the home position is the same as
cursor address (0,0): to the top left corner of the screen, not of memory.
(Therefore, the \*(lq\eEH\*(rq sequence on Hewlett-Packard terminals
cannot be used for
.BR ho .)
.br
.ne 5
.PP
.B Area Clears
.PP
If the terminal can clear from the current position to the end of the
line, leaving the cursor where it is, this should be given as
.BR ce .
If the terminal can clear from the current position to the end of the
display, this should be given as
.BR cd .
.B cd
must only be invoked from the first column of a line.
(Therefore,
it can be simulated by a request to delete a large number of lines,
if a true
.B cd
is not available.)
.br
.ne 5
.PP
.B Insert/Delete Line
.PP
If the terminal can open a new blank line
before the line containing the cursor,
this should be given as
.BR al ;
this must be invoked only from the first
position of a line.
The cursor must then appear at the left of the newly blank line.
If the terminal can delete the line that the cursor is on, this
should be given as
.BR dl ;
this must only be used from the first position on
the line to be deleted.
Versions of
.B al
and
.B dl
which take a single parameter
and insert or delete that many lines
can be given as
.B AL
and
.BR DL .
If the terminal has a settable scrolling region
(like the VT100),
the command to set this can be described with the
.B cs
capability,
which takes two parameters: the top and bottom lines of the scrolling region.
The cursor position is, alas, undefined after using this command.
It is possible to get the effect of insert or delete line
using this command \(em the
.B sc
and
0