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