]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/user_caps.5
ncurses 6.1 - patch 20180714
[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.7 2018/02/17 19:07:01 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 .in -4
47 ..
48 .de bP
49 .ie n  .IP \(bu 4
50 .el    .IP \(bu 2
51 ..
52 .SH NAME
53 user_caps \- user-defined terminfo capabilities
54 .SH SYNOPSIS
55 .B tic -x, infocmp -x
56 .SH DESCRIPTION
57 .SS Background
58 .PP
59 Before ncurses 5.0,
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.
64 .PP
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:
72 .bP
73 The \fIbinary format\fP itself is not described
74 in the X/Open Curses documentation.
75 Only the \fIsource format\fP is described.
76 .IP
77 Library developers rely upon the SVr4 documentation,
78 and reverse-engineering the compiled terminfo files to match the binary format.
79 .bP
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.
83 .IP
84 The format cannot represent very large numeric capabilities,
85 nor can it represent large numbers of special keyboard definitions.
86 .bP
87 The tables of capability names differ between implementations.
88 .IP
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.
92 .IP
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.
96 .PP
97 During the 1990s, some users were reluctant to use terminfo
98 in spite of its performance advantages over termcap:
99 .bP
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).
103 .bP
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.
107 .PP
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,
112 determine their
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.
117 .PP
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.
122 .PP
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.
126 .PP
127 Because ncurses provides a termcap library interface,
128 these user-defined capabilities may be visible to termcap applications:
129 .bP
130 The termcap interface (like all implementations of termcap)
131 requires that the capability names are 2-characters.
132 .IP
133 When the capability is simple enough for use in a termcap application,
134 it is provided as a 2-character name.
135 .bP
136 There are other
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.
142 .bP
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.
151 .IP
152 Fitting that into termcap's limitation of 2-character names
153 would be pointless.
154 These extended keys are available only with terminfo.
155 .SS Recognized capabilities
156 .PP
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:
160 .RS 3
161 .TP 3
162 AX
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. 
165 .IP
166 This is a feature recognized by the \fBscreen\fP program as well.
167 .TP 3
168 E3
169 \fIstring\fP, tells how to clear the terminal's scrollback buffer.
170 When present, the \fBclear\fP(1) program sends this before clearing
171 the terminal.
172 .IP
173 The command \*(``\fBtput clear\fP\*('' does the same thing.
174 .TP 3
175 RGB
176 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
177 to assert that the
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.
184 .IP
185 The capability type determines the values which ncurses sees:
186 .RS 3
187 .TP 3
188 \fIboolean\fP
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.
193 .IP
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.
196 .TP 3
197 \fInumber\fP
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.
201 .TP 3
202 \fIstring\fP
203 explicitly list the number of bits used for red, green and blue components
204 as a slash-separated list of decimal integers.
205 .RE
206 .IP
207 Because there are several RGB encodings in use,
208 applications which make assumptions about the number of bits per color
209 are unlikely to work reliably.
210 As a trivial case, for example, one could define \fBRGB#1\fP
211 to represent the standard eight ANSI colors, i.e., one bit per color.
212 .TP 3
213 U8
214 \fInumber\fP,
215 asserts that ncurses must use Unicode values for line-drawing characters,
216 and that it should ignore the alternate character set capabilities
217 when the locale uses UTF-8 encoding.
218 For more information, see the discussion of
219 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
220 .IP
221 Set this capability to a nonzero value to enable it.
222 .TP 3
223 XM
224 \fIstring\fP,
225 override ncurses's built-in string which
226 enables/disables \fBxterm\fP mouse mode.
227 .
228 .SS Extended key-definitions
229 .PP
230 Several terminals provide the ability to send distinct strings for
231 combinations of modified special keys.
232 There is no standard for what those keys can send.
233 .PP
234 Since 1999, \fBxterm\fP has supported
235 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
236 distinct special-key strings.
237 In a terminal description, ncurses has no special knowledge of the
238 modifiers used.
239 Applications can use the \fInaming convention\fP established for \fBxterm\fP
240 to find these special keys in the terminal description.
241 .PP
242 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
243 and that shifted special keys are an uppercase name,
244 ncurses' terminal database defines these names to which a suffix is added:
245 .RS 5
246 .TS
247 tab(/) ;
248 l l .
249 \fIName\fR/\fIDescription\fR
250 _
251 kDC/special form of kdch1 (delete character)
252 kDN/special form of kcud1 (cursor down)
253 kEND/special form of kend (End)
254 kHOM/special form of khome (Home)
255 kLFT/special form of kcub1 (cursor-left or cursor-back)
256 kNXT/special form of knext (Next, or Page-Down)
257 kPRV/special form of kprev (Prev, or Page-Up) 
258 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
259 kUP/special form of kcuu1 (cursor-up)
260 .TE
261 .RE
262 .PP
263 These are the suffixes used to denote the modifiers:
264 .RS 5
265 .TS
266 tab(/) ;
267 l l .
268 \fIValue\fR/\fIDescription\fR
269 _
270 2/Shift
271 3/Alt
272 4/Shift + Alt
273 5/Control
274 6/Shift + Control
275 7/Alt + Control
276 8/Shift + Alt + Control
277 9/Meta
278 10/Meta + Shift
279 11/Meta + Alt
280 12/Meta + Alt + Shift
281 13/Meta + Ctrl
282 14/Meta + Ctrl + Shift
283 15/Meta + Ctrl + Alt
284 16/Meta + Ctrl + Alt + Shift
285 .TE
286 .RE
287 .PP
288 None of these are predefined; terminal descriptions can refer to \fInames\fP
289 which ncurses will allocate at runtime to \fIkey-codes\fP.
290 To use these keys in an ncurses program, an application could do this:
291 .bP
292 using a list of extended key \fInames\fP,
293 ask \fBtigetstr\fP(3X) for their values, and
294 .bP
295 given the list of values,
296 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
297 would be returned for those keys by \fBwgetch\fP(3X).
298 .PP
299 .SH PORTABILITY
300 .PP
301 The \*(``\-x\*('' extension feature of \fBtic\fP and \fBinfocmp\fP
302 has been adopted in NetBSD curses.
303 That implementation stores user-defined capabilities,
304 but makes no use of these capabilities itself.
305 .SH SEE ALSO
306 .PP
307 \fBtic\fR(1),
308 \fBinfocmp\fR(1).
309 .SH AUTHORS
310 .PP
311 Thomas E. Dickey
312 .br
313 beginning with ncurses 5.0 (1999)