]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_variables.3x
ncurses 6.4 - patch 20240414
[ncurses.git] / man / curs_variables.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 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.47 2024/04/13 22:37:35 tom Exp $
31 .TH curs_variables 3X 2024-04-13 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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 .SH NAME
52 \fI\%bool\fP,
53 \fI\%chtype\fP,
54 \fI\%cchar_t\fP,
55 \fI\%attr_t\fP,
56 \fI\%SCREEN\fP,
57 \fI\%WINDOW\fP,
58 \fB\%TRUE\fP,
59 \fB\%FALSE\fP,
60 \fB\%ERR\fP,
61 \fB\%OK\fP,
62 \fB\%curscr\fP,
63 \fB\%newscr\fP,
64 \fB\%stdscr\fP,
65 \fB\%COLORS\fP,
66 \fB\%COLOR_PAIRS\fP,
67 \fB\%COLS\fP,
68 \fB\%LINES\fP,
69 \fB\%ESCDELAY\fP,
70 \fB\%TABSIZE\fP \-
71 \fIcurses\fR data types, constants, and global variables
72 .SH SYNOPSIS
73 .nf
74 \fB#include <curses.h>
75 .PP
76 \fI/* data types */
77 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP bool;
78 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP chtype;
79 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP cchar_t;
80 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP attr_t;
81 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP SCREEN;
82 \fBtypedef \fI/*\fP .\|.\|. \fI*/\fP WINDOW;
83 .PP
84 \fI/* constants */
85 \fBconst bool TRUE;
86 \fBconst bool FALSE;
87 .PP
88 \fBconst \fI/*\fP .\|.\|. \fI*/\fP ERR;
89 \fBconst \fI/*\fP .\|.\|. \fI*/\fP OK;
90 .PP
91 \fI/* variables */
92 \fBint COLORS;
93 \fBint COLOR_PAIRS;
94 \fBint COLS;
95 \fBint LINES;
96 \fBWINDOW * curscr;
97 \fBWINDOW * stdscr;
98 .PP
99 \fI/* extensions */
100 \fBint ESCDELAY;
101 \fBint TABSIZE;
102 \fBWINDOW * newscr;
103 .fi
104 .SH DESCRIPTION
105 This page summarizes data types,
106 constants,
107 and variables provided by the \fIcurses\fP library.
108 Locate further discussion in \fB\%curses\fP(3X).
109 .PP
110 Depending on \fI\%ncurses\fP's build-time configuration,
111 the variables may instead be
112 macros (see \fB\%curs_threads\fP(3X) and \fB\%curs_opaque\fP(3X))
113 that provide read-only access to the library's state.
114 In either case,
115 applications should treat them as read-only to avoid
116 confusing the library.
117 .SH "CONSTANTS"
118 .SS "TRUE, FALSE"
119 The \fIcurses\fP library defines \fBTRUE\fP and \fBFALSE\fP
120 to represent the values of the Boolean data type.
121 .SS "ERR, OK"
122 \fIcurses\fP and \fIterminfo\fP routines frequently return these
123 constant integral values indicating failure and success,
124 respectively.
125 .SH "PREDEFINED TYPES"
126 .SS "\fIbool\fP"
127 X/Open Issue 4 \fIcurses\fP (1996) preceded the ISO C99 and ISO C++98
128 standards,
129 each of which also defined a Boolean data type.
130 The \fIcurses\fP library requires an integral type \fIbool\fP.
131 .PP
132 \fB\%ncurses\fP' configure script attempts to discover the
133 data type used by the system's C and C++ compilers,
134 to reuse for the \fIcurses\fP \fIbool\fP.
135 .SS "\fIchtype\fP"
136 The \fI\%chtype\fP integral type combines a
137 (\*(``narrow\*('',
138 8-bit)
139 character with attributes encoding the character's \fIrendition\fP,
140 such as the styling of its typeface and/or foreground and background
141 colors.
142 See,
143 for example,
144 \fB\%addch\fP(3X),
145 \fB\%attron\fP(3X),
146 and
147 \fB\%inch\fP(3X).
148 .SS "\fIcchar_t\fP, \fIattr_t\fP"
149 \fI\%chtype\fP is too small for the standard C library's wide-character
150 type,
151 \fIwchar_t\fP.
152 \fI\%cchar_t\fP is a type that can accommodate an \fI\%attr_t\fP and
153 enough wide characters to store what Unicode terms a \fIgrapheme cluster\fP
154 (a \*(``user-perceived character\*('' [UAX #29],
155 which may nevertheless require several character encoding units to
156 represent).
157 \fI\%attr_t\fP is an integral type storing \*(``wide\*('' attributes that
158 apply to \fI\%cchar_t\fPs.
159 See,
160 for example,
161 \fB\%add_wch\fP(3X),
162 \fB\%attr_on\fP(3X),
163 and
164 \fB\%in_wch\fP(3X).
165 .SS "\fISCREEN\fP"
166 .I curses
167 manages a terminal device with this structure type;
168 see \fB\%initscr\fP(3X).
169 .SS "\fIWINDOW\fP"
170 .I curses
171 represents rectangular portions of the terminal screen with the
172 .I \%WINDOW
173 structure type;
174 see subsection \*(``Overview\*('' of \fB\%ncurses\fP(3X).
175 .SH "VARIABLES"
176 .SS "curscr, stdscr, newscr"
177 The library records updates to the terminal screen in a window named
178 \fB\%curscr\fP.
179 This object is referred to as the \*(``physical screen\*('' in
180 \fB\%curs_refresh\fP(3X) and
181 \fB\%curs_outopts\fP(3X).
182 .PP
183 \fI\%ncurses\fP collects pending updates to the terminal screen in a
184 window named \fB\%newscr\fP.
185 This object is referred to as the \*(``virtual screen\*('' in the
186 \fB\%curs_kernel\fP(3X),
187 \fB\%curs_refresh\fP(3X),
188 and
189 \fB\%curs_outopts\fP(3X).
190 When the screen is refreshed,
191 \fIcurses\fP determines a minimal set of updates using the terminal's
192 capabilities to make \fB\%curscr\fP look like \fB\%newscr\fP.
193 .PP
194 Once \fIcurses\fP is initialized,
195 it creates a window named \fB\%stdscr\fP.
196 It is the same size as the terminal screen and is the default window
197 used by routines that do not take a parameter identifying one.
198 Many \fIcurses\fP functions use this window.
199 .SS COLORS
200 Once \fIcurses\fP is initialized,
201 \fB\%COLORS\fP
202 contains the number of colors supported by the terminal;
203 see \fB\%curs_color\fP(3X).
204 .SS COLOR_PAIRS
205 Once \fIcurses\fP is initialized,
206 \fB\%COLOR_PAIRS\fP
207 contains the number of color pairs supported by the terminal;
208 see \fB\%curs_color\fP(3X).
209 .SS "COLS, LINES"
210 Once \fIcurses\fP is initialized,
211 .B \%COLS
212 and
213 .B LINES
214 contain the screen's width and height in character cells,
215 respectively;
216 that is,
217 the number of columns and lines.
218 .SS ESCDELAY
219 For
220 .I curses
221 to distinguish the ESC character resulting from a user's press of the
222 \*(``Escape\*('' key on the input device from one beginning an
223 .I "escape sequence"
224 (as commonly produced by function keys),
225 it waits after the escape character to see if further characters are
226 available on the input stream within a short interval.
227 .B \%ESCDELAY
228 stores this interval in milliseconds.
229 .PP
230 If \fB\%keypad\fP(3X) is disabled for the
231 .I curses
232 window receiving input,
233 a program must disambiguate escape sequences itself.
234 .SS TABSIZE
235 The \fIcurses\fP library converts a tab character to this number of
236 spaces as it adds a tab to a window;
237 see \fB\%curs_addch\fP(3X).
238 .SH NOTES
239 Either \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X) initializes
240 \fIcurses\fP.
241 .PP
242 If
243 .I \%ncurses
244 is configured to provide separate
245 .I curses
246 and
247 .I \%tinfo
248 libraries,
249 most of these variables reside in the former.
250 .SH PORTABILITY
251 The X/Open Curses standard documents all of the foregoing types and
252 symbols except for \fB\%newscr\fP,
253 \fB\%TABSIZE\fP,
254 and \fB\%ESCDELAY\fP.
255 .PP
256 X/Open Curses describes \fB\%curscr\fP only as \*(``an internal data
257 structure\*('';
258 SVr4 gave more details,
259 noting its use \*(``for certain low-level operations like clearing and
260 redrawing a screen containing garbage\*(''.
261 .\" SVID 4, Volume 3, p. 408
262 Neither specified its interaction with the rest of the interface beyond
263 use as an argument to \fB\%clearok\fP(3X) and \fB\%wrefresh\fP(3X).
264 .PP
265 \fB\%newscr\fP is a feature of SVr4 \fIcurses\fP.
266 When refreshing the screen,
267 it is used as a working area for combining the standard window
268 \fB\%stdscr\fP with any others the application may have created with
269 \fB\%newwin\fP(3X).
270 When the update of \fB\%newscr\fP is complete,
271 \fIcurses\fP modifies \fB\%curscr\fP to match \fB\%newscr\fP.
272 .PP
273 \fB\%TABSIZE\fP is a feature of SVr4 \fIcurses\fP.
274 .bP
275 SVr4 initially sets \fB\%TABSIZE\fP from the terminal description's
276 \fB\%init_tabs\fP capability.
277 After that,
278 it can be altered by applications using SVr4 \fIcurses\fP.
279 .bP
280 SVr4 \fIcurses\fP uses the value of \fB\%TABSIZE\fP to compute the
281 position of tab stops when updating both
282 the virtual screen with \fB\%addch\fP(3X) and
283 the physical screen with \fB\%mvcur\fP(3X).
284 .bP
285 \fI\%ncurses\fP uses the value of \fB\%TABSIZE\fP only to update the
286 virtual screen.
287 It uses the terminal description's \*(``\fBit\fP\*(''
288 (\fB\%init_tabs\fP) capability for computing hardware tabs
289 (that is,
290 tab stops on the physical screen).
291 .bP
292 Other implementations differ.
293 For instance,
294 NetBSD \fIcurses\fP allows \fB\%TABSIZE\fP to be set through an
295 environment variable.
296 \fI\%ncurses\fP does not.
297 .IP
298 NetBSD \fIcurses\fP does not support hardware tabs;
299 it uses the \fB\%init_tabs\fP capability and the \fB\%TABSIZE\fP
300 variable only for updating the virtual screen.
301 .PP
302 \fB\%ESCDELAY\fP is a feature of AIX \fIcurses\fP.
303 .bP
304 In AIX,
305 the units for \fB\%ESCDELAY\fP are \fIfifths\fP of milliseconds.
306 .bP
307 The default value for AIX's \fB\%ESCDELAY\fP equals 0.1 seconds.
308 .bP
309 AIX also enforces a limit of 10,000 seconds for \fB\%ESCDELAY\fP;
310 \fI\%ncurses\fP does not enforce any upper limit.
311 .PP
312 \fI\%ncurses\fP has long used \fB\%ESCDELAY\fP with units of
313 milliseconds,
314 making it impossible to be completely compatible with AIX.
315 Consequently,
316 most users have decided either to override the value,
317 or to rely upon its default.
318 .SH SEE ALSO
319 \fB\%curses\fP(3X),
320 \fB\%curs_color\fP(3X),
321 \fB\%curs_opaque\fP(3X),
322 \fB\%curs_terminfo\fP(3X),
323 \fB\%curs_threads\fP(3X),
324 \fB\%term_variables\fP(3X),
325 \fB\%terminfo\fP(5)
326 .PP
327 [UAX #29] \*(``Unicode Standard Annex #29: Unicode Text
328 Segmentation\*('';
329 \%<https://\*:unicode\*:.org/\*:reports/\*:tr29/>