]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/user_caps.5
ncurses 6.4 - patch 20231007
[ncurses.git] / man / user_caps.5
1 '\" t
2 .\"***************************************************************************
3 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
4 .\" Copyright 2017 Free Software Foundation, Inc.                            *
5 .\"                                                                          *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
7 .\" copy of this software and associated documentation files (the            *
8 .\" "Software"), to deal in the Software without restriction, including      *
9 .\" without limitation the rights to use, copy, modify, merge, publish,      *
10 .\" distribute, distribute with modifications, sublicense, and/or sell       *
11 .\" copies of the Software, and to permit persons to whom the Software is    *
12 .\" furnished to do so, subject to the following conditions:                 *
13 .\"                                                                          *
14 .\" The above copyright notice and this permission notice shall be included  *
15 .\" in all copies or substantial portions of the Software.                   *
16 .\"                                                                          *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24 .\"                                                                          *
25 .\" Except as contained in this notice, the name(s) of the above copyright   *
26 .\" holders shall not be used in advertising or otherwise to promote the     *
27 .\" sale, use or other dealings in this Software without prior written       *
28 .\" authorization.                                                           *
29 .\"***************************************************************************
30 .\"
31 .\" $Id: user_caps.5,v 1.41 2023/10/07 21:19:07 tom Exp $
32 .TH user_caps 5 2023-10-07 "ncurses 6.4" "File formats"
33 .ie \n(.g \{\
34 .ds `` \(lq
35 .ds '' \(rq
36 .\}
37 .el \{\
38 .ie t .ds `` ``
39 .el   .ds `` ""
40 .ie t .ds '' ''
41 .el   .ds '' ""
42 .\}
43 .
44 .de bP
45 .ie n  .IP \(bu 4
46 .el    .IP \(bu 2
47 ..
48 .SH NAME
49 user_caps \-
50 user-defined \fIterminfo\fR capability format
51 .SH SYNOPSIS
52 .B @INFOCMP@ \-x
53 .PP
54 .B @TIC@ \-x
55 .SH DESCRIPTION
56 .SS Background
57 Before ncurses 5.0,
58 terminfo databases used a \fIfixed repertoire\fP of terminal
59 capabilities designed for the SVr2 terminal database in 1984,
60 and extended in stages through SVr4 (1989),
61 and standardized in the Single Unix Specification beginning in 1995.
62 .PP
63 Most of the \fIextensions\fP in this fixed repertoire were additions
64 to the tables of boolean, numeric and string capabilities.
65 Rather than change the meaning of an existing capability, a new name was added.
66 The terminfo database uses a binary format; binary compatibility was
67 ensured by using a header which gave the number of items in the
68 tables for each type of capability.
69 The standardization was incomplete:
70 .bP
71 The \fIbinary format\fP itself is not described
72 in the X/Open Curses documentation.
73 Only the \fIsource format\fP is described.
74 .IP
75 Library developers rely upon the SVr4 documentation,
76 and reverse-engineering the compiled terminfo files to match the binary format.
77 .bP
78 Lacking a standard for the binary format, most implementations
79 copy the SVr2 binary format, which uses 16-bit signed integers,
80 and is limited to 4096-byte entries.
81 .IP
82 The format cannot represent very large numeric capabilities,
83 nor can it represent large numbers of special keyboard definitions.
84 .bP
85 The tables of capability names differ between implementations.
86 .IP
87 Although they \fImay\fP provide all of the standard capability names,
88 the position in the tables differs because some features were added as needed,
89 while others were added (out of order) to comply with X/Open Curses.
90 .IP
91 While ncurses' repertoire of predefined capabilities is closest to Solaris,
92 Solaris's terminfo database has a few differences from
93 the list published by X/Open Curses.
94 For example, ncurses can be configured with tables which match the
95 terminal databases for AIX, HP-UX or OSF/1,
96 rather than the default Solaris-like configuration.
97 .bP
98 In SVr4 curses and ncurses,
99 the terminal database is defined at compile-time using a text file
100 which lists the different terminal capabilities.
101 .IP
102 In principle, the text-file can be extended,
103 but doing this requires recompiling and reinstalling the library.
104 The text-file used in ncurses for terminal capabilities includes
105 details for various systems past the documented X/Open Curses features.
106 For example, ncurses supports these capabilities in each configuration:
107 .RS 8
108 .TP 5
109 memory_lock
110 (meml)
111 lock memory above cursor
112 .TP 5
113 memory_unlock
114 (memu)
115 unlock memory
116 .TP 5
117 box_chars_1
118 (box1)
119 box characters primary set
120 .RE
121 .IP
122 The memory lock/unlock capabilities were included because they were used
123 in the X11R6 terminal description for \fBxterm\fP(1).
124 The \fIbox1\fP capability is used in @TIC@ to help with terminal descriptions
125 written for AIX.
126 .PP
127 During the 1990s, some users were reluctant to use terminfo
128 in spite of its performance advantages over termcap:
129 .bP
130 The fixed repertoire prevented users from adding features
131 for unanticipated terminal improvements
132 (or required them to reuse existing capabilities as a workaround).
133 .bP
134 The limitation to 16-bit signed integers was also mentioned.
135 Because termcap stores everything as a string,
136 it could represent larger numbers.
137 .PP
138 Although termcap's extensibility was rarely used
139 (it was never the \fIspeaker\fP who had actually used the feature),
140 the criticism had a point.
141 ncurses 5.0 provided a way to detect nonstandard capabilities,
142 determine their
143 type and optionally store and retrieve them in a way which did not interfere
144 with other applications.
145 These are referred to as \fIuser-defined capabilities\fP because no
146 modifications to the toolset's predefined capability names are needed.
147 .PP
148 The ncurses utilities \fB@TIC@\fP and \fB@INFOCMP@\fP have a command-line
149 option \*(``\-x\*('' to control whether the nonstandard capabilities
150 are stored or retrieved.
151 A library function \fBuse_extended_names\fP
152 is provided for the same purpose.
153 .PP
154 When compiling a terminal database, if \*(``\-x\*('' is set,
155 \fB@TIC@\fP will store a user-defined capability if the capability name is not
156 one of the predefined names.
157 .PP
158 Because ncurses provides a termcap library interface,
159 these user-defined capabilities may be visible to termcap applications:
160 .bP
161 The termcap interface (like all implementations of termcap)
162 requires that the capability names are 2-characters.
163 .IP
164 When the capability is simple enough for use in a termcap application,
165 it is provided as a 2-character name.
166 .bP
167 There are other
168 user-defined capabilities which refer to features not usable in termcap,
169 e.g., parameterized strings that use more than two parameters
170 or use more than the trivial expression support provided by termcap.
171 For these, the terminfo database should have only capability names with
172 3 or more characters.
173 .bP
174 Some terminals can send distinct strings for special keys (cursor-,
175 keypad- or function-keys) depending on modifier keys (shift, control, etc.).
176 While terminfo and termcap have a set of 60 predefined function-key names,
177 to which a series of keys can be assigned,
178 that is insufficient for more than a dozen keys multiplied by more than
179 a couple of modifier combinations.
180 The ncurses database uses a convention based on \fBxterm\fP(1) to
181 provide extended special-key names.
182 .IP
183 Fitting that into termcap's limitation of 2-character names
184 would be pointless.
185 These extended keys are available only with terminfo.
186 .SS Recognized capabilities
187 The ncurses library uses the user-definable capabilities.
188 While the terminfo database may have other extensions,
189 ncurses makes explicit checks for these:
190 .RS 3
191 .TP 3
192 AX
193 \fIboolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
194 by resetting the foreground and background color, respectively, to the default.
195 .IP
196 This is a feature recognized by the \fBscreen\fP program as well.
197 .TP 3
198 E3
199 \fIstring\fP, tells how to clear the terminal's scrollback buffer.
200 When present, the \fBclear\fP(1) program sends this before clearing
201 the terminal.
202 .IP
203 The command \*(``\fBtput clear\fP\*('' does the same thing.
204 .TP 3
205 NQ
206 \fIboolean\fP,
207 used to suppress a consistency check in @TIC@ for the ncurses capabilities
208 in user6 through user9 (u6, u7, u8 and u9)
209 which tell how to query the terminal's cursor position
210 and its device attributes.
211 .TP 3
212 RGB
213 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
214 used to assert that the
215 \fBset_a_foreground\fP and
216 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
217 using an RGB (red/green/blue) convention.
218 This capability allows the \fBcolor_content\fP function to
219 return appropriate values without requiring the application
220 to initialize colors using \fBinit_color\fP.
221 .IP
222 The capability type determines the values which ncurses sees:
223 .RS 3
224 .TP 3
225 \fIboolean\fP
226 implies that the number of bits for red, green and blue are the same.
227 Using the maximum number of colors,
228 ncurses adds two, divides that sum by three, and assigns the result
229 to red, green and blue in that order.
230 .IP
231 If the number of bits needed for the number of colors is not a multiple
232 of three, the blue (and green) components lose in comparison to red.
233 .TP 3
234 \fInumber\fP
235 tells ncurses what result to add to red, green and blue.
236 If ncurses runs out of bits,
237 blue (and green) lose just as in the \fIboolean\fP case.
238 .TP 3
239 \fIstring\fP
240 explicitly list the number of bits used for red, green and blue components
241 as a slash-separated list of decimal integers.
242 .RE
243 .IP
244 Because there are several RGB encodings in use,
245 applications which make assumptions about the number of bits per color
246 are unlikely to work reliably.
247 As a trivial case, for example, one could define \fBRGB#1\fP
248 to represent the standard eight ANSI colors, i.e., one bit per color.
249 .TP 3
250 U8
251 \fInumber\fP,
252 asserts that ncurses must use Unicode values for line-drawing characters,
253 and that it should ignore the alternate character set capabilities
254 when the locale uses UTF-8 encoding.
255 For more information, see the discussion of
256 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
257 .IP
258 Set this capability to a nonzero value to enable it.
259 .TP 3
260 XM
261 \fIstring\fP,
262 override ncurses's built-in string which
263 enables/disables \fBxterm\fP(1) mouse mode.
264 .IP
265 ncurses sends a character sequence to the terminal to initialize mouse mode,
266 and when the user clicks the mouse buttons or (in certain modes) moves the
267 mouse, handles the characters sent back by the terminal to tell it what
268 was done with the mouse.
269 .IP
270 The mouse protocol is enabled when
271 the \fImask\fP passed in the \fBmousemask\fP function is nonzero.
272 By default, ncurses handles the responses for the X11 xterm mouse protocol.
273 It also knows about the \fISGR 1006\fP xterm mouse protocol,
274 but must to be told to look for this specifically.
275 It will not be able to guess which mode is used,
276 because the responses are enough alike that only confusion would result.
277 .IP
278 The \fBXM\fP capability has a single parameter.
279 If nonzero, the mouse protocol should be enabled.
280 If zero, the mouse protocol should be disabled.
281 ncurses inspects this capability if it is present,
282 to see whether the 1006 protocol is used.
283 If so, it expects the responses to use the \fISGR 1006\fP xterm mouse protocol.
284 .IP
285 The xterm mouse protocol is used by other terminal emulators.
286 The terminal database uses building-blocks for the various xterm mouse
287 protocols which can be used in customized terminal descriptions.
288 .IP
289 The terminal database building blocks for this mouse
290 feature also have an experimental capability \fIxm\fP.
291 The \*(``xm\*('' capability describes the mouse response.
292 Currently there is no interpreter which would use this
293 information to make the mouse support completely data-driven.
294 .IP
295 \fIxm\fP shows the format of the mouse responses.
296 In this experimental capability, the parameters are
297 .RS 5
298 .TP 5
299 .I p1
300 y-ordinate
301 .TP 5
302 .I p2
303 x-ordinate
304 .TP 5
305 .I p3
306 button
307 .TP 5
308 .I p4
309 state, e.g., pressed or released
310 .TP 5
311 .I p5
312 y-ordinate starting region
313 .TP 5
314 .I p6
315 x-ordinate starting region
316 .TP 5
317 .I p7
318 y-ordinate ending region
319 .TP 5
320 .I p8
321 x-ordinate ending region
322 .RE
323 .IP
324 Here are examples from the terminal database for the most commonly used
325 xterm mouse protocols:
326 .IP
327 .nf
328   xterm+x11mouse|X11 xterm mouse protocol,
329           kmous=\eE[M, XM=\eE[?1000%?%p1%{1}%=%th%el%;,
330           xm=\eE[M
331              %?%p4%t%p3%e%{3}%;%'\ '%+%c
332              %p2%'!'%+%c
333              %p1%'!'%+%c,
334
335   xterm+sm+1006|xterm SGR-mouse,
336           kmous=\eE[<, XM=\eE[?1006;1000%?%p1%{1}%=%th%el%;,
337           xm=\eE[<%i%p3%d;
338              %p1%d;
339              %p2%d;
340              %?%p4%tM%em%;,
341 .fi
342 .
343 .SS Extended key-definitions
344 Several terminals provide the ability to send distinct strings for
345 combinations of modified special keys.
346 There is no standard for what those keys can send.
347 .PP
348 Since 1999, \fBxterm\fP(1) has supported
349 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
350 distinct special-key strings.
351 In a terminal description, ncurses has no special knowledge of the
352 modifiers used.
353 Applications can use the \fInaming convention\fP established for \fBxterm\fP
354 to find these special keys in the terminal description.
355 .PP
356 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
357 and that shifted special keys are an uppercase name,
358 ncurses' terminal database defines these names to which a suffix is added:
359 .PP
360 .RS 5
361 .TS
362 tab(/) ;
363 l l .
364 \fBName\fP/\fBDescription\fP
365 _
366 kDC/special form of kdch1 (delete character)
367 kDN/special form of kcud1 (cursor down)
368 kEND/special form of kend (End)
369 kHOM/special form of khome (Home)
370 kLFT/special form of kcub1 (cursor-left or cursor-back)
371 kNXT/special form of knext (Next, or Page-Down)
372 kPRV/special form of kprev (Prev, or Page-Up)
373 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
374 kUP/special form of kcuu1 (cursor-up)
375 .TE
376 .RE
377 .PP
378 These are the suffixes used to denote the modifiers:
379 .PP
380 .RS 5
381 .TS
382 tab(/) ;
383 l l .
384 \fBValue\fP/\fBDescription\fP
385 _
386 2/Shift
387 3/Alt
388 4/Shift + Alt
389 5/Control
390 6/Shift + Control
391 7/Alt + Control
392 8/Shift + Alt + Control
393 9/Meta
394 10/Meta + Shift
395 11/Meta + Alt
396 12/Meta + Alt + Shift
397 13/Meta + Ctrl
398 14/Meta + Ctrl + Shift
399 15/Meta + Ctrl + Alt
400 16/Meta + Ctrl + Alt + Shift
401 .TE
402 .RE
403 .PP
404 None of these are predefined; terminal descriptions can refer to \fInames\fP
405 which ncurses will allocate at runtime to \fIkey-codes\fP.
406 To use these keys in an ncurses program, an application could do this:
407 .bP
408 using a list of extended key \fInames\fP,
409 ask \fBtigetstr\fP(3X) for their values, and
410 .bP
411 given the list of values,
412 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
413 would be returned for those keys by \fBwgetch\fP(3X).
414 .\"
415 .SH PORTABILITY
416 The \*(``\-x\*('' extension feature of \fB@TIC@\fP and \fB@INFOCMP@\fP
417 has been adopted in NetBSD curses.
418 That implementation stores user-defined capabilities,
419 but makes no use of these capabilities itself.
420 .\"
421 .SH AUTHORS
422 Thomas E. Dickey
423 .br
424 beginning with ncurses 5.0 (1999)
425 .\"
426 .SH SEE ALSO
427 \fB\%@INFOCMP@\fP(1M),
428 \fB\%@TIC@\fP(1M)
429 .PP
430 The terminal database section
431 .I "NCURSES USER-DEFINABLE CAPABILITIES"
432 summarizes commonly-used user-defined capabilities
433 which are used in the terminal descriptions.
434 Some of those features are mentioned in \fB\%screen\fP(1) or
435 \fBtmux\fP(1).
436 .PP
437 .I "XTerm Control Sequences"
438 provides further information on the \fB\%xterm\fP(1) features
439 that are used in these extended capabilities.