blob: 467b694445651daa5ae73c4fc5da730933d557ea [file] [log] [blame]
Steve Kondikae271bc2015-11-15 02:50:53 +01001.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 2010-2015,2017 Free Software Foundation, Inc. *
Steve Kondikae271bc2015-11-15 02:50:53 +01004.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $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.
Steve Kondikae271bc2015-11-15 02:50:53 +010046.de bP
micky3879b9f5e72025-07-08 18:04:53 -040047.ie n .IP \(bu 4
48.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010049..
micky3879b9f5e72025-07-08 18:04:53 -040050.
Steve Kondikae271bc2015-11-15 02:50:53 +010051.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040052\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
Steve Kondikae271bc2015-11-15 02:50:53 +010072.SH SYNOPSIS
73.nf
micky3879b9f5e72025-07-08 18:04:53 -040074\fB#include <curses.h>
Steve Kondikae271bc2015-11-15 02:50:53 +010075.PP
micky3879b9f5e72025-07-08 18:04:53 -040076\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;
Steve Kondikae271bc2015-11-15 02:50:53 +0100103.fi
104.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -0400105This page summarizes data types,
106constants,
107and variables provided by the \fIcurses\fP library.
108Locate further discussion in \fB\%curses\fP(3X).
Steve Kondikae271bc2015-11-15 02:50:53 +0100109.PP
micky3879b9f5e72025-07-08 18:04:53 -0400110Depending on \fI\%ncurses\fP's build-time configuration,
111the variables may instead be
112macros (see \fB\%curs_threads\fP(3X) and \fB\%curs_opaque\fP(3X))
113that provide read-only access to the library's state.
114In either case,
115applications should treat them as read-only to avoid
Steve Kondikae271bc2015-11-15 02:50:53 +0100116confusing the library.
micky3879b9f5e72025-07-08 18:04:53 -0400117.SH "CONSTANTS"
118.SS "TRUE, FALSE"
119The \fIcurses\fP library defines \fBTRUE\fP and \fBFALSE\fP
120to represent the values of the Boolean data type.
121.SS "ERR, OK"
122\fIcurses\fP and \fIterminfo\fP routines frequently return these
123constant integral values indicating failure and success,
124respectively.
125.SH "PREDEFINED TYPES"
126.SS "\fIbool\fP"
127X/Open Issue 4 \fIcurses\fP (1996) preceded the ISO C99 and ISO C++98
128standards,
129each of which also defined a Boolean data type.
130The \fIcurses\fP library requires an integral type \fIbool\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +0100131.PP
micky3879b9f5e72025-07-08 18:04:53 -0400132\fB\%ncurses\fP' configure script attempts to discover the
133data type used by the system's C and C++ compilers,
134to reuse for the \fIcurses\fP \fIbool\fP.
135.SS "\fIchtype\fP"
136The \fI\%chtype\fP integral type combines a
137(\*(``narrow\*('',
1388-bit)
139character with attributes encoding the character's \fIrendition\fP,
140such as the styling of its typeface and/or foreground and background
141colors.
142See,
143for example,
144\fB\%addch\fP(3X),
145\fB\%attron\fP(3X),
146and
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
150type,
151\fIwchar_t\fP.
152\fI\%cchar_t\fP is a type that can accommodate an \fI\%attr_t\fP and
153enough wide characters to store what Unicode terms a \fIgrapheme cluster\fP
154(a \*(``user-perceived character\*('' [UAX #29],
155which may nevertheless require several character encoding units to
156represent).
157\fI\%attr_t\fP is an integral type storing \*(``wide\*('' attributes that
158apply to \fI\%cchar_t\fPs.
159See,
160for example,
161\fB\%add_wch\fP(3X),
162\fB\%attr_on\fP(3X),
163and
164\fB\%in_wch\fP(3X).
165.SS "\fISCREEN\fP"
166.I curses
167manages a terminal device with this structure type;
168see \fB\%initscr\fP(3X).
169.SS "\fIWINDOW\fP"
170.I curses
171represents rectangular portions of the terminal screen with the
172.I \%WINDOW
173structure type;
174see subsection \*(``Overview\*('' of \fB\%ncurses\fP(3X).
175.SH "VARIABLES"
176.SS "curscr, stdscr, newscr"
177The library records updates to the terminal screen in a window named
178\fB\%curscr\fP.
179This 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
184window named \fB\%newscr\fP.
185This object is referred to as the \*(``virtual screen\*('' in the
186\fB\%curs_kernel\fP(3X),
187\fB\%curs_refresh\fP(3X),
188and
189\fB\%curs_outopts\fP(3X).
190When the screen is refreshed,
191\fIcurses\fP determines a minimal set of updates using the terminal's
192capabilities to make \fB\%curscr\fP look like \fB\%newscr\fP.
193.PP
194Once \fIcurses\fP is initialized,
195it creates a window named \fB\%stdscr\fP.
196It is the same size as the terminal screen and is the default window
197used by routines that do not take a parameter identifying one.
198Many \fIcurses\fP functions use this window.
199.SS COLORS
200Once \fIcurses\fP is initialized,
201\fB\%COLORS\fP
202contains the number of colors supported by the terminal;
203see \fB\%curs_color\fP(3X).
204.SS COLOR_PAIRS
205Once \fIcurses\fP is initialized,
206\fB\%COLOR_PAIRS\fP
207contains the number of color pairs supported by the terminal;
208see \fB\%curs_color\fP(3X).
209.SS "COLS, LINES"
210Once \fIcurses\fP is initialized,
211.B \%COLS
212and
213.B LINES
214contain the screen's width and height in character cells,
215respectively;
216that is,
217the number of columns and lines.
218.SS ESCDELAY
219For
220.I curses
221to 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),
225it waits after the escape character to see if further characters are
226available on the input stream within a short interval.
227.B \%ESCDELAY
228stores this interval in milliseconds.
229.PP
230If \fB\%keypad\fP(3X) is disabled for the
231.I curses
232window receiving input,
233a program must disambiguate escape sequences itself.
234.SS TABSIZE
235The \fIcurses\fP library converts a tab character to this number of
236spaces as it adds a tab to a window;
237see \fB\%curs_addch\fP(3X).
238.SH NOTES
239Either \fB\%initscr\fP(3X) or \fB\%newterm\fP(3X) initializes
240\fIcurses\fP.
241.PP
242If
243.I \%ncurses
244is configured to provide separate
245.I curses
246and
247.I \%tinfo
248libraries,
249most of these variables reside in the former.
Steve Kondikae271bc2015-11-15 02:50:53 +0100250.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400251The X/Open Curses standard documents all of the foregoing types and
252symbols except for \fB\%newscr\fP,
253\fB\%TABSIZE\fP,
254and \fB\%ESCDELAY\fP.
255.PP
256X/Open Curses describes \fB\%curscr\fP only as \*(``an internal data
257structure\*('';
258SVr4 gave more details,
259noting its use \*(``for certain low-level operations like clearing and
260redrawing a screen containing garbage\*(''.
261.\" SVID 4, Volume 3, p. 408
262Neither specified its interaction with the rest of the interface beyond
263use 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.
266When refreshing the screen,
267it 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).
270When 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
275SVr4 initially sets \fB\%TABSIZE\fP from the terminal description's
276\fB\%init_tabs\fP capability.
277After that,
278it can be altered by applications using SVr4 \fIcurses\fP.
279.bP
280SVr4 \fIcurses\fP uses the value of \fB\%TABSIZE\fP to compute the
281position of tab stops when updating both
282the virtual screen with \fB\%addch\fP(3X) and
283the physical screen with \fB\%mvcur\fP(3X).
284.bP
285\fI\%ncurses\fP uses the value of \fB\%TABSIZE\fP only to update the
286virtual screen.
287It uses the terminal description's \*(``\fBit\fP\*(''
288(\fB\%init_tabs\fP) capability for computing hardware tabs
289(that is,
290tab stops on the physical screen).
291.bP
292Other implementations differ.
293For instance,
294NetBSD \fIcurses\fP allows \fB\%TABSIZE\fP to be set through an
295environment variable.
296\fI\%ncurses\fP does not.
297.IP
298NetBSD \fIcurses\fP does not support hardware tabs;
299it uses the \fB\%init_tabs\fP capability and the \fB\%TABSIZE\fP
300variable only for updating the virtual screen.
301.PP
302\fB\%ESCDELAY\fP is a feature of AIX \fIcurses\fP.
303.bP
304In AIX,
305the units for \fB\%ESCDELAY\fP are \fIfifths\fP of milliseconds.
306.bP
307The default value for AIX's \fB\%ESCDELAY\fP equals 0.1 seconds.
308.bP
309AIX 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
313milliseconds,
314making it impossible to be completely compatible with AIX.
315Consequently,
316most users have decided either to override the value,
317or to rely upon its default.
Steve Kondikae271bc2015-11-15 02:50:53 +0100318.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400319\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
328Segmentation\*('';
329\%<https://\*:unicode\*:.org/\*:reports/\*:tr29/>