]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/user_caps.5
ncurses 6.4 - patch 20230917
[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.36 2023/09/16 23:38:39 tom Exp $
32 .TH user_caps 5 2023-09-16 "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 used to suppress a consistency check in @TIC@ for the ncurses capabilities
198 in user6 through user9 (u6, u7, u8 and u9)
199 which tell how to query the terminal's cursor position
200 and its device attributes.
201 .TP 3
202 RGB
203 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
204 used to assert that the
205 \fBset_a_foreground\fP and
206 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
207 using an RGB (red/green/blue) convention.
208 This capability allows the \fBcolor_content\fP function to
209 return appropriate values without requiring the application
210 to initialize colors using \fBinit_color\fP.
211 .IP
212 The capability type determines the values which ncurses sees:
213 .RS 3
214 .TP 3
215 \fIboolean\fP
216 implies that the number of bits for red, green and blue are the same.
217 Using the maximum number of colors,
218 ncurses adds two, divides that sum by three, and assigns the result
219 to red, green and blue in that order.
220 .IP
221 If the number of bits needed for the number of colors is not a multiple
222 of three, the blue (and green) components lose in comparison to red.
223 .TP 3
224 \fInumber\fP
225 tells ncurses what result to add to red, green and blue.
226 If ncurses runs out of bits,
227 blue (and green) lose just as in the \fIboolean\fP case.
228 .TP 3
229 \fIstring\fP
230 explicitly list the number of bits used for red, green and blue components
231 as a slash-separated list of decimal integers.
232 .RE
233 .IP
234 Because there are several RGB encodings in use,
235 applications which make assumptions about the number of bits per color
236 are unlikely to work reliably.
237 As a trivial case, for example, one could define \fBRGB#1\fP
238 to represent the standard eight ANSI colors, i.e., one bit per color.
239 .TP 3
240 U8
241 \fInumber\fP,
242 asserts that ncurses must use Unicode values for line-drawing characters,
243 and that it should ignore the alternate character set capabilities
244 when the locale uses UTF-8 encoding.
245 For more information, see the discussion of
246 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
247 .IP
248 Set this capability to a nonzero value to enable it.
249 .TP 3
250 XM
251 \fIstring\fP,
252 override ncurses's built-in string which
253 enables/disables \fBxterm\fP(1) mouse mode.
254 .IP
255 ncurses sends a character sequence to the terminal to initialize mouse mode,
256 and when the user clicks the mouse buttons or (in certain modes) moves the
257 mouse, handles the characters sent back by the terminal to tell it what
258 was done with the mouse.
259 .IP
260 The mouse protocol is enabled when
261 the \fImask\fP passed in the \fBmousemask\fP function is nonzero.
262 By default, ncurses handles the responses for the X11 xterm mouse protocol.
263 It also knows about the \fISGR 1006\fP xterm mouse protocol,
264 but must to be told to look for this specifically.
265 It will not be able to guess which mode is used,
266 because the responses are enough alike that only confusion would result.
267 .IP
268 The \fBXM\fP capability has a single parameter.
269 If nonzero, the mouse protocol should be enabled.
270 If zero, the mouse protocol should be disabled.
271 ncurses inspects this capability if it is present,
272 to see whether the 1006 protocol is used.
273 If so, it expects the responses to use the \fISGR 1006\fP xterm mouse protocol.
274 .IP
275 The xterm mouse protocol is used by other terminal emulators.
276 The terminal database uses building-blocks for the various xterm mouse
277 protocols which can be used in customized terminal descriptions.
278 .IP
279 The terminal database building blocks for this mouse
280 feature also have an experimental capability \fIxm\fP.
281 The \*(``xm\*('' capability describes the mouse response.
282 Currently there is no interpreter which would use this
283 information to make the mouse support completely data-driven.
284 .IP
285 \fIxm\fP shows the format of the mouse responses.
286 In this experimental capability, the parameters are
287 .RS 5
288 .TP 5
289 .I p1
290 y-ordinate
291 .TP 5
292 .I p2
293 x-ordinate
294 .TP 5
295 .I p3
296 button
297 .TP 5
298 .I p4
299 state, e.g., pressed or released
300 .TP 5
301 .I p5
302 y-ordinate starting region
303 .TP 5
304 .I p6
305 x-ordinate starting region
306 .TP 5
307 .I p7
308 y-ordinate ending region
309 .TP 5
310 .I p8
311 x-ordinate ending region
312 .RE
313 .IP
314 Here are examples from the terminal database for the most commonly used
315 xterm mouse protocols:
316 .IP
317 .nf
318   xterm+x11mouse|X11 xterm mouse protocol,
319           kmous=\\E[M, XM=\\E[?1000%?%p1%{1}%=%th%el%;,
320           xm=\\E[M
321              %?%p4%t%p3%e%{3}%;%'\ '%+%c
322              %p2%'!'%+%c
323              %p1%'!'%+%c,
324
325   xterm+sm+1006|xterm SGR-mouse,
326           kmous=\\E[<, XM=\\E[?1006;1000%?%p1%{1}%=%th%el%;,
327           xm=\\E[<%i%p3%d;
328              %p1%d;
329              %p2%d;
330              %?%p4%tM%em%;,
331 .fi
332 .
333 .SS Extended key-definitions
334 Several terminals provide the ability to send distinct strings for
335 combinations of modified special keys.
336 There is no standard for what those keys can send.
337 .PP
338 Since 1999, \fBxterm\fP(1) has supported
339 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
340 distinct special-key strings.
341 In a terminal description, ncurses has no special knowledge of the
342 modifiers used.
343 Applications can use the \fInaming convention\fP established for \fBxterm\fP
344 to find these special keys in the terminal description.
345 .PP
346 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
347 and that shifted special keys are an uppercase name,
348 ncurses' terminal database defines these names to which a suffix is added:
349 .PP
350 .RS 5
351 .TS
352 tab(/) ;
353 l l .
354 \fBName\fP/\fBDescription\fP
355 _
356 kDC/special form of kdch1 (delete character)
357 kDN/special form of kcud1 (cursor down)
358 kEND/special form of kend (End)
359 kHOM/special form of khome (Home)
360 kLFT/special form of kcub1 (cursor-left or cursor-back)
361 kNXT/special form of knext (Next, or Page-Down)
362 kPRV/special form of kprev (Prev, or Page-Up)
363 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
364 kUP/special form of kcuu1 (cursor-up)
365 .TE
366 .RE
367 .PP
368 These are the suffixes used to denote the modifiers:
369 .PP
370 .RS 5
371 .TS
372 tab(/) ;
373 l l .
374 \fBValue\fP/\fBDescription\fP
375 _
376 2/Shift
377 3/Alt
378 4/Shift + Alt
379 5/Control
380 6/Shift + Control
381 7/Alt + Control
382 8/Shift + Alt + Control
383 9/Meta
384 10/Meta + Shift
385 11/Meta + Alt
386 12/Meta + Alt + Shift
387 13/Meta + Ctrl
388 14/Meta + Ctrl + Shift
389 15/Meta + Ctrl + Alt
390 16/Meta + Ctrl + Alt + Shift
391 .TE
392 .RE
393 .PP
394 None of these are predefined; terminal descriptions can refer to \fInames\fP
395 which ncurses will allocate at runtime to \fIkey-codes\fP.
396 To use these keys in an ncurses program, an application could do this:
397 .bP
398 using a list of extended key \fInames\fP,
399 ask \fBtigetstr\fP(3X) for their values, and
400 .bP
401 given the list of values,
402 ask \fBkey_defined\fP(3X) for the \fIkey-code\fP which
403 would be returned for those keys by \fBwgetch\fP(3X).
404 .\"
405 .SH PORTABILITY
406 The \*(``\-x\*('' extension feature of \fB@TIC@\fP and \fB@INFOCMP@\fP
407 has been adopted in NetBSD curses.
408 That implementation stores user-defined capabilities,
409 but makes no use of these capabilities itself.
410 .\"
411 .SH SEE ALSO
412 \fB@INFOCMP@\fP(1M),
413 \fB@TIC@\fP(1M).
414 .PP
415 The terminal database section
416 .I "NCURSES USER-DEFINABLE CAPABILITIES"
417 summarizes commonly-used user-defined capabilities
418 which are used in the terminal descriptions.
419 Some of those features are mentioned in \fBscreen\fP(1) or \fBtmux\fP(1).
420 .PP
421 .I "XTerm Control Sequences"
422 provides further information on the \fBxterm\fP(1) features
423 which are used in these extended capabilities.
424 .\"
425 .SH AUTHORS
426 Thomas E. Dickey
427 .br
428 beginning with ncurses 5.0 (1999)