termcap Technical Information termcap
Terminal description language
termcap is a language for describing terminals and their
capabilities. Terminal descriptions are collected in the file
/etc/termcap and are read by tgetent and its related programs to
ensure that output to a particular terminal is in a format that
that terminal can understand.
A terminal description written in termcap consists of a series of
fields, which are separated from each other by colons `:'. Every
line in the description, with the exception of the last line,
must end in a backslash `\'. Tab characters are ignored. Lines
that begin with a `#' are comments. A termcap description must
not exceed 1,024 characters.
The first field names the terminal. Several different names may
be used, each separated by a vertical bar `|'; each name given,
however, must be unique within the file /etc/termcap. By conven-
tion, the first listed must be two characters long. The second
name is the name by which the terminal is most commonly known;
this name may contain no blanks in it. Other versions of the
name may follow. By convention, the last version is the full
name of the terminal; here, spaces may be used for legibility.
Any of these may be used to name your terminal to the COHERENT
system. For example, the name field for the VT-100 terminal is
as follows:
d1|vt100|vt-100|pt100|pt-100|dec vt100:\
Note that the names are separated by vertical bars `|', that the
field ends with a colon, and that the line ends with a backslash.
Using any of these names in an export command will make the cor-
rect terminal description available to programs that need to use
it.
The remaining fields in the entry describe the capabilities of
the terminal. Each capability field consists of a two-letter
code, and may include additional information. There are three
types of capability:
Boolean
This indicates whether or not a terminal has a specific fea-
ture. If the field is present, the terminal is assumed to
have the feature; if it is absend, the terminal is assumed
not to have that feature. For example, the field
am:
is present, termcap assumes that the terminal has automatic
margins, whereas if that field is not present, the program
using termcap assumes that the terminal does not have them.
COHERENT Lexicon Page 1
termcap Technical Information termcap
Numeric
This gives the size of some aspect of the terminal. Numeric
capability fields have the capability code, followed by a
`#' and a number. For example, the entry
co#80:
means that the terminal screen is 80 columns wide.
String capabilities
These give a sequence of characters that trigger a terminal
operation. These fields consist of the capability code, an
equal sign `=', and the string.
Strings often include escape sequences. A ``\E'' indicates
an <ESC> character; a control character is indicated with a
carat `^' plus the appropriate letter; and the sequences \b,
\f, \n, \r, and \t are, respectively, backspace, formfeed,
newline, <return>, and tab.
An integer or an integer followed by an asterisk in the
string (e.g., `int*') indicates that execution of the func-
tion should be delayed by int milliseconds; this delay is
termed padding. Thus, deletion on lines on the Microterm
Mime-2A is coded as:
dl=20*^W:
dl is the capability code for delete, the equal sign intro-
duces the deletion sequence, 20* indicates that each line
deletion should be delayed by 20 milliseconds, and ^W in-
dicates that the line-deletion code on the Mime-2A is <ctrl-
W>.
The asterisk indicates that the padding required is propor-
tional to the number of lines affected by the operation. In
the above example, the deletion of four lines on the Mime-2A
generates a total of 80 milliseconds of padding; if no as-
terisk were present, however, the padding would be only 20
milliseconds, no matter how many lines were deleted. Also,
when an asterisk is used, the number may be given to one
decimal place, to show tenths of a millisecond of padding.
Note that with string capabilities, characters may be given
as a backslash followed by the three octal digits of the
character's ASCII code. Thus, a colon in a capability field
may be given by \072. To put a null character into the
string, use \200, because termcap strips the high bit from
each character.
Finally, the literal characters `^' and `\' are given by
``\^'' and ``\\''.
COHERENT Lexicon Page 2
termcap Technical Information termcap
***** Capability Codes *****
The following table lists termcap's capability codes. Type in-
dicates whether the code is boolean, numeric, or string; an am-
persand `&' indicates that this capability may include padding,
and an ampersand plus an asterisk ``&*'' indicates that it may be
used with the asterisk padding function described above.
Name Type Definition
ae string& End alternate set of characters
al string&* Add blank line
am boolean Automatic margins
as string& Start alternate set of characters
bc string Backspace character, if not ^H
bs boolean Backspace character is ^H
bt string& Backtab
bw boolean Backspace wraps from column 0
to last column
CC string Command character in prototype
if it can be set at terminal
cd string&* Clear to end of display
ce string& Clear line
ch string& Horizontal cursor motion
cl string&* Clear screen
cm string& Cursor motion, both vertical and
horizontal
co number& Number of columns
cr string&* <return>; default ^M
cs string& Change scrolling region (DEC
VT100 only); resembles cm
cv string& Vertical cursor motion
da boolean& Display above may be retained
dB number Milliseconds of delay needed by bs
db boolean Display below may be retained
dC number Milliseconds of delay needed by cr
dc string&* Delete a character
dF number Milliseconds of delay needed byff
dl string&* Delete a line
dm string Enter delete mode
dN number Milliseconds of delay needed by nl
do string Move down one line
dT number Milliseconds of delay needed by tab
ed string Leave delete mode
ei string Leave insert mode; use :ei=:
if this string is the same as ic
eo string Erase overstrikes with a blank
ff string&* Eject hardcopy terminal page;
default ^L
hc boolean Hardcopy terminal
hd string Move half-line down, i.e., forward
1/2 line feed)
ho string Move cursor to home position; use
if cm is not set
hu string Move half-line up, i.e., reverse
COHERENT Lexicon Page 3
termcap Technical Information termcap
1/2 line feed
hz string Cannot print tilde `~' (Hazeltine
terminals only)
ic string& Insert a character
if string Name of the file that contains is
im string Begin insert mode; use :im=:
if ic has not been set
in boolean Nulls are distinguished in display
ip string&* Insert padding after each
character listed
is string Initialize terminal
k0-k9 string Codes sent by function keys 0-9
kb string Code sent by backspace key
kd string Code sent by down-arrow key
ke string Leave ``keypad transmit'' mode
kh string Code sent by home key
kl string Code sent by left-arrow key
kn number No. of function keys; default is 10
ko string Entries for for all other
non-function keys
kr string Code sent by right-arrow key
ks string Begin ``keypad transmit'' mode
ku string Code sent by up-arrow key
l0-l9 string Function keys labels if not f0-f9
li number Number of lines
ll string Move cursor to first column of
last line; use if cm is not set
mi boolean Cursor may be safely moved while
in insert mode
ml string Turn on memory lock for area of
screen above cursor
ms boolean Cursor may be safely moved while
in standout or underline mode
mu string Turn off memory lock
nc boolean <return> does not work
nd string Move cursor right non-destructively
nl string&* Newline character; default is \n. Obsolete
ns boolean Terminal is CRT, but does not scroll
os boolean Terminal can overstrike
pc string Pad character any character other than null
pt boolean Terminal's tabs set by hardware;
may need to be set with is
se string Exit standout mode
sf string& Scroll forward
sg number Blank characters left by so or se
so string Enter standout mode
sr string& Reverse scroll
ta string& Tab character other than ^I,
or used with character padding
tc string Similar terminal--must be
last field in entry
te string End a program that uses cm
ti string Begin a program that uses cm
uc string Underscore character and skip it
ue string Leave underscore mode
COHERENT Lexicon Page 4
termcap Technical Information termcap
ug number Blank characters left by us or ue
ul boolean Terminal underlines but does not overstrike
up string Move up one line
us string Begin underscore mode
vb string Visible bell; may not move cursor
ve string Exit open/visual mode
vs string Begin open/visual mode
xb boolean Beehive terminal (f1=<esc>,
f2=<crtl-C>)
xn boolean Newline is ignored after wrap
xr boolean <return> behaves like ce \r \n
xs boolean Standout mode is not erased by writing over it
xt boolean Tabs are destructive
The following is the termcap description of the Zenith Z-19 ter-
minal. The meaning of each field will be described:
kb|h19|heath|h19b|heathkit|heath-19|z19|zenith|heathkit h19:\
:al=1*\EL:am:bs:cd=\EJ:ce=\EK:cl=\EE:cm=\EY%+ %+ :\
:co#80:dc=\EN:dl=1*\EM:do=\EB:ei=\EO:ho=\EH:\
:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms:pt:\
:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4:\
:kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH:kn#8:\
:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW:\
:l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER:
The first field, which occupies line 1, gives the various aliases
for this terminal. The Heathkit H-19, which appears most
prominently, was the home-kit version of the commercially sold Z-
19. The remaining fields mean the following:
:al=1*\EL: <esc>L adds new blank line; use
one millisecond for each line added
:am: Terminal has automatic margins
:bs: Backspace character is <ctrl>-H (the default)
:cd=\EJ: <esc>J clears to end of display
:ce=\EK: <esc>K clears to end of line
:cl=\EE: <esc>E clears screen
:cm=\EY%+ %+ :Cursor motion (described later)
:co#80: Screen has 80 columns
:dc=\EN:\ <esc>N deletes a character
(backslash indicates end of a line)
:dl=1*\EM: <esc>M deletes a line
:do=\EB: <esc>B moves cursor down one line
:ei=\EO: <esc>O exits from insert mode
:ho=\EH: <esc>H moves cursor to home position
:im=\E@: <esc>@ begins insert mode (note that
ic is set)
:li#24: Terminal has 24 lines
:mi: Cursor may be moved safely while terminal
is in insert mode
:nd=\EC: <esc>C moves cursor right non-destructively
:as=\EF: <esc>F begins set of alternate characters
COHERENT Lexicon Page 5
termcap Technical Information termcap
:ae=\EG:\ <esc>G ends set of alternate characters
:ms: Cursor may be moved safely while terminal
is in standout and underline mode
:pt: Terminal has hardware tabs
:sr=\EI: <esc>I reverse-scrolls the screen
:se=\Eq: <esc>q exits standout mode
:so=\Ep: <esc>p begins standout mode
:up=\EA: <esc>A moves the cursor up one line
:vs=\Ex4: <esc>x begins visual mode; insert
4 milliseconds of padding
when visual mode is begun
:ve=\Ey4:\ <esc>y ends visual mode; insert
4 milliseconds of padding when visual
mode is ended
:kb=^h: Backspace key sends <Ctrl>-H
:ku=\EA: Up-arrow key sends <esc>A
:kd=\EB: Down-arrow key sends <esc>B
:kl=\ED: Left-arrow key sends <esc>D
:kr=\EC: Right-arrow key sends <esc>C
:kh=\EH: Home key sends <esc>H
:kn#8:\ There are eight other keys on the
keyboard
:k1=\ES: Other key 1 sends <esc>S
:k2=\ET: Other key 2 sends <esc>T
:k3=\EU: Other key 3 sends <esc>U
:k4=\EV: Other key 4 sends <esc>V
:k5=\EW:\ Other key 5 sends <esc>W
:l6=blue: Other key 6 is labeled ``blue''
:l7=red: Other key 7 is labeled ``red''
:l8=white: Other key 8 is labeled ``white''
:k6=\EP: Other key 6 sends <esc>P
:k7=\EQ: Other key 7 sends <esc>Q
:k8=\ER: Other key 8 sends <esc>R
Note that the last field did not end with a backslash; this in-
dicated to the COHERENT system that the termcap description was
finished.
A terminal description does not have to be nearly so detailed.
If you wish to use a new terminal, first check the following
table to see if it already appears by termcap. If it does not,
check the terminal's documentation to see if it mimics a terminal
that is already in /etc/termcap, and use that description,
modifying it if necessary and changing the name to suit your ter-
minal. If you must create an entirely new description, first
prepare a skeleton file that contains the following basic
elements: number of lines, number of columns, backspace, cursor
motion, line delete, clear screen, move cursor to home position,
newline, move cursor up a line, and non-destructive right space.
For example, the following is the termcap description for the
Lear-Siegler ADM-3A terminal:
COHERENT Lexicon Page 6
termcap Technical Information termcap
la|adm3a|3a|lsi adm3a:\
:am:bs:cd=^W:ce=^X:cm=\E=%+ %+ :cl=^Z:co#80:ho=^^:li#24:\
:nd=^L:up=^K:
Once you have installed and debugged the skeleton description,
add details gradually until every feature of the terminal is
described.
***** Cursor Motion *****
The cursor motion characteristic contains printf-like escape se-
quences not used elsewhere. These encode the line and column
positions of the cursor, whereas other characters are passed un-
changed. If the cm string is considered as a function, then its
arguments are the line and the column to which the cursor is to
move; the % codes have the following meanings:
%d Decimal number, as in printf. The origin is 0.
%2 Two-digit decimal number. The same as %2d in printf.
%3 Three-digit decimal number. The same as %3d in printf.
%. Single byte. The same as %c in printf.
%+n Add n to the current position value. n may be either a num-
ber or a character.
%>nm If the current position value is greater than n+m; then
there is no output.
%r Reverse order of line and column, giving column first and
then line. No output.
%i Increment line and column.
%% Give a % sign in the string.
%n Exclusive or line and column with 0140 (Datamedia 2500 ter-
minal only).
%B Binary coded decimal (16 * (n/10))+(n%10). No output.
%D Reverse coding (n-(2*(n%16)). No output (Delta Data ter-
minal only).
To send the cursor to line 3, column 12 on the Hewlett-Packard
2645, the terminal must be sent <esc>&a12c03Y padded for 6
milliseconds. Note that the column is given first and then the
line, and that the line and column are given as two digits each.
Thus, the cm capability for the Hewlett-Packard 2645 is given by:
COHERENT Lexicon Page 7
termcap Technical Information termcap
:cm=6\E&%r%2c%2Y:
The Microterm ACT-IV needs the current position sent preceded by
a <Ctrl-T>, with the line and column encoded in binary:
:cm=^T%.%.:
Terminals that use %. must be able to backspace the cursor (bs or
bc) and to move the cursor up one line on the screen (up). This
is because transmitting \t, \n, \r, or <ctrl-D> may have undesir-
able consequences or be ignored by the system.
***** Similar Terminals *****
If your system uses two similar terminals, one can be defined as
resembling the other, with certain exceptions. The code tc names
the similar terminal. This field must be last in the termcap
entry, and the combined length of the two entries cannot exceed
1,024 characters. Capabilities given first over-ride those in
the similar terminal, and capabilities in the similar terminal
can be cancelled by xx@ where xx is the capability. For example,
the entry
hn|2621nl|HP 2621nl:ks@:ke@:tc=2621
defines a Hewlett-Packard 2621 terminal that does not have the ks
and ke capabilities, and thus cannot turn on the function keys
when in visual mode.
***** Initialization *****
A terminal initialization string may be given with the is
capability; if the string is too long, it may be read from a file
given by the if code. Usually, these strings set the tabs on a
terminal with settable tabs. If both is and if are given, is
will be printed first to clear the tabs, then the tabs will be
set from the file specified by if. The Hewlett-Packard 2626 has:
:is=\E&j@\r\E3\r:if=/usr/lib/tabset/stdcrt:
***** Terminals Supported *****
The following table lists the terminals described in
/etc/termcap, and an abbreviated name for each.
Name Terminal
act5 Microterm Act V
COHERENT Lexicon Page 8
termcap Technical Information termcap
adm3a Lear-Siegler ADM3A
adm31 Lear-Siegler ADM31
ansipc AT COHERENT console
cohibm PC COHERENT console
dos DOS 3.1 ANSI.SIS
h1510 Hazeltine 1510
h19 Heathkit H-19
h19a Heathkit H-19 in ANSI
mime1 Microterm Mime1
mime2a Microterm Mime2a
mime3a Microterm Mime3a
qvt102 Qume QVT-102
qume5 Qume Sprint 5
tvi912 Televideo 920
tvi920 Televideo 920
tvi925 Televideo 925
vt52 DEC VT-52
vt100 DEC VT-100
vt100n DEC VT-100 without initialization
vt100s DEC VT-100, 132 columns, 14 lines
vt100w DEC VT-100, 132 columns, 24 lines
wy50 Wyse 50
***** Files *****
/etc/termcap
***** See Also *****
modemcap, technical information, terminal-independent operations
COHERENT Lexicon Page 9