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