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