Debian Codegraph @

upstream/opensuse-leap-16-1/man3/curses_variables.3ncurses

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 Thomas E. Dickey *
3 .\" Copyright 2010-2015,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: curs_variables.3x,v 1.62 2025/04/05 22:24:24 tom Exp $
31 .TH curses_variables 3NCURSES 2025-04-05 "ncurses 6.5" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el .ds `` ""
39 .ie t .ds '' ''
40 .el .ds '' ""
41 .\}
42 .
43 .ie \n(.g .ds : \:
44 .el .ds : \" empty
45 .
46 .de bP
47 .ie n .IP \(bu 4
48 .el .IP \(bu 2
49 ..
50 .
51 .\" URL hyperlink support macros from groff's "an-ext.tmac"
52 .
53 .\" Save the automatic hyphenation mode.
54 .\"
55 .\" In AT&T troff, there was no register exposing the hyphenation mode,
56 .\" and no way to save and restore it. Set `mH` to a reasonable value
57 .\" for your implementation and preference.
58 .de mY
59 . ie !\\n(.g \
60 . nr mH 14
61 . el \
62 . do nr mH \\n[.hy] \" groff extension register
63 ..
64 .
65 .\" Prepare link text for mail/web hyperlinks. `MT` and `UR` call this.
66 .de mV
67 . ds mU \\$1\"
68 ..
69 .
70 .\" Emit hyperlink. The optional argument supplies trailing punctuation
71 .\" after link text. `ME` and `UE` call this.
72 .de mQ
73 . mY
74 . nh
75 <\\*(mU>\\$1
76 . hy \\n(mH
77 . rm mU
78 ..
79 .
80 .\" Start URL.
81 .\" .UR url
82 .if !\n(.g \{\
83 .de UR
84 . mV \\$1
85 ..
86 .\}
87 .
88 .\" End URL.
89 .\" .UE [punctuation]
90 .if !\n(.g \{\
91 .de UE
92 . mQ \\$1
93 ..
94 .\}
95 .
96 .SH NAME
97 \fI\%bool\fP,
98 \fI\%chtype\fP,
99 \fI\%cchar_t\fP,
100 \fI\%attr_t\fP,
101 \fI\%SCREEN\fP,
102 \fI\%WINDOW\fP,
103 \fB\%TRUE\fP,
104 \fB\%FALSE\fP,
105 \fB\%ERR\fP,
106 \fB\%OK\fP,
107 \fB\%CCHARW_MAX\fP,
108 \fB\%curscr\fP,
109 \fB\%newscr\fP,
110 \fB\%stdscr\fP,
111 \fB\%COLORS\fP,
112 \fB\%COLOR_PAIRS\fP,
113 \fB\%COLS\fP,
114 \fB\%LINES\fP,
115 \fB\%ESCDELAY\fP,
116 \fB\%TABSIZE\fP \-
117 \fIcurses\fR data types, constants, and global variables
118 .SH SYNOPSIS
119 .nf
120 \fB#include <ncursesw/curses.h>
121 .PP
122 \fI/* data types */
123 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP bool;
124 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP chtype;
125 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP cchar_t;
126 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP attr_t;
127 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP SCREEN;
128 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP WINDOW;
129 .PP
130 \fI/* constants */
131 \fBconst bool TRUE;
132 \fBconst bool FALSE;
133 .PP
134 \fBconst \fI/*\fP .\|.\|. \fI*/\fP ERR;
135 \fBconst \fI/*\fP .\|.\|. \fI*/\fP OK;
136 .PP
137 \fI/* extension */
138 \fBconst \fI/*\fP .\|.\|. \fI*/\fP CCHARW_MAX;
139 .PP
140 \fI/* variables */
141 \fBint COLORS;
142 \fBint COLOR_PAIRS;
143 \fBint COLS;
144 \fBint LINES;
145 \fBWINDOW * curscr;
146 \fBWINDOW * stdscr;
147 .PP
148 \fI/* extensions */
149 \fBint ESCDELAY;
150 \fBint TABSIZE;
151 \fBWINDOW * newscr;
152 .fi
153 .SH DESCRIPTION
154 This page summarizes data types,
155 constants,
156 and variables provided by the \fIcurses\fP library.
157 Locate further discussion in \fB\%ncurses\fP(3NCURSES).
158 .PP
159 Depending on \fI\%ncurses\fP's build-time configuration,
160 the variables may instead be
161 macros (see \fB\%threads\fP(3NCURSES) and \fB\%opaque\fP(3NCURSES))
162 that provide read-only access to the library's state.
163 In either case,
164 applications should treat them as read-only to avoid
165 confusing the library.
166 .SH CONSTANTS
167 .SS "TRUE, FALSE"
168 The \fIcurses\fP library defines \fBTRUE\fP and \fBFALSE\fP
169 to represent the values of the Boolean data type.
170 .SS "ERR, OK"
171 \fIcurses\fP and \fIterminfo\fP routines frequently return these
172 constant integral values indicating failure and success,
173 respectively.
174 .SS CCHARW_MAX
175 This integral value,
176 an
177 .I \%ncurses
178 extension,
179 contains the maximum number of
180 .I \%wchar_t
181 wide characters that can be stored in a
182 .I curses
183 complex character
184 .IR \%cchar_t "."
185 .SH "PREDEFINED TYPES"
186 .SS "\fIbool\fP"
187 X/Open Issue\ 4 \fIcurses\fP (1996) preceded the ISO C99 and ISO C++98
188 standards,
189 each of which also defined a Boolean data type.
190 The \fIcurses\fP library requires an integral type \fIbool\fP.
191 .PP
192 \fB\%ncurses\fP' configure script attempts to discover the
193 data type used by the system's C and C++ compilers,
194 to reuse for the \fIcurses\fP \fIbool\fP.
195 .SS "\fIchtype\fP"
196 The \fI\%chtype\fP integral type combines a
197 (\*(``narrow\*('',
198 8-bit)
199 character with attributes encoding the character's \fIrendition\fP,
200 such as the styling of its typeface and/or foreground and background
201 colors.
202 See,
203 for example,
204 \fB\%addch\fP(3NCURSES),
205 \fB\%attron\fP(3NCURSES),
206 and
207 \fB\%inch\fP(3NCURSES).
208 .SS "\fIcchar_t\fP, \fIattr_t\fP"
209 \fI\%chtype\fP is too small for the standard C library's wide-character
210 type,
211 \fIwchar_t\fP.
212 \fI\%cchar_t\fP is a type that can accommodate an \fI\%attr_t\fP and
213 enough wide characters to store what Unicode terms a \fIgrapheme cluster\fP
214 (a \*(``user-perceived character\*('' [UAX #29],
215 which may nevertheless require several character encoding units to
216 represent).
217 \fI\%attr_t\fP is an integral type storing \*(``wide\*('' attributes that
218 apply to \fI\%cchar_t\fPs.
219 See,
220 for example,
221 \fB\%add_wch\fP(3NCURSES),
222 \fB\%attr_on\fP(3NCURSES),
223 and
224 \fB\%in_wch\fP(3NCURSES).
225 .SS "\fISCREEN\fP"
226 .I curses
227 manages a terminal device with this structure type;
228 see \fB\%initscr\fP(3NCURSES).
229 .SS "\fIWINDOW\fP"
230 .I curses
231 represents rectangular portions of the terminal screen with the
232 .I \%WINDOW
233 structure type;
234 see subsection \*(``Overview\*('' of \fB\%ncurses\fP(3NCURSES).
235 .SH "VARIABLES"
236 .SS "curscr, newscr, stdscr"
237 When a
238 .I curses
239 application calls
240 \fB\%initscr\fP(3NCURSES) or \fB\%newterm\fP(3NCURSES),
241 the library creates a window named
242 .B \%stdscr
243 that is the same size as the terminal screen,
244 (minus any lines reserved by
245 \fB\%ripoffline\fP(3NCURSES) or \fB\%slk_init\fP(3NCURSES))
246 and is the implicit window used by functions
247 that interact with a window
248 but do not take a parameter identifying one;
249 many
250 .I curses
251 functions use it.
252 An application need not use
253 .BR \%stdscr ";"
254 it might prefer to tile the display into multiple windows instead.
255 .PP
256 The library records updates to the terminal screen in a window named
257 \fB\%curscr\fP.
258 This object is referred to as the \*(``physical screen\*('' in
259 \fB\%refresh\fP(3NCURSES) and
260 \fB\%outopts\fP(3NCURSES).
261 .PP
262 \fI\%ncurses\fP collects pending updates to the terminal screen in a
263 window named \fB\%newscr\fP.
264 This object is referred to as the \*(``virtual screen\*('' in the
265 \fB\%kernel\fP(3NCURSES),
266 \fB\%refresh\fP(3NCURSES),
267 and
268 \fB\%outopts\fP(3NCURSES).
269 When the screen is refreshed,
270 \fIcurses\fP determines a minimal set of updates using the terminal's
271 capabilities to make \fB\%curscr\fP look like \fB\%newscr\fP.
272 .SS COLORS
273 Once \fIcurses\fP is initialized,
274 \fB\%COLORS\fP
275 contains the number of colors supported by the terminal;
276 see \fB\%color\fP(3NCURSES).
277 .SS COLOR_PAIRS
278 Once \fIcurses\fP is initialized,
279 \fB\%COLOR_PAIRS\fP
280 contains the number of color pairs supported by the terminal;
281 see \fB\%color\fP(3NCURSES).
282 .SS "COLS, LINES"
283 Once \fIcurses\fP is initialized,
284 .B \%COLS
285 and
286 .B LINES
287 contain the screen's width and height in character cells,
288 respectively;
289 that is,
290 the number of columns and lines.
291 .SS ESCDELAY
292 When reading key strokes from a window in keypad mode,
293 .I curses
294 distinguishes the ESC character resulting from a user's press of the
295 \*(``Escape\*('' key on the input device
296 from one beginning an escape sequence
297 (commonly produced by function keys),
298 by waiting after the escape character
299 to see if further characters are available
300 on the input stream within a short interval.
301 .B \%ESCDELAY
302 stores this interval in milliseconds.
303 .PP
304 If \fB\%keypad\fP(3NCURSES) is disabled for the
305 .I curses
306 window receiving input,
307 a program must disambiguate escape sequences itself.
308 .SS TABSIZE
309 The \fIcurses\fP library converts a tab character to this number of
310 spaces as it adds a tab to a window;
311 see \fB\%addch\fP(3NCURSES).
312 .SH NOTES
313 Either \fB\%initscr\fP(3NCURSES) or \fB\%newterm\fP(3NCURSES) initializes
314 \fIcurses\fP.
315 .PP
316 If
317 .I \%ncurses
318 is configured to provide separate
319 .I curses
320 and
321 .I \%tinfo
322 libraries,
323 most of these symbols reside in the former.
324 The
325 .B bool
326 data type
327 is used by both.
328 .SH EXTENSIONS
329 The
330 .B \%CCHARW_MAX
331 constant,
332 and
333 .BR \%ESCDELAY ","
334 .BR \%TABSIZE ","
335 and
336 .B \%newscr
337 variables,
338 are
339 extensions,
340 the first of these originating in
341 .\" Solaris xcurses calls it M_CCHAR_MAX.
342 .IR \%ncurses "."
343 .SH PORTABILITY
344 Applications employing
345 .I \%ncurses
346 extensions should condition their use on the visibility of the
347 .B \%NCURSES_VERSION
348 preprocessor macro.
349 .PP
350 The X/Open Curses standard documents all of the foregoing types and
351 symbols except for
352 .BR \%CCHARW_MAX ","
353 .BR \%newscr ","
354 .BR \%TABSIZE ","
355 and
356 .BR \%ESCDELAY "."
357 .PP
358 X/Open Curses describes \fB\%curscr\fP only as \*(``an internal data
359 structure\*('';
360 SVr4 gave more details,
361 noting its use \*(``for certain low-level operations like clearing and
362 redrawing a screen containing garbage\*(''.
363 .\" SVID 4, Volume 3, p. 408
364 Neither specified its interaction with the rest of the interface beyond
365 use as an argument to \fB\%clearok\fP(3NCURSES) and \fB\%wrefresh\fP(3NCURSES).
366 .PP
367 \fB\%newscr\fP is a feature of SVr4 \fIcurses\fP.
368 When refreshing the screen,
369 it is used as a working area for combining the standard window
370 \fB\%stdscr\fP with any others the application may have created with
371 \fB\%newwin\fP(3NCURSES).
372 When the update of \fB\%newscr\fP is complete,
373 \fIcurses\fP modifies \fB\%curscr\fP to match \fB\%newscr\fP.
374 .PP
375 \fB\%TABSIZE\fP is a feature of SVr4 \fIcurses\fP.
376 .bP
377 SVr4 initially sets \fB\%TABSIZE\fP from the terminal description's
378 \fB\%init_tabs\fP capability.
379 After that,
380 it can be altered by applications using SVr4 \fIcurses\fP.
381 .bP
382 SVr4 \fIcurses\fP uses the value of \fB\%TABSIZE\fP to compute the
383 position of tab stops when updating both
384 the virtual screen with \fB\%addch\fP(3NCURSES) and
385 the physical screen with \fB\%mvcur\fP(3NCURSES).
386 .bP
387 \fI\%ncurses\fP uses the value of \fB\%TABSIZE\fP only to update the
388 virtual screen.
389 It uses the terminal description's \*(``\fBit\fP\*(''
390 \%(\fBinit_tabs\fP) capability for computing hardware tabs
391 (that is,
392 tab stops on the physical screen).
393 .bP
394 Other implementations differ.
395 For instance,
396 NetBSD \fIcurses\fP allows \fB\%TABSIZE\fP to be set through an
397 environment variable.
398 \fI\%ncurses\fP does not.
399 .IP
400 NetBSD \fIcurses\fP does not support hardware tabs;
401 it uses the \fB\%init_tabs\fP capability and the \fB\%TABSIZE\fP
402 variable only for updating the virtual screen.
403 .PP
404 \fB\%ESCDELAY\fP is a feature of AIX \fIcurses\fP.
405 .bP
406 In AIX,
407 the units for \fB\%ESCDELAY\fP are \fIfifths\fP of milliseconds.
408 .bP
409 The default value for AIX's \fB\%ESCDELAY\fP equals 0.1 seconds.
410 .bP
411 AIX also enforces a limit of 10,000 seconds for \fB\%ESCDELAY\fP;
412 \fI\%ncurses\fP does not enforce any upper limit.
413 .PP
414 \fI\%ncurses\fP has long used \fB\%ESCDELAY\fP with units of
415 milliseconds,
416 making it impossible to be completely compatible with AIX.
417 Consequently,
418 most users have decided either to override the value,
419 or to rely upon its default.
420 .SH SEE ALSO
421 .UR https://\*:unicode\*:.org/\*:reports/\*:tr29/
422 [UAX #29] \*(``Unicode Standard Annex #29: Unicode Text
423 Segmentation\*(''
424 .UE
425 .PP
426 \fB\%getcchar\fP(3NCURSES)
427 further discusses the
428 .I \%ncurses
429 extension
430 .BR \%CCHARW_MAX "."
431 .PP
432 \fB\%ncurses\fP(3NCURSES),
433 \fB\%color\fP(3NCURSES),
434 \fB\%opaque\fP(3NCURSES),
435 \fB\%terminfo\fP(3NCURSES),
436 \fB\%threads\fP(3NCURSES),
437 \fB\%terminfo_variables\fP(3NCURSES),
438 \fB\%terminfo\fP(5)