]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/user_caps.5
ncurses 6.4 - patch 20230701
[ncurses.git] / man / user_caps.5
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 2017 Free Software Foundation, Inc.                            *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: user_caps.5,v 1.27 2023/07/01 15:46:10 tom Exp $
31 .TH user_caps 5 2023-07-01 "ncurses 6.4" "File formats"
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de NS
37 .ie n  .sp
38 .el    .sp .5
39 .ie n  .in +4
40 .el    .in +2
41 .nf
42 .ft CR                  \" Courier
43 ..
44 .de NE
45 .fi
46 .ft R
47 .ie n  .in -4
48 .el    .in -2
49 ..
50 .de bP
51 .ie n  .IP \(bu 4
52 .el    .IP \(bu 2
53 ..
54 .SH NAME
55 user_caps \- user-defined terminfo capabilities
56 .SH SYNOPSIS
57 .B @TIC@ -x, @INFOCMP@ -x
58 .SH DESCRIPTION
59 .SS Background
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(1).
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(1) 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 The ncurses library uses the user-definable capabilities.
191 While the terminfo database may have other extensions,
192 ncurses makes explicit checks for these:
193 .RS 3
194 .TP 3
195 AX
196 \fIboolean\fP, asserts that the terminal interprets SGR 39 and SGR 49
197 by resetting the foreground and background color, respectively, to the default.
198 .IP
199 This is a feature recognized by the \fBscreen\fP program as well.
200 .TP 3
201 E3
202 \fIstring\fP, tells how to clear the terminal's scrollback buffer.
203 When present, the \fBclear\fP(1) program sends this before clearing
204 the terminal.
205 .IP
206 The command \*(``\fBtput clear\fP\*('' does the same thing.
207 .TP 3
208 NQ
209 used to suppress a consistency check in @TIC@ for the ncurses capabilities
210 in user6 through user9 (u6, u7, u8 and u9)
211 which tell how to query the terminal's cursor position
212 and its device attributes.
213 .TP 3
214 RGB
215 \fIboolean\fP, \fInumber\fP \fBor\fP \fIstring\fP,
216 used to assert that the
217 \fBset_a_foreground\fP and
218 \fBset_a_background\fP capabilities correspond to \fIdirect colors\fP,
219 using an RGB (red/green/blue) convention.
220 This capability allows the \fBcolor_content\fP function to
221 return appropriate values without requiring the application
222 to initialize colors using \fBinit_color\fP.
223 .IP
224 The capability type determines the values which ncurses sees:
225 .RS 3
226 .TP 3
227 \fIboolean\fP
228 implies that the number of bits for red, green and blue are the same.
229 Using the maximum number of colors,
230 ncurses adds two, divides that sum by three, and assigns the result
231 to red, green and blue in that order.
232 .IP
233 If the number of bits needed for the number of colors is not a multiple
234 of three, the blue (and green) components lose in comparison to red.
235 .TP 3
236 \fInumber\fP
237 tells ncurses what result to add to red, green and blue.
238 If ncurses runs out of bits,
239 blue (and green) lose just as in the \fIboolean\fP case.
240 .TP 3
241 \fIstring\fP
242 explicitly list the number of bits used for red, green and blue components
243 as a slash-separated list of decimal integers.
244 .RE
245 .IP
246 Because there are several RGB encodings in use,
247 applications which make assumptions about the number of bits per color
248 are unlikely to work reliably.
249 As a trivial case, for example, one could define \fBRGB#1\fP
250 to represent the standard eight ANSI colors, i.e., one bit per color.
251 .TP 3
252 U8
253 \fInumber\fP,
254 asserts that ncurses must use Unicode values for line-drawing characters,
255 and that it should ignore the alternate character set capabilities
256 when the locale uses UTF-8 encoding.
257 For more information, see the discussion of
258 \fBNCURSES_NO_UTF8_ACS\fP in \fBncurses\fP(3X).
259 .IP
260 Set this capability to a nonzero value to enable it.
261 .TP 3
262 XM
263 \fIstring\fP,
264 override ncurses's built-in string which
265 enables/disables \fBxterm\fP(1) mouse mode.
266 .IP
267 ncurses sends a character sequence to the terminal to initialize mouse mode,
268 and when the user clicks the mouse buttons or (in certain modes) moves the
269 mouse, handles the characters sent back by the terminal to tell it what
270 was done with the mouse.
271 .IP
272 The mouse protocol is enabled when
273 the \fImask\fP passed in the \fBmousemask\fP function is nonzero.
274 By default, ncurses handles the responses for the X11 xterm mouse protocol.
275 It also knows about the \fISGR 1006\fP xterm mouse protocol,
276 but must to be told to look for this specifically.
277 It will not be able to guess which mode is used,
278 because the responses are enough alike that only confusion would result.
279 .IP
280 The \fBXM\fP capability has a single parameter.
281 If nonzero, the mouse protocol should be enabled.
282 If zero, the mouse protocol should be disabled.
283 ncurses inspects this capability if it is present,
284 to see whether the 1006 protocol is used.
285 If so, it expects the responses to use the \fISGR 1006\fP xterm mouse protocol.
286 .IP
287 The xterm mouse protocol is used by other terminal emulators.
288 The terminal database uses building-blocks for the various xterm mouse
289 protocols which can be used in customized terminal descriptions.
290 .IP
291 The terminal database building blocks for this mouse
292 feature also have an experimental capability \fIxm\fP.
293 The \*(``xm\*('' capability describes the mouse response.
294 Currently there is no interpreter which would use this
295 information to make the mouse support completely data-driven.
296 .IP
297 \fIxm\fP shows the format of the mouse responses.
298 In this experimental capability, the parameters are
299 .RS 5
300 .TP 5
301 .I p1
302 y-ordinate
303 .TP 5
304 .I p2
305 x-ordinate
306 .TP 5
307 .I p3
308 button
309 .TP 5
310 .I p4
311 state, e.g., pressed or released
312 .TP 5
313 .I p5
314 y-ordinate starting region
315 .TP 5
316 .I p6
317 x-ordinate starting region
318 .TP 5
319 .I p7
320 y-ordinate ending region
321 .TP 5
322 .I p8
323 x-ordinate ending region
324 .RE
325 .IP
326 Here are examples from the terminal database for the most commonly used
327 xterm mouse protocols:
328 .IP
329 .nf
330   xterm+x11mouse|X11 xterm mouse protocol,
331           kmous=\\E[M, XM=\\E[?1000%?%p1%{1}%=%th%el%;,
332           xm=\\E[M
333              %?%p4%t%p3%e%{3}%;%'\ '%+%c
334              %p2%'!'%+%c
335              %p1%'!'%+%c,
336
337   xterm+sm+1006|xterm SGR-mouse,
338           kmous=\\E[<, XM=\\E[?1006;1000%?%p1%{1}%=%th%el%;,
339           xm=\\E[<%i%p3%d;
340              %p1%d;
341              %p2%d;
342              %?%p4%tM%em%;,
343 .fi
344 .
345 .SS Extended key-definitions
346 Several terminals provide the ability to send distinct strings for
347 combinations of modified special keys.
348 There is no standard for what those keys can send.
349 .PP
350 Since 1999, \fBxterm\fP(1) has supported
351 \fIshift\fP, \fIcontrol\fP, \fIalt\fP, and \fImeta\fP modifiers which produce
352 distinct special-key strings.
353 In a terminal description, ncurses has no special knowledge of the
354 modifiers used.
355 Applications can use the \fInaming convention\fP established for \fBxterm\fP
356 to find these special keys in the terminal description.
357 .PP
358 Starting with the curses convention that \fIkey names\fP begin with \*(``k\*(''
359 and that shifted special keys are an uppercase name,
360 ncurses' terminal database defines these names to which a suffix is added:
361 .RS 5
362 .TS
363 tab(/) ;
364 l l .
365 \fBName\fP/\fBDescription\fP
366 _
367 kDC/special form of kdch1 (delete character)
368 kDN/special form of kcud1 (cursor down)
369 kEND/special form of kend (End)
370 kHOM/special form of khome (Home)
371 kLFT/special form of kcub1 (cursor-left or cursor-back)
372 kNXT/special form of knext (Next, or Page-Down)
373 kPRV/special form of kprev (Prev, or Page-Up)
374 kRIT/special form of kcuf1 (cursor-right, or cursor-forward)
375 kUP/special form of kcuu1 (cursor-up)
376 .TE
377 .RE
378 .PP
379 These are the suffixes used to denote the modifiers:
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 SEE ALSO
422 \fB@INFOCMP@\fP(1M),
423 \fB@TIC@\fP(1M).
424 .PP
425 The terminal database section
426 .I "NCURSES USER-DEFINABLE CAPABILITIES"
427 summarizes commonly-used user-defined capabilities
428 which are used in the terminal descriptions.
429 Some of those features are mentioned in \fBscreen\fP(1) or \fBtmux\fP(1).
430 .PP
431 .I "XTerm Control Sequences"
432 provides further information on the \fBxterm\fP(1) features
433 which are used in these extended capabilities.
434 .\"
435 .SH AUTHORS
436 Thomas E. Dickey
437 .br
438 beginning with ncurses 5.0 (1999)