📄 termcap.5
字号:
ul bool Underline character overstrikes
UP str (NP*) Move cursor up n lines
up str Upline (cursor up)
us str Start underscore mode
vb str Visible bell (must not move cursor)
ve str Make cursor appear normal (undo vs/vi)
vi str Make cursor invisible
vs str Make cursor very visible
vt num Virtual terminal number (not supported on all systems)
wi str (N) Set current window
ws num Number of columns in status line
xb bool Beehive (f1=ESC, f2=^C)
xn bool Newline ignored after 80 cols (Concept)
xo bool Terminal uses xoff/xon (DC3/DC1) handshaking
xr bool (o) Return acts like ce cr nl (Delta Data)
xs bool Standout not erased by overwriting (Hewlett-Packard)
xt bool Tabs ruin, magic so char (Teleray 1061)
xx bool (o) Tektronix 4025 insert-line
A Sample Entry
The following entry, which describes the Concept-100, is among the more
complex entries in the termcap file as of this writing.
BSD 1 November 1985 5
TERMCAP(5) Minix Programmer's Manual TERMCAP(5)
ca|concept100|c100|concept|c104|concept100-4p|HDS Concept-100:\
:al=3*\E^R:am:bl=^G:cd=16*\E^C:ce=16\E^U:cl=2*^L:cm=\Ea%+ %+ :\
:co#80:.cr=9^M:db:dc=16\E^A:dl=3*\E^B:do=^J:ei=\E\200:eo:im=\E^P:in:\
:ip=16*:is=\EU\Ef\E7\E5\E8\El\ENH\EK\E\200\Eo&\200\Eo\47\E:k1=\E5:\
:k2=\E6:k3=\E7:kb=^h:kd=\E<:ke=\Ex:kh=\E?:kl=\E>:kr=\E=:ks=\EX:\
:ku=\E;:le=^H:li#24:mb=\EC:me=\EN\200:mh=\EE:mi:mk=\EH:mp=\EI:\
:mr=\ED:nd=\E=:pb#9600:rp=0.2*\Er%.%+ :se=\Ed\Ee:sf=^J:so=\EE\ED:\
:.ta=8\t:te=\Ev \200\200\200\200\200\200\Ep\r\n:\
:ti=\EU\Ev 8p\Ep\r:ue=\Eg:ul:up=\E;:us=\EG:\
:vb=\Ek\200\200\200\200\200\200\200\200\200\200\200\200\200\200\EK:\
:ve=\Ew:vs=\EW:vt#8:xn:\
:bs:cr=^M:dC#9:dT#8:nl=^J:ta=^I:pt:
Entries may continue onto multiple lines by giving a \ as the last
character of a line, and empty fields may be included for readability
(here between the last field on a line and the first field on the next).
Comments may be included on lines beginning with "#".
Types of Capabilities
Capabilities in termcap are of three types: Boolean capabilities, which
indicate particular features that the terminal has; numeric capabilities,
giving the size of the display or the size of other attributes; and
string capabilities, which give character sequences that can be used to
perform particular terminal operations. All capabilities have two-letter
codes. For instance, the fact that the Concept has automatic margins
(i.e., an automatic return and linefeed when the end of a line is
reached) is indicated by the Boolean capability am. Hence the
description of the Concept includes am.
Numeric capabilities are followed by the character `#' then the value.
In the example above co, which indicates the number of columns the
display has, gives the value `80' for the Concept.
Finally, string-valued capabilities, such as ce (clear-to-end-of-line
sequence) are given by the two-letter code, an `=', then a string ending
at the next following `:'. A delay in milliseconds may appear after the
`=' in such a capability, which causes padding characters to be supplied
by tputs after the remainder of the string is sent to provide this delay.
The delay can be either a number, e.g. `20', or a number followed by an
`*', i.e., `3*'. An `*' indicates that the padding required is
proportional to the number of lines affected by the operation, and the
amount given is the per-affected-line padding required. (In the case of
insert-character, the factor is still the number of lines affected; this
is always 1 unless the terminal has 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.)
BSD 1 November 1985 6
TERMCAP(5) Minix Programmer's Manual TERMCAP(5)
A number of escape sequences are provided in the string-valued
capabilities for easy encoding of control characters there. \E maps to
an ESC character, ^X maps to a control-X for any appropriate X, and the
sequences \n \r \t \b \f map to linefeed, return, tab, backspace, and
formfeed, respectively. Finally, characters may be given as three octal
digits after a \, and the characters ^ and \ may be given as \^ and \\.
If it is necessary to place a : in a capability it must be escaped in
octal as \072. If it is necessary to place a NUL character in a string
capability it must be encoded as \200. (The routines that deal with
termcap use C strings and strip the high bits of the output very late, so
that a \200 comes out as a \000 would.)
Sometimes individual capabilities must be commented out. To do this, put
a period before the capability name. For example, see the first cr and
ta in the example above.
Preparing Descriptions
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 termcap and to build up a
description gradually, using partial descriptions with vi to check that
they are correct. Be aware that a very unusual terminal may expose
deficiencies in the ability of the termcap file to describe it or bugs in
vi. To easily test a new terminal description you can set the
environment variable TERMCAP to the absolute pathname of a file
containing the description you are working on and programs will look
there rather than in /etc/termcap. TERMCAP can also be set to the
termcap entry itself to avoid reading the file when starting up a
program.
To get the padding for insert-line right (if the terminal manufacturer
did not document it), a severe test is to use vi to edit /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.
Basic Capabilities
The number of columns on each line of the display is given by the co
numeric capability. If the display is a CRT, then the number of lines on
the screen is given by the 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 am capability. If the terminal can clear its
screen, the code to do this is given by the cl string capability. If the
terminal overstrikes (rather than clearing the position when a character
is overwritten), it should have the os capability. If the terminal is a
printing terminal, with no soft copy unit, give it both hc and os. (os
applies to storage scope terminals, such as the Tektronix 4010 series, as
BSD 1 November 1985 7
TERMCAP(5) Minix Programmer's Manual TERMCAP(5)
well as to hard copy and APL terminals.) If there is a code to move the
cursor to the left edge of the current row, give this as cr. (Normally
this will be carriage-return, ^M.) If there is a code to produce an
audible signal (bell, beep, etc.), give this as bl.
If there is a code (such as backspace) to move the cursor one position to
the left, that capability should be given as le. Similarly, codes to
move to the right, up, and down should be given as nd, up, and do,
respectively. These local cursor motions should not alter the text they
pass over; for example, you would not normally use "nd= " unless the
terminal has the os capability, because the space would erase the
character moved over.
A very important point here is that the local cursor motions encoded in
termcap have undefined behavior at the left and top edges of a CRT
display. Programs should never attempt to backspace around the left
edge, unless bw is given, and never attempt to go up off the top using
local cursor motions.
In order to scroll text up, a program goes to the bottom left corner of
the screen and sends the sf (index) string. To scroll text down, a
program goes to the top left corner of the screen and sends the sr
(reverse index) string. The strings sf and sr have undefined behavior
when not on their respective corners of the screen. Parameterized
versions of the scrolling sequences are SF and SR, which have the same
semantics as sf and 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.
The 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 nd from the last column. Leftward local motion is defined from the
left edge only when bw is given; then an 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 termcap description usually assumes
that this feature is on, i.e., am. If the terminal has a command that
moves to the first column of the next line, that command can be given as
nw (newline). It is permissible for this to clear the remainder of the
current line, so if the terminal has no correctly-working CR and LF it
may still be possible to craft a working nw out of one or both of them.
These capabilities suffice to describe hardcopy and "glass-tty"
terminals. Thus the Teletype model 33 is described as
T3|tty33|33|tty|Teletype model 33:\
:bl=^G:co#72:cr=^M:do=^J:hc:os:
BSD 1 November 1985 8
TERMCAP(5) Minix Programmer's Manual TERMCAP(5)
and the Lear Siegler ADM-3 is described as
l3|adm3|3|LSI ADM-3:\
:am:bl=^G:cl=^Z:co#80:cr=^M:do=^J:le=^H:li#24:sf=^J:
Parameterized Strings
Cursor addressing and other strings requiring parameters are described by
a parameterized string capability, with printf(3)-like escapes %x in it,
while other characters are passed through unchanged. For example, to
address the cursor the 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 CM capability.)
The % encodings have the following meanings:
%% output `%'
%d output value as in printf %d
%2 output value as in printf %2d
%3 output value as in printf %3d
%. output value as in printf %c
%+x add x to value, then do %.
%>xy if value > x then add y, no output
%r reverse order of two parameters, no output
%i increment by one, no output
%n exclusive-or all parameters with 0140 (Datamedia 2500)
%B BCD (16*(value/10)) + (value%10), no output
%D Reverse coding (value - 2*(value%16)), no output (Delta
Data)
Consider the Hewlett-Packard 2645, which, to get to row 3 and column 12,
needs to be sent "\E&a12c03Y" 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 cm capability is
"cm=6\E&%r%2c%2Y".
The Microterm ACT-IV needs the current row and column sent simply encoded
in binary preceded by a ^T, "cm=^T%.%.". Terminals that use "%." need to
be able to backspace the cursor (le) and to move the cursor up one line
on the screen (up). This is necessary because it is not always safe to
transmit \n, ^D, and \r, as the system may change or discard them.
(Programs using termcap must set terminal modes so that tabs are not
expanded, so \t is safe to send. This turns out to be essential for the
Ann Arbor 4080.)
A final example is the Lear Siegler ADM-3a, which offsets row and column
by a blank character, thus "cm=\E=%+ %+ ".
BSD 1 November 1985 9
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -