Terminfo
is a data base describing terminals, used by screen-oriented programs such as
nvi(1),
rogue(1)
and libraries such as
curses(3X).
Terminfo
describes terminals by giving a set of capabilities which they
have, by specifying how to perform screen operations, and by
specifying padding requirements and initialization sequences.
Entries in
terminfo
consist of a sequence of `,' separated fields (embedded commas may be
escaped with a backslash or notated as \072).
White space after the `,' separator is ignored.
The first entry for each terminal gives the names which are known for the
terminal, separated by `|' characters.
The first name given is the most common abbreviation for the terminal,
the last name given should be a long name fully identifying the terminal,
and all others are understood as synonyms for the terminal name.
All names but the last should be in lower case and contain no blanks;
the last name may well contain upper case and blanks for readability.
Terminal names (except for the last, verbose entry) should
be chosen using the following conventions.
The particular piece of hardware making up the terminal should
have a root name, thus ``hp2621''.
This name should not contain hyphens.
Modes that the hardware can be in, or user preferences, should
be indicated by appending a hyphen and a mode suffix.
Thus, a vt100 in 132 column mode would be vt100-w.
The following suffixes should be used where possible:
Suffix
Meaning
Example
-nn
Number of lines on the screen
aaa-60
-np
Number of pages of memory
c100-4p
-am
With automargins (usually the default)
vt100-am
-m
Mono mode; suppress color
ansi-m
-mc
Magic cookie; spaces when highlighting
wy30-mc
-na
No arrow keys (leave them in local)
c100-na
-nam
Without automatic margins
vt100-nam
-nl
No status line
att4415-nl
-ns
No status line
hp2626-ns
-rv
Reverse video
c100-rv
-s
Enable status line
vt100-s
-vb
Use visible bell instead of beep
wy370-vb
-w
Wide mode (> 80 columns, usually 132)
vt100-w
For more on terminal naming conventions, see the term(7) manual page.
Capabilities
The following is a complete table of the capabilities included in a
terminfo description block and available to terminfo-using code. In each
line of the table,
The variable is the name by which the programmer (at the terminfo level)
accesses the capability.
The capname is the short name used in the text of the database,
and is used by a person updating the database.
Whenever possible, capnames are chosen to be the same as or similar to
the ANSI X3.64-1979 standard (now superseded by ECMA-48, which uses
identical or very similar names). Semantics are also intended to match
those of the specification.
The termcap code is the old
termcap
capability name (some capabilities are new, and have names which termcap
did not originate).
Capability names have no hard length limit, but an informal limit of 5
characters has been adopted to keep them short and to allow the tabs in
the source file
Caps
to line up nicely.
Finally, the description field attempts to convey the semantics of the
capability. You may find some codes in the description field:
(P)
indicates that padding may be specified
#[1-9]
in the description field indicates that the string is passed through tparm with
parms as given (#i).
(P*)
indicates that padding may vary in proportion to the number of
lines affected
(#i)
indicates the ith parameter.
These are the boolean capabilities:
T}
has_print_wheel
daisy
YC
printer needs operator to change character set
has_status_line
hs
hs
has extra status line
hue_lightness_saturation
hls
hl
terminal uses only HLS color notation (Tektronix)
insert_null_glitch
in
in
insert mode distinguishes nulls
lpi_changes_res
YG
changing line pitch changes resolution
memory_above
da
da
display may be retained above the screen
memory_below
move_insert_mode
mi
move_standout_mode
msgr
ms
safe to move while in standout mode
needs_xon_xoff
no_esc_ctlc
xsb
beehive (f1=escape, f2=ctrl C)
npc
NP
pad character does not exist
non_dest_scroll_region
non_rev_rmcup
nrrmc
NR
over_strike
os
os
terminal can overstrike
prtr_silent
row_addr_glitch
xvpa
only positive motion for vpa/mvpa caps
sam
YE
printing in last column causes cr
status_line_esc_ok
tilde_glitch
hz
cannot print ~'s (hazeltine)
transparent_underline
ul
ul
underline character overstrikes
xon_xoff
These are the numeric capabilities:
T}
magic_cookie_glitch
xmc
sg
number of blank characters left by smso or rmso
max_attributes
ma
ma
maximum combined attributes terminal can handle
max_colors
colors
Co
maximum number of colors on screen
max_pairs
pairs
pa
maximum number of color-pairs on the screen
maximum_windows
wnum
MW
maximum number of defineable windows
no_color_video
ncv
NC
video attributes that cannot be used with colors
num_labels
padding_baud_rate
pb
virtual_terminal
vt
vt
virtual terminal number (CB/unix)
width_status_line
The following numeric capabilities are present in the SVr4.0 term structure,
but are not yet documented in the man page. They came in with SVr4's
printer support.
T}
max_micro_jump
mjump
Ye
maximum value in parm_..._micro
micro_col_size
mcs
Yf
character step size when in micro mode
micro_line_size
mls
Yg
line step size when in micro mode
number_of_pins
npins
Yh
numbers of pins in print-head
orc
horizontal resolution in units per line
output_res_horz_inch
orhi
Yk
horizontal resolution in units per inch
orl
output_res_vert_inch
print_rate
wide_char_size
Yn
character step size when in double wide mode
These are the string capabilities:
T}
set_left_margin_parm
smglp
Zm
Set left (right) margin at column #1
set_right_margin
smgr
MR
set right soft margin at current column
set_right_margin_parm
smgrp
Zn
Set right margin at column #1
set_tab
hts
st
set a tab in every row, current columns
set_top_margin
smgt
Set top margin at current line
set_top_margin_parm
smgtp
Zp
Set top (bottom) margin at row #1
set_window
wind
start_bit_image
start_char_set_def
scsd
Start character set definition #1, with #2 characters in the set
stop_bit_image
rbim
Zs
stop_char_set_def
subscript_characters
subcs
Zu
List of subscriptable characters
superscript_characters
supcs
Zv
List of superscriptable characters
tab
these_cause_cr
docr
Zw
Printing any of these characters causes CR
to_status_line
tsl
ts
move to status line, column #1
tone
underline_char
uc
uc
up_half_line
hu
hu
half a line up
user0
user1
u1
u1
user2
u2
u2
User string #2
user3
user4
u4
u4
user5
u5
u5
User string #5
user6
user7
u7
u7
user8
u8
u8
User string #8
user9
wait_tone
wait
WA
xoff_character
xoffc
XF
XOFF character
xon_character
zero_motion
zerom
Zx
No motion for subsequent character
The following string capabilities are present in the SVr4.0 term structure,
but were originally not documented in the man page.
T}
key_mouse
kmous
Km
Mouse event has occurred
mouse_info
minfo
Mi
Mouse status information
pc_term_options
pctrm
S6
PC terminal options
pkey_plab
pfxl
xl
Program function key #1 to type string #2 and show string #3
req_mouse_pos
reqmp
Request mouse position
scancode_escape
scesc
S7
Escape for scancode emulation
set0_des_seq
s1ds
Shift to code set 1
set2_des_seq
s2ds
s2
Shift to code set 2
s3ds
Shift to code set 3
set_a_background
setab
AB
set_a_foreground
setcolor
Change to ribbon color #1
set_lr_margin
smglr
ML
Set both left and right margins to #1, #2. (ML is not in BSD termcap).
set_page_length
set_tb_margin
smgtb
MT
The XSI Curses standard added these. They are some post-4.1
versions of System V curses, e.g., Solaris 2.5 and IRIX 6.x.
The ncurses termcap names for them are invented; according to the
XSI Curses standard, they have no termcap names. If your compiled terminfo
entries use these, they may not be binary-compatible with System V terminfo
entries after SVr4.1; beware!
The following entry, describing an ANSI-standard terminal, is representative
of what a terminfo entry for a modern terminal typically looks like.
only those for which corresponding separate attribute commands exist.
For example, the DEC vt220 supports most of the modes:
center;
l c c
l c c
lw28 lw6 lw2 lw20.
tparm parameter
none
p1
p2
p3
p4
p5
p6
p7
p8
p9
We begin each escape sequence by turning off any existing modes, since
there is no quick way to determine whether they are active.
Standout is set up to be the combination of reverse and bold.
The vt220 terminal has a protect mode,
though it is not commonly used in sgr
because it protects characters on the screen from the host's erasures.
The altcharset mode also is different in that it is either ^O or ^N,
depending on whether it is off or on.
If all modes are turned on, the resulting sequence is \E[0;1;4;5;7;8m^N.
Some sequences are common to different modes.
For example, ;7 is output when either p1 or p3 is true, that is, if
either standout or reverse modes are turned on.
Writing out the above sequences, along with their dependencies yields
Putting this all together into the sgr sequence gives:
Remember that if you specify sgr, you must also specify sgr0.
Terminals with the ``magic cookie'' glitch
deposit special ``cookies'' when they receive mode-setting sequences,
which affect the display algorithm rather than having extra bits for
each character.
Some terminals, such as the HP 2621, automatically leave standout
mode when they move to a new line or the cursor is addressed.
Programs using standout mode should exit standout mode before
moving the cursor or sending a newline,
capability, asserting that it is safe to move in standout mode, is present.
If the terminal has
a way of flashing the screen to indicate an error quietly (a bell replacement)
then this can be given as flash; it must not move the cursor.
If the cursor needs to be made more visible than normal when it is
not on the bottom line (to make, for example, a non-blinking underline into an
easier to find block or blinking underline)
give this sequence as
If there is a way to make the cursor completely invisible, give that as
The capability
should be given which undoes the effects of both of these modes.
If your terminal correctly generates underlined characters
(with no special codes needed)
even though it does not overstrike,
then you should give the capability ul.
If a character overstriking another leaves both characters on the screen,
specify the capability os.
If overstrikes are erasable with a blank,
then this should be indicated by giving eo.
If the terminal has a keypad that transmits codes when the keys are pressed,
this information can be given.
Note that it is not possible to handle
terminals where the keypad only works in local (this applies, for example,
to the unshifted HP 2621 keys).
If the keypad can be set to transmit or not transmit,
give these codes as smkx and rmkx.
Otherwise the keypad is assumed to always transmit.
The codes sent by the left arrow, right arrow, up arrow, down arrow,
and home keys can be given as
kcub1, kcuf1, kcuu1, kcud1, and khome respectively.
If there are function keys such as f0, f1, ..., f10, the codes they send
can be given as kf0, kf1, ..., kf10.
If these keys have labels other than the default f0 through f10, the labels
can be given as lf0, lf1, ..., lf10.
The codes transmitted by certain other special keys can be given:
(home down),
(backspace),
(clear all tabs),
(clear the tab stop in this column),
(clear screen or erase key),
(delete character),
(delete line),
(exit insert mode),
(clear to end of line),
(clear to end of screen),
(insert character or enter insert mode),
(insert line),
(next page),
(previous page),
(scroll forward/down),
(scroll backward/up),
(set a tab stop in this column).
In addition, if the keypad has a 3 by 3 array of keys including the four
arrow keys, the other five keys can be given as
and
These keys are useful when the effects of a 3 by 3 directional pad are needed.
Strings to program function keys can be given as
and
A string to program screen labels should be specified as pln.
Each of these strings takes two parameters: the function key number to
program (from 0 to 10) and the string to program it with.
Function key numbers out of this range may program undefined keys in
a terminal dependent manner.
The difference between the capabilities is that
causes pressing the given key to be the same as the user typing the
given string;
causes the string to be executed by the terminal in local; and
causes the string to be transmitted to the computer.
The capabilities nlab, lw and lh
define the number of programmable
screen labels and their width and height.
If there are commands to turn the labels on and off,
give them in smln and rmln.
smln is normally output after one or more pln
sequences to make sure that the change becomes visible.
If the terminal has hardware tabs, the command to advance to the next
tab stop can be given as
(usually control I).
A ``back-tab'' command which moves leftward to the preceding tab stop can
be given as
By convention, if the teletype modes indicate that tabs are being
expanded by the computer rather than being sent to the terminal,
programs should not use
or
even if they are present, since the user may not have the tab stops
properly set.
If the terminal has hardware tabs which are initially set every
spaces when the terminal is powered up,
the numeric parameter
is given, showing the number of spaces the tabs are set to.
This is normally used by the
command to determine whether to set the mode for hardware tab expansion,
and whether to set the tab stops.
If the terminal has tab stops that can be saved in non-volatile memory,
the terminfo description can assume that they are properly set.
Other capabilities
include
and
initialization strings for the terminal,
the path name of a program to be run to initialize the terminal,
and if, the name of a file containing long initialization strings.
These strings are expected to set the terminal into modes consistent
with the rest of the terminfo description.
They are normally sent to the terminal, by the
option of the
program, each time the user logs in.
They will be printed in the following order:
run the program
output
set the margins using
and
set tabs using
and
print the file
and finally
output
Most initialization is done with
Special terminal modes can be set up without duplicating strings
by putting the common sequences in
and special cases in
and
A pair of sequences that does a harder reset from a totally unknown state
can be analogously given as
and
analogous to
and
These strings are output by the
program, which is used when the terminal gets into a wedged state.
Commands are normally placed in
and
only if they produce annoying effects on the screen and are not
necessary when logging in.
For example, the command to set the vt100 into 80-column mode would
normally be part of
but it causes an annoying glitch of the screen and is not normally
needed since the terminal is usually already in 80 column mode.
If there are commands to set and clear tab stops, they can be given as
(clear all tab stops)
and
(set a tab stop in the current column of every row).
If a more complex sequence is needed to set the tabs than can be
described by this, the sequence can be placed in
or
Many older and slower terminals don't support either XON/XOFF or DTR
handshaking, including hard copy terminals and some very archaic CRTs
(including, for example, DEC VT100s).
These may require padding characters
after certain cursor motions and screen changes.
If the terminal uses xon/xoff handshaking for flow control (that is,
it automatically emits ^S back to the host when its input buffers are
close to full), set
This capability suppresses the emission of padding.
You can also set it
for memory-mapped console devices effectively that don't have a speed limit.
Padding information should still be included so that routines can
make better decisions about relative costs, but actual pad characters will
not be transmitted.
If pb (padding baud rate) is given, padding is suppressed at baud rates
below the value of pb.
If the entry has no padding baud rate, then
whether padding is emitted or not is completely controlled by xon.
If the terminal requires other than a null (zero) character as a pad,
then this can be given as pad.
Only the first character of the
string is used.
Some terminals have an extra `status line' which is not normally used by
software (and thus not counted in the terminal's lines capability).
The simplest case is a status line which is cursor-addressable but not
part of the main scrolling region on the screen; the Heathkit H19 has
a status line of this kind, as would a 24-line VT100 with a 23-line
scrolling region set up on initialization.
This situation is indicated
by the hs capability.
Some terminals with status lines need special sequences to access the
status line.
These may be expressed as a string with single parameter
tsl which takes the cursor to a given zero-origin column on the
status line.
The capability fsl must return to the main-screen
cursor positions before the last tsl.
You may need to embed the
string values of sc (save cursor) and rc (restore cursor)
in tsl and fsl to accomplish this.
The status line is normally assumed to be the same width as the width
of the terminal.
If this is untrue, you can specify it with the numeric
capability wsl.
A command to erase or blank the status line may be specified as dsl.
The boolean capability eslok specifies that escape sequences, tabs,
etc., work ordinarily in the status line.
The ncurses implementation does not yet use any of these capabilities.
They are documented here in case they ever become important.
Many terminals have alternate character sets useful for forms-drawing.
Terminfo and curses build in support for the drawing characters
supported by the VT100, with some characters from the AT&T 4410v1 added.
This alternate character set may be specified by the acsc capability.
center expand;
c l l c
c l l c
lw28 lw6 lw2 lw20.
Glyph
Name
UK pound sign
arrow pointing down
arrow pointing left
arrow pointing right
arrow pointing up
board of squares
bullet
checker board (stipple)
degree symbol
diamond
greater-than-or-equal-to
greek pi
horizontal line
lantern symbol
large plus or crossover
less-than-or-equal-to
lower left corner
lower right corner
not-equal
plus/minus
scan line 1
scan line 3
scan line 7
scan line 9
solid square block
tee pointing down
tee pointing left
tee pointing right
tee pointing up
upper left corner
upper right corner
vertical line
The best way to define a new device's graphics set is to add a column
to a copy of this table for your terminal, giving the character which
(when emitted between smacs/rmacs switches) will be rendered
as the corresponding graphic.
Then read off the VT100/your terminal
character pairs right to left in sequence; these become the ACSC string.
Color Handling
Most color terminals are either `Tektronix-like' or `HP-like'.
Tektronix-like
terminals have a predefined set of N colors (where N usually 8), and can set
character-cell foreground and background characters independently, mixing them
into N * N color-pairs.
On HP-like terminals, the use must set each color
pair up separately (foreground and background are not independently settable).
Up to M color-pairs may be set up from 2*M different colors.
ANSI-compatible
terminals are Tektronix-like.
Some basic color capabilities are independent of the color method.
The numeric
capabilities colors and pairs specify the maximum numbers of colors
and color-pairs that can be displayed simultaneously.
The op (original
pair) string resets foreground and background colors to their default values
for the terminal.
The oc string resets all colors or color-pairs to
their default values for the terminal.
Some terminals (including many PC
terminal emulators) erase screen areas with the current background color rather
than the power-up default background; these should have the boolean capability
bce.
To change the current foreground or background color on a Tektronix-type
terminal, use setaf (set ANSI foreground) and setab (set ANSI
background) or setf (set foreground) and setb (set background).
These take one parameter, the color number.
The SVr4 documentation describes
only setaf/setab; the XPG4 draft says that "If the terminal
supports ANSI escape sequences to set background and foreground, they should
be coded as setaf and setab, respectively.
If the terminal
supports other escape sequences to set background and foreground, they should
be coded as setf and setb, respectively.
The vidputs()
function and the refresh functions use setaf and setab if they are
defined."
The setaf/setab and setf/setb capabilities take a
single numeric argument each.
Argument values 0-7 are portably defined as
follows (the middle column is the symbolic #define available in the header for
the curses or ncurses libraries).
The terminal hardware is free to
map these as it likes, but the RGB values indicate normal locations in color
space.
Color
#define
Value
RGB
black
COLOR_BLACK
0
0, 0, 0
red
COLOR_RED
1
max,0,0
green
COLOR_GREEN
2
0,max,0
yellow
COLOR_YELLOW
3
max,max,0
blue
COLOR_BLUE
4
0,0,max
magenta
COLOR_MAGENTA
5
max,0,max
cyan
COLOR_CYAN
6
0,max,max
white
COLOR_WHITE
7
max,max,max
On an HP-like terminal, use scp with a color-pair number parameter to set
which color pair is current.
On a Tektronix-like terminal, the capability ccc may be present to
indicate that colors can be modified.
If so, the initc capability will
take a color number (0 to colors - 1)and three more parameters which
describe the color.
These three parameters default to being interpreted as RGB
(Red, Green, Blue) values.
If the boolean capability hls is present,
they are instead as HLS (Hue, Lightness, Saturation) indices.
The ranges are
terminal-dependent.
On an HP-like terminal, initp may give a capability for changing a
color-pair value.
It will take seven parameters; a color-pair number (0 to
max_pairs - 1), and two triples describing first background and then
foreground colors.
These parameters must be (Red, Green, Blue) or
(Hue, Lightness, Saturation) depending on hls.
On some color terminals, colors collide with highlights.
You can register
these collisions with the ncv capability.
This is a bit-mask of
attributes not to be used when colors are enabled.
The correspondence with the
attributes understood by curses is as follows:
For example, on many IBM PC consoles, the underline attribute collides with the
foreground color blue and is not available in color mode.
These should have
an ncv capability of 2.
SVr4 curses does nothing with ncv, ncurses recognizes it and optimizes
the output in favor of colors.
If the terminal requires other than a null (zero) character as a pad, then this
can be given as pad.
Only the first character of the pad string is used.
If the terminal does not have a pad character, specify npc.
Note that ncurses implements the termcap-compatible PC variable;
though the application may set this value to something other than
a null, ncurses will test npc first and use napms if the terminal
has no pad character.
If the terminal can move up or down half a line,
this can be indicated with
(half-line up)
and
(half-line down).
This is primarily useful for superscripts and subscripts on hard-copy terminals.
If a hard-copy terminal can eject to the next page (form feed), give this as
(usually control L).
If there is a command to repeat a given character a given number of
times (to save time transmitting a large number of identical characters)
this can be indicated with the parameterized string
The first parameter is the character to be repeated and the second
is the number of times to repeat it.
Thus, tparm(repeat_char, 'x', 10) is the same as `xxxxxxxxxx'.
If the terminal has a settable command character, such as the TEKTRONIX 4025,
this can be indicated with
A prototype command character is chosen which is used in all capabilities.
This character is given in the
capability to identify it.
The following convention is supported on some UNIX systems:
The environment is to be searched for a
variable, and if found, all
occurrences of the prototype character are replaced with the character
in the environment variable.
Terminal descriptions that do not represent a specific kind of known
terminal, such as
and
should include the
(generic) capability so that programs can complain that they do not know
how to talk to the terminal.
(This capability does not apply to
terminal descriptions for which the escape sequences are known.)
If the terminal has a ``meta key'' which acts as a shift key,
setting the 8th bit of any character transmitted, this fact can
be indicated with
Otherwise, software will assume that the 8th bit is parity and it
will usually be cleared.
If strings exist to turn this ``meta mode'' on and off, they
can be given as
and
If the terminal has more lines of memory than will fit on the screen
at once, the number of lines of memory can be indicated with
A value of
indicates that the number of lines is not fixed,
but that there is still more memory than fits on the screen.
If the terminal is one of those supported by the UNIX virtual
terminal protocol, the terminal number can be given as
Media copy
strings which control an auxiliary printer connected to the terminal
can be given as
print the contents of the screen,
turn off the printer, and
turn on the printer.
When the printer is on, all text sent to the terminal will be sent
to the printer.
It is undefined whether the text is also displayed on the terminal screen
when the printer is on.
A variation
takes one parameter, and leaves the printer on for as many characters
as the value of the parameter, then turns the printer off.
The parameter should not exceed 255.
All text, including
is transparently passed to the printer while an
is in effect.
Hazeltine terminals, which do not allow `~' characters to be displayed should
indicate hz.
Terminals which ignore a line-feed immediately after an am wrap,
such as the Concept and vt100,
should indicate xenl.
If
is required to get rid of standout
(instead of merely writing normal text on top of it),
xhp should be given.
Teleray terminals, where tabs turn all characters moved over to blanks,
should indicate xt (destructive tabs).
Note: the variable indicating this is now `dest_tabs_magic_smso'; in
older versions, it was teleray_glitch.
This glitch is also taken to mean that it is not possible to position
the cursor on top of a ``magic cookie'',
that to erase standout mode it is instead necessary to use
delete and insert line.
The ncurses implementation ignores this glitch.
The Beehive Superbee, which is unable to correctly transmit the escape
or control C characters, has
indicating that the f1 key is used for escape and f2 for control C.
(Only certain Superbees have this problem, depending on the ROM.)
Note that in older terminfo versions, this capability was called
`beehive_glitch'; it is now `no_esc_ctl_c'.
Other specific terminal problems may be corrected by adding more
capabilities of the form xx.
If there are two very similar terminals, one (the variant) can be defined as
being just like the other (the base) with certain exceptions.
In the
definition of the variant, the string capability use can be given with
the name of the base terminal.
The capabilities given before
override those in the base type named by
If there are multiple use capabilities, they are merged in reverse order.
That is, the rightmost use reference is processed first, then the one to
its left, and so forth.
Capabilities given explicitly in the entry override
those brought in by use references.
A capability can be canceled by placing xx@ to the left of the
use reference that imports it, where xx is the capability.
For example, the entry
defines a 2621-nl that does not have the smkx or rmkx capabilities,
and hence does not turn on the function key labels when in visual mode.
This is useful for different modes for a terminal, or for different
user preferences.
Long terminfo entries are unlikely to be a problem; to date, no entry has even
approached terminfo's 4K string-table maximum.
Unfortunately, the termcap
translations are much more strictly limited (to 1K), thus termcap translations
of long terminfo entries can cause problems.
The man pages for 4.3BSD and older versions of tgetent() instruct the user to
allocate a 1K buffer for the termcap entry.
The entry gets null-terminated by
the termcap library, so that makes the maximum safe length for a termcap entry
1k-1 (1023) bytes.
Depending on what the application and the termcap library
being used does, and where in the termcap file the terminal type that tgetent()
is searching for is, several bad things can happen.
Some termcap libraries print a warning message or exit if they find an
entry that's longer than 1023 bytes; others don't; others truncate the
entries to 1023 bytes.
Some application programs allocate more than
the recommended 1K for the termcap entry; others don't.
Each termcap entry has two important sizes associated with it: before
"tc" expansion, and after "tc" expansion.
"tc" is the capability that
tacks on another termcap entry to the end of the current one, to add
on its capabilities.
If a termcap entry doesn't use the "tc"
capability, then of course the two lengths are the same.
The "before tc expansion" length is the most important one, because it
affects more than just users of that particular terminal.
This is the
length of the entry as it exists in /etc/termcap, minus the
backslash-newline pairs, which tgetent() strips out while reading it.
Some termcap libraries strip off the final newline, too (GNU termcap does not).
Now suppose:
*
a termcap entry before expansion is more than 1023 bytes long,
*
and the application has only allocated a 1k buffer,
*
and the termcap library (like the one in BSD/OS 1.1 and GNU) reads
the whole entry into the buffer, no matter what its length, to see
if it's the entry it wants,
*
and tgetent() is searching for a terminal type that either is the
long entry, appears in the termcap file after the long entry, or
doesn't appear in the file at all (so that tgetent() has to search
the whole termcap file).
Then tgetent() will overwrite memory, perhaps its stack, and probably core dump
the program.
Programs like telnet are particularly vulnerable; modern telnets
pass along values like the terminal type automatically.
The results are almost
as undesirable with a termcap library, like SunOS 4.1.3 and Ultrix 4.4, that
prints warning messages when it reads an overly long termcap entry.
If a
termcap library truncates long entries, like OSF/1 3.0, it is immune to dying
here but will return incorrect data for the terminal.
The "after tc expansion" length will have a similar effect to the
above, but only for people who actually set TERM to that terminal
type, since tgetent() only does "tc" expansion once it's found the
terminal type it was looking for, not while searching.
In summary, a termcap entry that is longer than 1023 bytes can cause,
on various combinations of termcap libraries and applications, a core
dump, warnings, or incorrect operation.
If it's too long even before
"tc" expansion, it will have this effect even for users of some other
terminal types and users whose TERM variable does not have a termcap
entry.
When in -C (translate to termcap) mode, the ncurses implementation of
tic(1) issues warning messages when the pre-tc length of a termcap
translation is too long.
The -c (check) option also checks resolved (after tc
expansion) lengths.
It is not wise to count on portability of binary terminfo entries between
commercial UNIX versions.
The problem is that there are at least two versions
of terminfo (under HP-UX and AIX) which diverged from System V terminfo after
SVr1, and have added extension capabilities to the string table that (in the
binary format) collide with System V and XSI Curses extensions.
Some SVr4 curses implementations, and all previous to SVr4, don't
interpret the %A and %O operators in parameter strings.
SVr4/XPG4 do not specify whether msgr licenses movement while in
an alternate-character-set mode (such modes may, among other things, map
CR and NL to characters that don't trigger local motions).
The ncurses implementation ignores msgr in ALTCHARSET
mode.
This raises the possibility that an XPG4
implementation making the opposite interpretation may need terminfo
entries made for ncurses to have msgr turned off.
The ncurses library handles insert-character and insert-character modes
in a slightly non-standard way to get better update efficiency.
See
the Insert/Delete Character subsection above.
The parameter substitutions for set_clock and display_clock are
not documented in SVr4 or the XSI Curses standard.
They are deduced from the
documentation for the AT&T 505 terminal.
Be careful assigning the kmous capability.
The ncurses wants to
interpret it as KEY_MOUSE, for use by terminals and emulators like xterm
that can return mouse-tracking information in the keyboard-input stream.
Different commercial ports of terminfo and curses support different subsets of
the XSI Curses standard and (in some cases) different extension sets.
Here
is a summary, accurate as of October 1995:
SVR4, Solaris, ncurses --
These support all SVr4 capabilities.
SGI --
Supports the SVr4 set, adds one undocumented extended string
capability (set_pglen).
SVr1, Ultrix --
These support a restricted subset of terminfo capabilities.
The booleans
end with xon_xoff; the numerics with width_status_line; and the
strings with prtr_non.
HP/UX --
Supports the SVr1 subset, plus the SVr[234] numerics num_labels,
label_height, label_width, plus function keys 11 through 63, plus
plab_norm, label_on, and label_off, plus some incompatible
extensions in the string table.
AIX --
Supports the SVr1 subset, plus function keys 11 through 63, plus a number
of incompatible string table extensions.
OSF --
Supports both the SVr4 set and the AIX extensions.