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