]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/user_caps.5
ncurses 6.1 - patch 20190824
[ncurses.git] / man / user_caps.5
1 .\"***************************************************************************
2 .\" Copyright (c) 2017-2018,2019 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.10 2019/05/18 22:48:40 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 For example, ncurses can be configured with tables which match the
98 terminal databases for AIX, HP-UX or OSF/1,
99 rather than the default Solaris-like configuration.
100 .bP
101 In SVr4 curses and ncurses,
102 the terminal database is defined at compile-time using a text file
103 which lists the different terminal capabilities.
104 .IP
105 In principle, the text-file can be extended,
106 but doing this requires recompiling and reinstalling the library.
107 The text-file used in ncurses for terminal capabilities includes
108 details for various systems past the documented X/Open Curses features.
109 For example, ncurses supports these capabilities in each configuration:
110 .RS 8
111 .TP 5
112 memory_lock
113 (meml)
114 lock memory above cursor
115 .TP 5
116 memory_unlock
117 (memu)
118 unlock memory
119 .TP 5
120 box_chars_1
121 (box1)
122 box characters primary set
123 .RE
124 .IP
125 The memory lock/unlock capabilities were included because they were used
126 in the X11R6 terminal description for \fBxterm\fP.
127 The \fIbox1\fP capability is used in @TIC@ to help with terminal descriptions
128 written for AIX. 
129 .PP
130 During the 1990s, some users were reluctant to use terminfo
131 in spite of its performance advantages over termcap:
132 .bP
133 The fixed repertoire prevented users from adding features
134 for unanticipated terminal improvements
135 (or required them to reuse existing capabilities as a workaround).
136 .bP
137 The limitation to 16-bit signed integers was also mentioned.
138 Because termcap stores everything as a string,
139 it could represent larger numbers.
140 .PP
141 Although termcap's extensibility was rarely used
142 (it was never the \fIspeaker\fP who had actually used the feature),
143 the criticism had a point.
144 ncurses 5.0 provided a way to detect nonstandard capabilities,
145 determine their
146 type and optionally store and retrieve them in a way which did not interfere
147 with other applications.
148 These are referred to as \fIuser-defined capabilities\fP because no
149 modifications to the toolset's predefined capability names are needed.
150 .PP
151 The ncurses utilities \fB@TIC@\fP and \fB@INFOCMP@\fP have a command-line
152 option \*(``\-x\*('' to control whether the nonstandard capabilities
153 are stored or retrieved.
154 A library function \fBuse_extended_names\fP
155 is provided for the same purpose.
156 .PP
157 When compiling a terminal database, if \*(``\-x\*('' is set,
158 \fB@TIC@\fP will store a user-defined capability if the capability name is not
159 one of the predefined names.
160 .PP
161 Because ncurses provides a termcap library interface,
162 these user-defined capabilities may be visible to termcap applications:
163 .bP
164 The termcap interface (like all implementations of termcap)
165 requires that the capability names are 2-characters.
166 .IP
167 When the capability is simple enough for use in a termcap application,
168 it is provided as a 2-character name.
169 .bP
170 There are other
171 user-defined capabilities which refer to features not usable in termcap,
172 e.g., parameterized strings that use more than two parameters
173 or use more than the trivial expression support provided by termcap.
174 For these, the terminfo database should have only capability names with
175 3 or more characters.
176 .bP
177 Some terminals can send distinct strings for special keys (cursor-,
178 keypad- or function-keys) depending on modifier keys (shift, control, etc.).
179 While terminfo and termcap have a set of 60 predefined function-key names,
180 to which a series of keys can be assigned,
181 that is insufficient for more than a dozen keys multiplied by more than
182 a couple of modifier combinations.
183 The ncurses database uses a convention based on \fBxterm\fP to
184 provide extended special-key names.
185 .IP
186 Fitting that into termcap's limitation of 2-character names
187 would be pointless.
188 These extended keys are available only with terminfo.
189 .SS Recognized capabilities
190 .PP
191 The ncurses library uses the user-definable capabilities.
192 While the terminfo database may have other extensions,
193 ncurses makes explicit checks for these:
194 .RS 3
195 .TP 3
196 AX
197 \fIboolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
198 by resetting the foreground and background color, respectively, to the default.
199 .IP
200 This is a feature recognized by the \fBscreen\fP program as well.
201 .TP 3
202 E3
203 \fIstring\fP, tells how to clear the terminal's scrollback buffer.
204 When present, the \fBclear\fP(1) program sends this before clearing
205 the terminal.
206 .IP
207 The command \*(``\fBtput clear\fP\*('' does the same thing.
208 .TP 3
209 RGB
210 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
211 to assert that the
212 \fBset_a_foreground\fP and
213 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
214 using an RGB (red/green/blue) convention.
215 This capability allows the \fBcolor_content\fP function to
216 return appropriate values without requiring the application
217 to initialize colors using \fBinit_color\fP.
218 .IP
219 The capability type determines the values which ncurses sees:
220 .RS 3
221 .TP 3
222 \fIboolean\fP
223 implies that the number of bits for red, green and blue are the same.
224 Using the maximum number of colors,
225 ncurses adds two, divides that sum by three, and assigns the result
226 to red, green and blue in that order.
227 .IP
228 If the number of bits needed for the number of colors is not a multiple
229 of three, the blue (and green) components lose in comparison to red.
230 .TP 3
231 \fInumber\fP
232 tells ncurses what result to add to red, green and blue.
233 If ncurses runs out of bits,
234 blue (and green) lose just as in the \fIboolean\fP case.
235 .TP 3
236 \fIstring\fP
237 explicitly list the number of bits used for red, green and blue components
238 as a slash-separated list of decimal integers.
239 .RE
240 .IP
241 Because there are several RGB encodings in use,
242 applications which make assumptions about the number of bits per color
243 are unlikely to work reliably.
244 As a trivial case, for example, one could define \fBRGB#1\fP
245 to represent the standard eight ANSI colors, i.e., one bit per color.
246 .TP 3
247 U8
248 \fInumber\fP,
249 asserts that ncurses must use Unicode values for line-drawing characters,
250 and that it should ignore the alternate character set capabilities
251 when the locale uses UTF-8 encoding.
252 For more information, see the discussion of
253 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
254 .IP
255 Set this capability to a nonzero value to enable it.
256 .TP 3
257 XM
258 \fIstring\fP,
259 override ncurses's built-in string which
260 enables/disables \fBxterm\fP mouse mode.
261 .
262 .SS Extended key-definitions
263 .PP
264 Several terminals provide the ability to send distinct strings for
265 combinations of modified special keys.
266 There is no standard for what those keys can send.
267 .PP
268 Since 1999, \fBxterm\fP has supported
269 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
270 distinct special-key strings.
271 In a terminal description, ncurses has no special knowledge of the
272 modifiers used.
273 Applications can use the \fInaming convention\fP established for \fBxterm\fP
274 to find these special keys in the terminal description.
275 .PP
276 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
277 and that shifted special keys are an uppercase name,
278 ncurses' terminal database defines these names to which a suffix is added:
279 .RS 5
280 .TS
281 tab(/) ;
282 l l .
283 \fIName\fR/\fIDescription\fR
284 _
285 kDC/special form of kdch1 (delete character)
286 kDN/special form of kcud1 (cursor down)
287 kEND/special form of kend (End)
288 kHOM/special form of khome (Home)
289 kLFT/special form of kcub1 (cursor-left or cursor-back)
290 kNXT/special form of knext (Next, or Page-Down)
291 kPRV/special form of kprev (Prev, or Page-Up)
292 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
293 kUP/special form of kcuu1 (cursor-up)
294 .TE
295 .RE
296 .PP
297 These are the suffixes used to denote the modifiers:
298 .RS 5
299 .TS
300 tab(/) ;
301 l l .
302 \fIValue\fR/\fIDescription\fR
303 _
304 2/Shift
305 3/Alt
306 4/Shift + Alt
307 5/Control
308 6/Shift + Control
309 7/Alt + Control
310 8/Shift + Alt + Control
311 9/Meta
312 10/Meta + Shift
313 11/Meta + Alt
314 12/Meta + Alt + Shift
315 13/Meta + Ctrl
316 14/Meta + Ctrl + Shift
317 15/Meta + Ctrl + Alt
318 16/Meta + Ctrl + Alt + Shift
319 .TE
320 .RE
321 .PP
322 None of these are predefined; terminal descriptions can refer to \fInames\fP
323 which ncurses will allocate at runtime to \fIkey-codes\fP.
324 To use these keys in an ncurses program, an application could do this:
325 .bP
326 using a list of extended key \fInames\fP,
327 ask \fBtigetstr\fP(3X) for their values, and
328 .bP
329 given the list of values,
330 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
331 would be returned for those keys by \fBwgetch\fP(3X).
332 .PP
333 .SH PORTABILITY
334 .PP
335 The \*(``\-x\*('' extension feature of \fB@TIC@\fP and \fB@INFOCMP@\fP
336 has been adopted in NetBSD curses.
337 That implementation stores user-defined capabilities,
338 but makes no use of these capabilities itself.
339 .SH SEE ALSO
340 .PP
341 \fB@TIC@\fR(1M),
342 \fB@INFOCMP@\fR(1M).
343 .SH AUTHORS
344 .PP
345 Thomas E. Dickey
346 .br
347 beginning with ncurses 5.0 (1999)