1 .\"***************************************************************************
2 .\" Copyright (c) 2017 Free Software Foundation, Inc. *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a *
5 .\" copy of this software and associated documentation files (the *
6 .\" "Software"), to deal in the Software without restriction, including *
7 .\" without limitation the rights to use, copy, modify, merge, publish, *
8 .\" distribute, distribute with modifications, sublicense, and/or sell *
9 .\" copies of the Software, and to permit persons to whom the Software is *
10 .\" furnished to do so, subject to the following conditions: *
12 .\" The above copyright notice and this permission notice shall be included *
13 .\" in all copies or substantial portions of the Software. *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 .\" Except as contained in this notice, the name(s) of the above copyright *
24 .\" holders shall not be used in advertising or otherwise to promote the *
25 .\" sale, use or other dealings in this Software without prior written *
27 .\"***************************************************************************
29 .\" $Id: user_caps.5,v 1.2 2017/09/04 19:27:24 tom Exp $
53 user_caps \- user-defined terminfo capabilities
60 terminfo databases used a \fIfixed repertoire\fP of terminal
61 capabilities designed for the SVr2 terminal database in 1984,
62 and extended in stages through SVr4 (1989),
63 and standardized in the Single Unix Specification beginning in 1995.
65 Most of the \fIextensions\fP in this fixed repertoire were additions
66 to the tables of boolean, numeric and string capabilities.
67 Rather than change the meaning of an existing capability, a new name was added.
68 The terminfo database uses a binary format; binary compatibility was
69 ensured by using a header which gave the number of items in the
70 tables for each type of capability.
71 The standardization was incomplete:
73 The \fIbinary format\fP itself is not described
74 in the X/Open Curses documentation.
75 Only the \fIsource format\fP is described.
77 Library developers rely upon the SVr4 documentation,
78 and reverse-engineering the compiled terminfo files to match the binary format.
80 Lacking a standard for the binary format, most implementations
81 copy the SVr2 binary format, which uses 16-bit signed integers,
82 and is limited to 4096-byte entries.
84 The format cannot represent very large numeric capabilities,
85 nor can it represent large numbers of special keyboard definitions.
87 The tables of capability names differ between implementations.
89 Although they \fImay\fP provide all of the standard capability names,
90 the position in the tables differs because some features were added as needed,
91 while others were added (out of order) to comply with X/Open Curses.
93 While ncurses' repertoire of predefined capabilities is closest to Solaris,
94 Solaris's terminfo database has a few differences from
95 the list published by X/Open Curses.
97 During the 1990s, some users were reluctant to use terminfo
98 in spite of its performance advantages over termcap:
100 The fixed repertoire prevented users from adding features
101 for unanticipated terminal improvements
102 (or required them to reuse existing capabilities as a workaround).
104 The limitation to 16-bit signed integers was also mentioned.
105 Because termcap stores everything as a string,
106 it could represent larger numbers.
108 Although termcap's extensibility was rarely used
109 (it was never the \fIspeaker\fP who had actually used the feature),
110 the criticism had a point.
111 ncurses 5.0 provided a way to detect nonstandard capabilities,
113 type and optionally store and retrieve them in a way which did not interfere
114 with other applications.
115 These are referred to as \fIuser-defined capabilities\fP because no
116 modifications to the toolset's predefined capability names are needed.
118 The ncurses utilities \fBtic\fP and \fBinfocmp\fP have a command-line
119 option \*(``\-x\*('' to control whether the nonstandard capabilities
120 are stored or retrieved. A library function \fBuse_extended_names\fP
121 is provided for the same purpose.
123 When compiling a terminal database, if \*(``\-x\*('' is set,
124 \fBtic\fP will store a user-defined capability if the capability name is not
125 one of the predefined names.
127 Because ncurses provides a termcap library interface,
128 these user-defined capabilities may be visible to termcap applications:
130 The termcap interface (like all implementations of termcap)
131 requires that the capability names are 2-characters.
133 When the capability is simple enough for use in a termcap application,
134 it is provided as a 2-character name.
137 user-defined capabilities which refer to features not usable in termcap,
138 e.g., parameterized strings that use more than two parameters
139 or use more than the trivial expression support provided by termcap.
140 For these, the terminfo database should have only capability names with
141 3 or more characters.
143 Some terminals can send distinct strings for special keys (cursor-,
144 keypad- or function-keys) depending on modifier keys (shift, control, etc.).
145 While terminfo and termcap have a set of 60 predefined function-key names,
146 to which a series of keys can be assigned,
147 that is insufficient for more than a dozen keys multiplied by more than
148 a couple of modifier combinations.
149 The ncurses database uses a convention based on \fBxterm\fP to
150 provide extended special-key names.
152 Fitting that into termcap's limitation of 2-character names
154 These extended keys are available only with terminfo.
155 .SS Recognized capabilities
157 The ncurses library uses the user-definable capabilities.
158 While the terminfo database may have other extensions,
159 ncurses makes explicit checks for these:
163 \fIboolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
164 by resetting the foreground and background color, respectively, to the default.
166 This is a feature recognized by the \fBscreen\fP program as well.
169 \fIstring\fP, tells how to clear the terminal's scrollback buffer.
170 When present, the \fBclear\fP(1) program sends this before clearing
173 The command \*(``\fBtput clear\fP\*('' does the same thing.
176 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
178 \fBset_a_foreground\fP and
179 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
180 using an RGB (red/green/blue) convention.
181 This capability allows the \fBcolor_content\fP function to
182 return appropriate values without requiring the application
183 to initialize colors using \fBinit_color\fP.
185 The capability type determines the values which ncurses sees:
189 implies that the number of bits for red, green and blue are the same.
190 Using the maximum number of colors,
191 ncurses adds two, divides that sum by three, and assigns the result
192 to red, green and blue in that order.
194 If the number of bits needed for the number of colors is not a multiple
195 of three, the blue (and green) components lose in comparison to red.
198 tells ncurses what result to add to red, green and blue.
199 If ncurses runs out of bits,
200 blue (and green) lose just as in the \fIboolean\fP case.
203 explicitly list the number of bits used for red, green and blue components
204 as a slash-separated list of decimal integers.
209 asserts that ncurses must use Unicode values for line-drawing characters,
210 and that it should ignore the alternate character set capabilities
211 when the locale uses UTF-8 encoding.
212 For more information, see the discussion of
213 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
215 Set this capability to a nonzero value to enable it.
219 override ncurses's built-in string which
220 enables/disables \fBxterm\fP mouse mode.
222 .SS Extended key-definitions
224 Several terminals provide the ability to send distinct strings for
225 combinations of modified special keys.
226 There is no standard for what those keys can send.
228 Since 1999, \fBxterm\fP has supported
229 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
230 distinct special-key strings.
231 In a terminal description, ncurses has no special knowledge of the
233 Applications can use the \fInaming convention\fP established for \fBxterm\fP
234 to find these special keys in the terminal description.
236 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
237 and that shifted special keys are an uppercase name,
238 ncurses' terminal database defines these names to which a suffix is added:
243 \fIName\fR/\fIDescription\fR
245 kDC/special form of kdch1 (delete character)
246 kDN/special form of kcud1 (cursor down)
247 kEND/special form of kend (End)
248 kHOM/special form of khome (Home)
249 kLFT/special form of kcub1 (cursor-left or cursor-back)
250 kNXT/special form of knext (Next, or Page-Down)
251 kPRV/special form of kprev (Prev, or Page-Up)
252 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
253 kUP/special form of kcuu1 (cursor-up)
257 These are the suffixes used to denote the modifiers:
262 \fIValue\fR/\fIDescription\fR
270 8/Shift + Alt + Control
274 12/Meta + Alt + Shift
276 14/Meta + Ctrl + Shift
278 16/Meta + Ctrl + Alt + Shift
282 None of these are predefined; terminal descriptions can refer to \fInames\fP
283 which ncurses will allocate at runtime to \fIkey-codes\fP.
284 To use these keys in an ncurses program, an application could do this:
286 using a list of extended key \fInames\fP,
287 ask \fBtigetstr\fP(3X) for their values, and
289 given the list of values,
290 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
291 would be returned for those keys by \fBwgetch\fP(3X).
295 The \*(``\-x\*('' extension feature of \fBtic\fP and \fBinfocmp\fP
296 has been adopted in NetBSD curses.
297 That implementation stores user-defined capabilities,
298 but makes no use of these capabilities itself.
307 beginning with ncurses 5.0 (1999)