]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/user_caps.5
ncurses 6.1 - patch 20180901
[ncurses.git] / man / user_caps.5
1 .\"***************************************************************************
2 .\" Copyright (c) 2017,2018 Free Software Foundation, Inc.                   *
3 .\"                                                                          *
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:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
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.                               *
22 .\"                                                                          *
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       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: user_caps.5,v 1.9 2018/07/28 22:05:23 tom Exp $
30 .TH user_caps 5
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .de NS
36 .ie n  .sp
37 .el    .sp .5
38 .ie n  .in +4
39 .el    .in +2
40 .nf
41 .ft C                   \" Courier
42 ..
43 .de NE
44 .fi
45 .ft R
46 .ie n  .in -4
47 .el    .in -2
48 ..
49 .de bP
50 .ie n  .IP \(bu 4
51 .el    .IP \(bu 2
52 ..
53 .SH NAME
54 user_caps \- user-defined terminfo capabilities
55 .SH SYNOPSIS
56 .B tic -x, infocmp -x
57 .SH DESCRIPTION
58 .SS Background
59 .PP
60 Before ncurses 5.0,
61 terminfo databases used a \fIfixed repertoire\fP of terminal
62 capabilities designed for the SVr2 terminal database in 1984,
63 and extended in stages through SVr4 (1989),
64 and standardized in the Single Unix Specification beginning in 1995.
65 .PP
66 Most of the \fIextensions\fP in this fixed repertoire were additions
67 to the tables of boolean, numeric and string capabilities.
68 Rather than change the meaning of an existing capability, a new name was added.
69 The terminfo database uses a binary format; binary compatibility was
70 ensured by using a header which gave the number of items in the
71 tables for each type of capability.
72 The standardization was incomplete:
73 .bP
74 The \fIbinary format\fP itself is not described
75 in the X/Open Curses documentation.
76 Only the \fIsource format\fP is described.
77 .IP
78 Library developers rely upon the SVr4 documentation,
79 and reverse-engineering the compiled terminfo files to match the binary format.
80 .bP
81 Lacking a standard for the binary format, most implementations
82 copy the SVr2 binary format, which uses 16-bit signed integers,
83 and is limited to 4096-byte entries.
84 .IP
85 The format cannot represent very large numeric capabilities,
86 nor can it represent large numbers of special keyboard definitions.
87 .bP
88 The tables of capability names differ between implementations.
89 .IP
90 Although they \fImay\fP provide all of the standard capability names,
91 the position in the tables differs because some features were added as needed,
92 while others were added (out of order) to comply with X/Open Curses.
93 .IP
94 While ncurses' repertoire of predefined capabilities is closest to Solaris,
95 Solaris's terminfo database has a few differences from
96 the list published by X/Open Curses.
97 .PP
98 During the 1990s, some users were reluctant to use terminfo
99 in spite of its performance advantages over termcap:
100 .bP
101 The fixed repertoire prevented users from adding features
102 for unanticipated terminal improvements
103 (or required them to reuse existing capabilities as a workaround).
104 .bP
105 The limitation to 16-bit signed integers was also mentioned.
106 Because termcap stores everything as a string,
107 it could represent larger numbers.
108 .PP
109 Although termcap's extensibility was rarely used
110 (it was never the \fIspeaker\fP who had actually used the feature),
111 the criticism had a point.
112 ncurses 5.0 provided a way to detect nonstandard capabilities,
113 determine their
114 type and optionally store and retrieve them in a way which did not interfere
115 with other applications.
116 These are referred to as \fIuser-defined capabilities\fP because no
117 modifications to the toolset's predefined capability names are needed.
118 .PP
119 The ncurses utilities \fBtic\fP and \fBinfocmp\fP have a command-line
120 option \*(``\-x\*('' to control whether the nonstandard capabilities
121 are stored or retrieved.
122 A library function \fBuse_extended_names\fP
123 is provided for the same purpose.
124 .PP
125 When compiling a terminal database, if \*(``\-x\*('' is set,
126 \fBtic\fP will store a user-defined capability if the capability name is not
127 one of the predefined names.
128 .PP
129 Because ncurses provides a termcap library interface,
130 these user-defined capabilities may be visible to termcap applications:
131 .bP
132 The termcap interface (like all implementations of termcap)
133 requires that the capability names are 2-characters.
134 .IP
135 When the capability is simple enough for use in a termcap application,
136 it is provided as a 2-character name.
137 .bP
138 There are other
139 user-defined capabilities which refer to features not usable in termcap,
140 e.g., parameterized strings that use more than two parameters
141 or use more than the trivial expression support provided by termcap.
142 For these, the terminfo database should have only capability names with
143 3 or more characters.
144 .bP
145 Some terminals can send distinct strings for special keys (cursor-,
146 keypad- or function-keys) depending on modifier keys (shift, control, etc.).
147 While terminfo and termcap have a set of 60 predefined function-key names,
148 to which a series of keys can be assigned,
149 that is insufficient for more than a dozen keys multiplied by more than
150 a couple of modifier combinations.
151 The ncurses database uses a convention based on \fBxterm\fP to
152 provide extended special-key names.
153 .IP
154 Fitting that into termcap's limitation of 2-character names
155 would be pointless.
156 These extended keys are available only with terminfo.
157 .SS Recognized capabilities
158 .PP
159 The ncurses library uses the user-definable capabilities.
160 While the terminfo database may have other extensions,
161 ncurses makes explicit checks for these:
162 .RS 3
163 .TP 3
164 AX
165 \fIboolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
166 by resetting the foreground and background color, respectively, to the default.
167 .IP
168 This is a feature recognized by the \fBscreen\fP program as well.
169 .TP 3
170 E3
171 \fIstring\fP, tells how to clear the terminal's scrollback buffer.
172 When present, the \fBclear\fP(1) program sends this before clearing
173 the terminal.
174 .IP
175 The command \*(``\fBtput clear\fP\*('' does the same thing.
176 .TP 3
177 RGB
178 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
179 to assert that the
180 \fBset_a_foreground\fP and
181 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
182 using an RGB (red/green/blue) convention.
183 This capability allows the \fBcolor_content\fP function to
184 return appropriate values without requiring the application
185 to initialize colors using \fBinit_color\fP.
186 .IP
187 The capability type determines the values which ncurses sees:
188 .RS 3
189 .TP 3
190 \fIboolean\fP
191 implies that the number of bits for red, green and blue are the same.
192 Using the maximum number of colors,
193 ncurses adds two, divides that sum by three, and assigns the result
194 to red, green and blue in that order.
195 .IP
196 If the number of bits needed for the number of colors is not a multiple
197 of three, the blue (and green) components lose in comparison to red.
198 .TP 3
199 \fInumber\fP
200 tells ncurses what result to add to red, green and blue.
201 If ncurses runs out of bits,
202 blue (and green) lose just as in the \fIboolean\fP case.
203 .TP 3
204 \fIstring\fP
205 explicitly list the number of bits used for red, green and blue components
206 as a slash-separated list of decimal integers.
207 .RE
208 .IP
209 Because there are several RGB encodings in use,
210 applications which make assumptions about the number of bits per color
211 are unlikely to work reliably.
212 As a trivial case, for example, one could define \fBRGB#1\fP
213 to represent the standard eight ANSI colors, i.e., one bit per color.
214 .TP 3
215 U8
216 \fInumber\fP,
217 asserts that ncurses must use Unicode values for line-drawing characters,
218 and that it should ignore the alternate character set capabilities
219 when the locale uses UTF-8 encoding.
220 For more information, see the discussion of
221 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
222 .IP
223 Set this capability to a nonzero value to enable it.
224 .TP 3
225 XM
226 \fIstring\fP,
227 override ncurses's built-in string which
228 enables/disables \fBxterm\fP mouse mode.
229 .
230 .SS Extended key-definitions
231 .PP
232 Several terminals provide the ability to send distinct strings for
233 combinations of modified special keys.
234 There is no standard for what those keys can send.
235 .PP
236 Since 1999, \fBxterm\fP has supported
237 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
238 distinct special-key strings.
239 In a terminal description, ncurses has no special knowledge of the
240 modifiers used.
241 Applications can use the \fInaming convention\fP established for \fBxterm\fP
242 to find these special keys in the terminal description.
243 .PP
244 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
245 and that shifted special keys are an uppercase name,
246 ncurses' terminal database defines these names to which a suffix is added:
247 .RS 5
248 .TS
249 tab(/) ;
250 l l .
251 \fIName\fR/\fIDescription\fR
252 _
253 kDC/special form of kdch1 (delete character)
254 kDN/special form of kcud1 (cursor down)
255 kEND/special form of kend (End)
256 kHOM/special form of khome (Home)
257 kLFT/special form of kcub1 (cursor-left or cursor-back)
258 kNXT/special form of knext (Next, or Page-Down)
259 kPRV/special form of kprev (Prev, or Page-Up)
260 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
261 kUP/special form of kcuu1 (cursor-up)
262 .TE
263 .RE
264 .PP
265 These are the suffixes used to denote the modifiers:
266 .RS 5
267 .TS
268 tab(/) ;
269 l l .
270 \fIValue\fR/\fIDescription\fR
271 _
272 2/Shift
273 3/Alt
274 4/Shift + Alt
275 5/Control
276 6/Shift + Control
277 7/Alt + Control
278 8/Shift + Alt + Control
279 9/Meta
280 10/Meta + Shift
281 11/Meta + Alt
282 12/Meta + Alt + Shift
283 13/Meta + Ctrl
284 14/Meta + Ctrl + Shift
285 15/Meta + Ctrl + Alt
286 16/Meta + Ctrl + Alt + Shift
287 .TE
288 .RE
289 .PP
290 None of these are predefined; terminal descriptions can refer to \fInames\fP
291 which ncurses will allocate at runtime to \fIkey-codes\fP.
292 To use these keys in an ncurses program, an application could do this:
293 .bP
294 using a list of extended key \fInames\fP,
295 ask \fBtigetstr\fP(3X) for their values, and
296 .bP
297 given the list of values,
298 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
299 would be returned for those keys by \fBwgetch\fP(3X).
300 .PP
301 .SH PORTABILITY
302 .PP
303 The \*(``\-x\*('' extension feature of \fBtic\fP and \fBinfocmp\fP
304 has been adopted in NetBSD curses.
305 That implementation stores user-defined capabilities,
306 but makes no use of these capabilities itself.
307 .SH SEE ALSO
308 .PP
309 \fBtic\fR(1),
310 \fBinfocmp\fR(1).
311 .SH AUTHORS
312 .PP
313 Thomas E. Dickey
314 .br
315 beginning with ncurses 5.0 (1999)