user_caps(5) | File Formats Manual | user_caps(5) |
user_caps - user-defined terminfo capabilities
tic -x, infocmp -x
Before ncurses 5.0, terminfo databases used a fixed repertoire of terminal capabilities designed for the SVr2 terminal database in 1984, and extended in stages through SVr4 (1989), and standardized in the Single Unix Specification beginning in 1995.
Most of the extensions in this fixed repertoire were additions to the tables of boolean, numeric and string capabilities. Rather than change the meaning of an existing capability, a new name was added. The terminfo database uses a binary format; binary compatibility was ensured by using a header which gave the number of items in the tables for each type of capability. The standardization was incomplete:
During the 1990s, some users were reluctant to use terminfo in spite of its performance advantages over termcap:
Although termcap's extensibility was rarely used (it was never the speaker who had actually used the feature), the criticism had a point. ncurses 5.0 provided a way to detect nonstandard capabilities, determine their type and optionally store and retrieve them in a way which did not interfere with other applications. These are referred to as user-defined capabilities because no modifications to the toolset's predefined capability names are needed.
The ncurses utilities tic and infocmp have a command-line option “-x” to control whether the nonstandard capabilities are stored or retrieved. A library function use_extended_names is provided for the same purpose.
When compiling a terminal database, if “-x” is set, tic will store a user-defined capability if the capability name is not one of the predefined names.
Because ncurses provides a termcap library interface, these user-defined capabilities may be visible to termcap applications:
The ncurses library uses the user-definable capabilities. While the terminfo database may have other extensions, ncurses makes explicit checks for these:
Several terminals provide the ability to send distinct strings for combinations of modified special keys. There is no standard for what those keys can send.
Since 1999, xterm has supported shift, control, alt, and meta modifiers which produce distinct special-key strings. In a terminal description, ncurses has no special knowledge of the modifiers used. Applications can use the naming convention established for xterm to find these special keys in the terminal description.
Starting with the curses convention that key names begin with “k” and that shifted special keys are an uppercase name, ncurses' terminal database defines these names to which a suffix is added:
Name | Description |
kDC | special form of kdch1 (delete character) |
kDN | special form of kcud1 (cursor down) |
kEND | special form of kend (End) |
kHOM | special form of khome (Home) |
kLFT | special form of kcub1 (cursor-left or cursor-back) |
kNXT | special form of knext (Next, or Page-Down) |
kPRV | special form of kprev (Prev, or Page-Up) |
kRIT | special form of kcuf1 (cursor-right, or cursor-forward) |
kUP | special form of kcuu1 (cursor-up) |
These are the suffixes used to denote the modifiers:
Value | Description |
2 | Shift |
3 | Alt |
4 | Shift + Alt |
5 | Control |
6 | Shift + Control |
7 | Alt + Control |
8 | Shift + Alt + Control |
9 | Meta |
10 | Meta + Shift |
11 | Meta + Alt |
12 | Meta + Alt + Shift |
13 | Meta + Ctrl |
14 | Meta + Ctrl + Shift |
15 | Meta + Ctrl + Alt |
16 | Meta + Ctrl + Alt + Shift |
None of these are predefined; terminal descriptions can refer to names which ncurses will allocate at runtime to key-codes. To use these keys in an ncurses program, an application could do this:
The “-x” extension feature of tic and infocmp has been adopted in NetBSD curses. That implementation stores user-defined capabilities, but makes no use of these capabilities itself.
Thomas E. Dickey
beginning with ncurses 5.0 (1999)