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