]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_variables.3x
ncurses 6.4 - patch 20240106
[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.43 2024/01/05 21:46:58 tom Exp $
31 .TH curs_variables 3X 2024-01-05 "ncurses 6.4" "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 \fIcurses\fP to distinguish an escape character corresponding to a
220 user's press of an \*(``Escape\*('' key on the input device from one
221 included in a control sequence used by a cursor movement or function
222 key,
223 the library waits to see if another key event occurs after the escape
224 character.
225 \fB\%ESCDELAY\fP
226 stores this interval in milliseconds.
227 .SS TABSIZE
228 The \fIcurses\fP library converts a tab character to this number of
229 spaces as it adds a tab to a window;
230 see \fB\%curs_addch\fP(3X).
231 .SH NOTES
232 Either \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X) initializes
233 \fIcurses\fP.
234 .PP
235 If \fI\%ncurses\fP is configured to provide separate \fIcurses\fP and
236 \fIterminfo\fP libraries,
237 most of these variables reside in the \fIcurses\fP library.
238 .SH PORTABILITY
239 The X/Open Curses standard documents all of the foregoing types and
240 symbols except for \fB\%newscr\fP,
241 \fB\%TABSIZE\fP,
242 and \fB\%ESCDELAY\fP.
243 .PP
244 X/Open Curses describes \fB\%curscr\fP only as \*(``an internal data
245 structure\*('';
246 SVr4 gave more details,
247 noting its use \*(``for certain low-level operations like clearing and
248 redrawing a screen containing garbage\*(''.
249 .\" SVID 4, Volume 3, p. 408
250 Neither specified its interaction with the rest of the interface beyond
251 use as an argument to \fB\%clearok\fP(3X) and \fB\%wrefresh\fP(3X).
252 .PP
253 \fB\%newscr\fP is a feature of SVr4 \fIcurses\fP.
254 When refreshing the screen,
255 it is used as a working area for combining the standard window
256 \fB\%stdscr\fP with any others the application may have created with
257 \fB\%newwin\fP(3X).
258 When the update of \fB\%newscr\fP is complete,
259 \fIcurses\fP modifies \fB\%curscr\fP to match \fB\%newscr\fP.
260 .PP
261 \fB\%TABSIZE\fP is a feature of SVr4 \fIcurses\fP.
262 .bP
263 SVr4 initially sets \fB\%TABSIZE\fP from the terminal description's
264 \fB\%init_tabs\fP capability.
265 After that,
266 it can be altered by applications using SVr4 \fIcurses\fP.
267 .bP
268 SVr4 \fIcurses\fP uses the value of \fB\%TABSIZE\fP to compute the
269 position of tab stops when updating both
270 the virtual screen with \fB\%addch\fP(3X) and
271 the physical screen with \fB\%mvcur\fP(3X).
272 .bP
273 \fI\%ncurses\fP uses the value of \fB\%TABSIZE\fP only to update the
274 virtual screen.
275 It uses the terminal description's \*(``\fBit\fP\*(''
276 (\fB\%init_tabs\fP) capability for computing hardware tabs
277 (that is,
278 tab stops on the physical screen).
279 .bP
280 Other implementations differ.
281 For instance,
282 NetBSD \fIcurses\fP allows \fB\%TABSIZE\fP to be set through an
283 environment variable.
284 \fI\%ncurses\fP does not.
285 .IP
286 NetBSD \fIcurses\fP does not support hardware tabs;
287 it uses the \fB\%init_tabs\fP capability and the \fB\%TABSIZE\fP
288 variable only for updating the virtual screen.
289 .PP
290 \fB\%ESCDELAY\fP is a feature of AIX \fIcurses\fP.
291 .bP
292 In AIX,
293 the units for \fB\%ESCDELAY\fP are \fIfifths\fP of milliseconds.
294 .bP
295 The default value for AIX's \fB\%ESCDELAY\fP equals 0.1 seconds.
296 .bP
297 AIX also enforces a limit of 10,000 seconds for \fB\%ESCDELAY\fP;
298 \fI\%ncurses\fP does not enforce any upper limit.
299 .PP
300 \fI\%ncurses\fP has long used \fB\%ESCDELAY\fP with units of
301 milliseconds,
302 making it impossible to be completely compatible with AIX.
303 Consequently,
304 most users have decided either to override the value,
305 or to rely upon its default.
306 .SH SEE ALSO
307 \fB\%curses\fP(3X),
308 \fB\%curs_color\fP(3X),
309 \fB\%curs_opaque\fP(3X),
310 \fB\%curs_terminfo\fP(3X),
311 \fB\%curs_threads\fP(3X),
312 \fB\%term_variables\fP(3X),
313 \fB\%terminfo\fP(5)
314 .PP
315 [UAX #29] \*(``Unicode Standard Annex #29: Unicode Text
316 Segmentation\*('';
317 \%<https://\*:unicode\*:.org/\*:reports/\*:tr29/>