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