jcs's openbsd hax
openbsd
1'\" t
2.\" $OpenBSD: curses.3,v 1.6 2023/10/17 09:52:08 nicm Exp $
3.\"
4.\"***************************************************************************
5.\" Copyright 2018-2021,2023 Thomas E. Dickey *
6.\" Copyright 1998-2015,2017 Free Software Foundation, Inc. *
7.\" *
8.\" Permission is hereby granted, free of charge, to any person obtaining a *
9.\" copy of this software and associated documentation files (the *
10.\" "Software"), to deal in the Software without restriction, including *
11.\" without limitation the rights to use, copy, modify, merge, publish, *
12.\" distribute, distribute with modifications, sublicense, and/or sell *
13.\" copies of the Software, and to permit persons to whom the Software is *
14.\" furnished to do so, subject to the following conditions: *
15.\" *
16.\" The above copyright notice and this permission notice shall be included *
17.\" in all copies or substantial portions of the Software. *
18.\" *
19.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
20.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
21.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
22.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
23.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
24.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
25.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
26.\" *
27.\" Except as contained in this notice, the name(s) of the above copyright *
28.\" holders shall not be used in advertising or otherwise to promote the *
29.\" sale, use or other dealings in this Software without prior written *
30.\" authorization. *
31.\"***************************************************************************
32.\"
33.\" $Id: curses.3,v 1.6 2023/10/17 09:52:08 nicm Exp $
34.hy 0
35.TH ncurses 3 2023-08-19 "ncurses 6.4" "Library calls"
36.ie \n(.g .ds `` \(lq
37.el .ds `` ``
38.ie \n(.g .ds '' \(rq
39.el .ds '' ''
40.de bP
41.ie n .IP \(bu 4
42.el .IP \(bu 2
43..
44.de NS
45.ie n .sp
46.el .sp .5
47.ie n .in +4
48.el .in +2
49.nf
50.ft CR \" Courier
51..
52.de NE
53.fi
54.ft R
55.ie n .in -4
56.el .in -2
57..
58.ds n 5
59.ds d /usr/share/terminfo
60.SH NAME
61\fBncurses\fP \- CRT screen handling and optimization package
62.SH SYNOPSIS
63\fB#include <curses.h>\fP
64.SH DESCRIPTION
65The \fBncurses\fP library routines give the user a terminal-independent method
66of updating character screens with reasonable optimization.
67This implementation is \*(``new curses\*('' (ncurses) and
68is the approved replacement for
694.4BSD classic curses, which has been discontinued.
70This describes \fBncurses\fP
71version 6.4 (patch 20230826).
72.PP
73The \fBncurses\fP library emulates the curses library of
74System V Release 4 UNIX,
75and XPG4 (X/Open Portability Guide) curses (also known as XSI curses).
76XSI stands for X/Open System Interfaces Extension.
77The \fBncurses\fP library is freely redistributable in source form.
78Differences from the SVr4
79curses are summarized under the
80\fIEXTENSIONS\fP and \fIPORTABILITY\fP sections below and
81described in detail in the respective
82\fIEXTENSIONS\fP, \fIPORTABILITY\fP and \fIBUGS\fP sections
83of individual man pages.
84.PP
85The \fBncurses\fP library also provides many useful extensions,
86i.e., features which cannot be implemented by a simple add-on library
87but which require access to the internals of the library.
88.PP
89A program using these routines must be linked with the \fB\-lncurses\fP option,
90or (if it has been generated) with the debugging library \fB\-lncurses_g\fP.
91(Your system integrator may also have installed these libraries under
92the names \fB\-lcurses\fP and \fB\-lcurses_g\fP.)
93The ncurses_g library generates trace logs
94(in a file called \*(``trace\*('' in the current directory)
95that describe curses actions.
96See also the section on \fBALTERNATE CONFIGURATIONS\fP.
97.PP
98The \fBncurses\fP package supports: overall screen, window and pad
99manipulation; output to windows and pads; reading terminal input; control over
100terminal and \fBcurses\fP input and output options; environment query
101routines; color manipulation; use of soft label keys; terminfo capabilities;
102and access to low-level terminal-manipulation routines.
103.SS Initialization
104The library uses the locale which the calling program has initialized.
105That is normally done with \fBsetlocale\fP(3):
106.NS
107\fBsetlocale(LC_ALL, "");\fP
108.NE
109.PP
110If the locale is not initialized,
111the library assumes that characters are printable as in ISO\-8859\-1,
112to work with certain legacy programs.
113You should initialize the locale and not rely on specific details of
114the library when the locale has not been setup.
115.PP
116The function \fBinitscr\fP or \fBnewterm\fP
117must be called to initialize the library
118before any of the other routines that deal with windows
119and screens are used.
120The routine \fBendwin\fP(3) must be called before exiting.
121.PP
122To get character-at-a-time input without echoing (most
123interactive, screen oriented programs want this), the following
124sequence should be used:
125.NS
126\fBinitscr(); cbreak(); noecho();\fP
127.NE
128.PP
129Most programs would additionally use the sequence:
130.NS
131\fBintrflush(stdscr, FALSE);\fP
132\fBkeypad(stdscr, TRUE);\fP
133.NE
134.PP
135Before a \fBcurses\fP program is run, the tab stops of the terminal
136should be set and its initialization strings, if defined, must be output.
137This can be done by executing the \fBtput init\fP command
138after the shell environment variable \fBTERM\fP has been exported.
139\fBtset(1)\fP is usually responsible for doing this.
140[See \fBterminfo\fP(\*n) for further details.]
141.SS Datatypes
142The \fBncurses\fP library permits manipulation of data structures,
143called \fIwindows\fP, which can be thought of as two-dimensional
144arrays of characters representing all or part of a CRT screen.
145A default window called \fBstdscr\fP, which is the size of the terminal
146screen, is supplied.
147Others may be created with \fBnewwin\fP.
148.PP
149Note that \fBcurses\fP does not handle overlapping windows, that's done by
150the \fBpanel\fP(3) library.
151This means that you can either use
152\fBstdscr\fP or divide the screen into tiled windows and not using
153\fBstdscr\fP at all.
154Mixing the two will result in unpredictable, and undesired, effects.
155.PP
156Windows are referred to by variables declared as \fBWINDOW *\fP.
157These data structures are manipulated with routines described here and
158elsewhere in the \fBncurses\fP manual pages.
159Among those, the most basic
160routines are \fBmove\fP and \fBaddch\fP.
161More general versions of
162these routines are included with names beginning with \fBw\fP,
163allowing the user to specify a window.
164The routines not beginning
165with \fBw\fP affect \fBstdscr\fP.
166.PP
167After using routines to manipulate a window, \fBrefresh\fP(3) is called,
168telling \fBcurses\fP to make the user's CRT screen look like
169\fBstdscr\fP.
170The characters in a window are actually of type
171\fBchtype\fP, (character and attribute data) so that other information
172about the character may also be stored with each character.
173.PP
174Special windows called \fIpads\fP may also be manipulated.
175These are windows
176which are not constrained to the size of the screen and whose contents need not
177be completely displayed.
178See \fBcurs_pad\fP(3) for more information.
179.PP
180In addition to drawing characters on the screen, video attributes and colors
181may be supported, causing the characters to show up in such modes as
182underlined, in reverse video, or in color on terminals that support such
183display enhancements.
184Line drawing characters may be specified to be output.
185On input, \fBcurses\fP is also able to translate arrow and function keys that
186transmit escape sequences into single values.
187The video attributes, line
188drawing characters, and input values use names, defined in \fB<curses.h>\fP,
189such as \fBA_REVERSE\fP, \fBACS_HLINE\fP, and \fBKEY_LEFT\fP.
190.SS Environment variables
191If the environment variables \fBLINES\fP and \fBCOLUMNS\fP are set, or if the
192program is executing in a window environment, line and column information in
193the environment will override information read by \fIterminfo\fP.
194This would affect a program running in an AT&T 630 layer,
195for example, where the size of a
196screen is changeable (see \fBENVIRONMENT\fP).
197.PP
198If the environment variable \fBTERMINFO\fP is defined, any program using
199\fBcurses\fP checks for a local terminal definition before checking in the
200standard place.
201For example, if \fBTERM\fP is set to \fBatt4424\fP, then the
202compiled terminal definition is found in
203.NS
204\fB\*d/a/att4424\fP.
205.NE
206.PP
207(The \fBa\fP is copied from the first letter of \fBatt4424\fP to avoid
208creation of huge directories.) However, if \fBTERMINFO\fP is set to
209\fB$HOME/myterms\fP, \fBcurses\fP first checks
210.NS
211\fB$HOME/myterms/a/att4424\fP,
212.NE
213.PP
214and if that fails, it then checks
215.NS
216\fB\*d/a/att4424\fP.
217.NE
218.PP
219This is useful for developing experimental definitions or when write
220permission in \fB\*d\fP is not available.
221.PP
222The integer variables \fBLINES\fP and \fBCOLS\fP are defined in
223\fB<curses.h>\fP and will be filled in by \fBinitscr\fP with the size of the
224screen.
225The constants \fBTRUE\fP and \fBFALSE\fP have the values \fB1\fP and
226\fB0\fP, respectively.
227.PP
228The \fBcurses\fP routines also define the \fBWINDOW *\fP variable \fBcurscr\fP
229which is used for certain low-level operations like clearing and redrawing a
230screen containing garbage.
231The \fBcurscr\fP can be used in only a few routines.
232.\"
233.SS Routine and Argument Names
234Many \fBcurses\fP routines have two or more versions.
235The routines prefixed with \fIw\fP require a window argument.
236The routines prefixed with \fIp\fP require a pad argument.
237Those without a prefix generally use \fBstdscr\fP.
238.PP
239The routines prefixed with \fBmv\fP require a \fIy\fP and \fIx\fP
240coordinate to move to before performing the appropriate action.
241The \fBmv\fP routines imply a call to \fBmove\fP before the call to the
242other routine.
243The coordinate \fIy\fP always refers to the row (of
244the window), and \fIx\fP always refers to the column.
245The upper left-hand corner is always (0,0), not (1,1).
246.PP
247The routines prefixed with \fBmvw\fP take both a window argument and
248\fIx\fP and \fIy\fP coordinates.
249The window argument is always specified before the coordinates.
250.PP
251In each case, \fIwin\fP is the window affected, and \fIpad\fP is the
252pad affected; \fIwin\fP and \fIpad\fP are always pointers to type
253\fBWINDOW\fP.
254.PP
255Option setting routines require a Boolean flag \fIbf\fP with the value
256\fBTRUE\fP or \fBFALSE\fP; \fIbf\fP is always of type \fBbool\fP.
257Most of the data types used in the library routines,
258such as \fBWINDOW\fP, \fBSCREEN\fP, \fBbool\fP, and \fBchtype\fP
259are defined in \fB<curses.h>\fP.
260Types used for the terminfo routines such as
261\fBTERMINAL\fP are defined in \fB<term.h>\fP.
262.PP
263This manual page describes functions which may appear in any configuration
264of the library.
265There are two common configurations of the library:
266.RS 3
267.TP 5
268.I ncurses
269the \*(``normal\*('' library, which handles 8-bit characters.
270The normal (8-bit) library stores characters combined with attributes
271in \fBchtype\fP data.
272.IP
273Attributes alone (no corresponding character) may be stored in \fBchtype\fP
274or the equivalent \fBattr_t\fP data.
275In either case, the data is stored in something like an integer.
276.IP
277Each cell (row and column) in a \fBWINDOW\fP is stored as a \fBchtype\fP.
278.TP 5
279.I ncursesw
280the so-called \*(``wide\*('' library, which handles multibyte characters
281(see the section on \fBALTERNATE CONFIGURATIONS\fP).
282The \*(``wide\*('' library includes all of the calls
283from the \*(``normal\*('' library.
284It adds about one third more calls using data types which store
285multibyte characters:
286.RS 5
287.TP 5
288.B cchar_t
289corresponds to \fBchtype\fP.
290However it is a structure, because more data is stored than can fit into
291an integer.
292The characters are large enough to require a full integer value \- and there
293may be more than one character per cell.
294The video attributes and color are stored in separate fields of the structure.
295.IP
296Each cell (row and column) in a \fBWINDOW\fP is stored as a \fBcchar_t\fP.
297.IP
298The \fBsetcchar\fP(3) and \fBgetcchar\fP(3)
299functions store and retrieve the data from
300a \fBcchar_t\fP structure.
301.TP 5
302.B wchar_t
303stores a \*(``wide\*('' character.
304Like \fBchtype\fP, this may be an integer.
305.TP 5
306.B wint_t
307stores a \fBwchar_t\fP or \fBWEOF\fP \- not the same, though both may have
308the same size.
309.RE
310.IP
311The \*(``wide\*('' library provides new functions which are analogous to
312functions in the \*(``normal\*('' library.
313There is a naming convention which relates many of the normal/wide variants:
314a \*(``_w\*('' is inserted into the name.
315For example, \fBwaddch\fP becomes \fBwadd_wch\fP.
316.RE
317.\"
318.SS Routine Name Index
319The following table lists the \fBcurses\fP routines provided in
320the \*(``normal\*('' and \*(``wide\*('' libraries and the names of
321the manual pages on which they are described.
322Routines flagged with \*(``*\*(''
323are ncurses-specific, not described by XPG4 or present in SVr4.
324.PP
325.TS
326center tab(/);
327l l
328l l .
329\fBcurses\fP Routine Name/Manual Page Name
330=
331COLOR_PAIR/\fBcurs_color\fP(3)
332PAIR_NUMBER/\fBcurs_attr\fP(3)
333add_wch/\fBcurs_add_wch\fP(3)
334add_wchnstr/\fBcurs_add_wchstr\fP(3)
335add_wchstr/\fBcurs_add_wchstr\fP(3)
336addch/\fBcurs_addch\fP(3)
337addchnstr/\fBcurs_addchstr\fP(3)
338addchstr/\fBcurs_addchstr\fP(3)
339addnstr/\fBcurs_addstr\fP(3)
340addnwstr/\fBcurs_addwstr\fP(3)
341addstr/\fBcurs_addstr\fP(3)
342addwstr/\fBcurs_addwstr\fP(3)
343alloc_pair/\fBnew_pair\fP(3)*
344assume_default_colors/\fBdefault_colors\fP(3)*
345attr_get/\fBcurs_attr\fP(3)
346attr_off/\fBcurs_attr\fP(3)
347attr_on/\fBcurs_attr\fP(3)
348attr_set/\fBcurs_attr\fP(3)
349attroff/\fBcurs_attr\fP(3)
350attron/\fBcurs_attr\fP(3)
351attrset/\fBcurs_attr\fP(3)
352baudrate/\fBcurs_termattrs\fP(3)
353beep/\fBcurs_beep\fP(3)
354bkgd/\fBcurs_bkgd\fP(3)
355bkgdset/\fBcurs_bkgd\fP(3)
356bkgrnd/\fBcurs_bkgrnd\fP(3)
357bkgrndset/\fBcurs_bkgrnd\fP(3)
358border/\fBcurs_border\fP(3)
359border_set/\fBcurs_border_set\fP(3)
360box/\fBcurs_border\fP(3)
361box_set/\fBcurs_border_set\fP(3)
362can_change_color/\fBcurs_color\fP(3)
363cbreak/\fBcurs_inopts\fP(3)
364chgat/\fBcurs_attr\fP(3)
365clear/\fBcurs_clear\fP(3)
366clearok/\fBcurs_outopts\fP(3)
367clrtobot/\fBcurs_clear\fP(3)
368clrtoeol/\fBcurs_clear\fP(3)
369color_content/\fBcurs_color\fP(3)
370color_set/\fBcurs_attr\fP(3)
371copywin/\fBcurs_overlay\fP(3)
372curs_set/\fBcurs_kernel\fP(3)
373curses_trace/\fBcurs_trace\fP(3)*
374curses_version/\fBcurs_extend\fP(3)*
375def_prog_mode/\fBcurs_kernel\fP(3)
376def_shell_mode/\fBcurs_kernel\fP(3)
377define_key/\fBdefine_key\fP(3)*
378del_curterm/\fBterminfo\fP(3)
379delay_output/\fBcurs_util\fP(3)
380delch/\fBcurs_delch\fP(3)
381deleteln/\fBcurs_deleteln\fP(3)
382delscreen/\fBcurs_initscr\fP(3)
383delwin/\fBcurs_window\fP(3)
384derwin/\fBcurs_window\fP(3)
385doupdate/\fBcurs_refresh\fP(3)
386dupwin/\fBcurs_window\fP(3)
387echo/\fBcurs_inopts\fP(3)
388echo_wchar/\fBcurs_add_wch\fP(3)
389echochar/\fBcurs_addch\fP(3)
390endwin/\fBcurs_initscr\fP(3)
391erase/\fBcurs_clear\fP(3)
392erasechar/\fBcurs_termattrs\fP(3)
393erasewchar/\fBcurs_termattrs\fP(3)
394exit_curses/\fBcurs_memleaks\fP(3)*
395exit_terminfo/\fBcurs_memleaks\fP(3)*
396extended_color_content/\fBcurs_color\fP(3)*
397extended_pair_content/\fBcurs_color\fP(3)*
398extended_slk_color/\fBcurs_slk\fP(3)*
399filter/\fBcurs_util\fP(3)
400find_pair/\fBnew_pair\fP(3)*
401flash/\fBcurs_beep\fP(3)
402flushinp/\fBcurs_util\fP(3)
403free_pair/\fBnew_pair\fP(3)*
404get_wch/\fBcurs_get_wch\fP(3)
405get_wstr/\fBcurs_get_wstr\fP(3)
406getattrs/\fBcurs_attr\fP(3)
407getbegx/\fBcurs_legacy\fP(3)*
408getbegy/\fBcurs_legacy\fP(3)*
409getbegyx/\fBcurs_getyx\fP(3)
410getbkgd/\fBcurs_bkgd\fP(3)
411getbkgrnd/\fBcurs_bkgrnd\fP(3)
412getcchar/\fBcurs_getcchar\fP(3)
413getch/\fBcurs_getch\fP(3)
414getcurx/\fBcurs_legacy\fP(3)*
415getcury/\fBcurs_legacy\fP(3)*
416getmaxx/\fBcurs_legacy\fP(3)*
417getmaxy/\fBcurs_legacy\fP(3)*
418getmaxyx/\fBcurs_getyx\fP(3)
419getmouse/\fBcurs_mouse\fP(3)*
420getn_wstr/\fBcurs_get_wstr\fP(3)
421getnstr/\fBcurs_getstr\fP(3)
422getparx/\fBcurs_legacy\fP(3)*
423getpary/\fBcurs_legacy\fP(3)*
424getparyx/\fBcurs_getyx\fP(3)
425getstr/\fBcurs_getstr\fP(3)
426getsyx/\fBcurs_kernel\fP(3)
427getwin/\fBcurs_util\fP(3)
428getyx/\fBcurs_getyx\fP(3)
429halfdelay/\fBcurs_inopts\fP(3)
430has_colors/\fBcurs_color\fP(3)
431has_ic/\fBcurs_termattrs\fP(3)
432has_il/\fBcurs_termattrs\fP(3)
433has_key/\fBcurs_getch\fP(3)*
434has_mouse/\fBcurs_mouse\fP(3)*
435hline/\fBcurs_border\fP(3)
436hline_set/\fBcurs_border_set\fP(3)
437idcok/\fBcurs_outopts\fP(3)
438idlok/\fBcurs_outopts\fP(3)
439immedok/\fBcurs_outopts\fP(3)
440in_wch/\fBcurs_in_wch\fP(3)
441in_wchnstr/\fBcurs_in_wchstr\fP(3)
442in_wchstr/\fBcurs_in_wchstr\fP(3)
443inch/\fBcurs_inch\fP(3)
444inchnstr/\fBcurs_inchstr\fP(3)
445inchstr/\fBcurs_inchstr\fP(3)
446init_color/\fBcurs_color\fP(3)
447init_extended_color/\fBcurs_color\fP(3)*
448init_extended_pair/\fBcurs_color\fP(3)*
449init_pair/\fBcurs_color\fP(3)
450initscr/\fBcurs_initscr\fP(3)
451innstr/\fBcurs_instr\fP(3)
452innwstr/\fBcurs_inwstr\fP(3)
453ins_nwstr/\fBcurs_ins_wstr\fP(3)
454ins_wch/\fBcurs_ins_wch\fP(3)
455ins_wstr/\fBcurs_ins_wstr\fP(3)
456insch/\fBcurs_insch\fP(3)
457insdelln/\fBcurs_deleteln\fP(3)
458insertln/\fBcurs_deleteln\fP(3)
459insnstr/\fBcurs_insstr\fP(3)
460insstr/\fBcurs_insstr\fP(3)
461instr/\fBcurs_instr\fP(3)
462intrflush/\fBcurs_inopts\fP(3)
463inwstr/\fBcurs_inwstr\fP(3)
464is_cbreak/\fBcurs_inopts\fP(3)*
465is_cleared/\fBcurs_opaque\fP(3)*
466is_echo/\fBcurs_inopts\fP(3)*
467is_idcok/\fBcurs_opaque\fP(3)*
468is_idlok/\fBcurs_opaque\fP(3)*
469is_immedok/\fBcurs_opaque\fP(3)*
470is_keypad/\fBcurs_opaque\fP(3)*
471is_leaveok/\fBcurs_opaque\fP(3)*
472is_linetouched/\fBcurs_touch\fP(3)
473is_nl/\fBcurs_inopts\fP(3)*
474is_nodelay/\fBcurs_opaque\fP(3)*
475is_notimeout/\fBcurs_opaque\fP(3)*
476is_pad/\fBcurs_opaque\fP(3)*
477is_raw/\fBcurs_inopts\fP(3)*
478is_scrollok/\fBcurs_opaque\fP(3)*
479is_subwin/\fBcurs_opaque\fP(3)*
480is_syncok/\fBcurs_opaque\fP(3)*
481is_term_resized/\fBresizeterm\fP(3)*
482is_wintouched/\fBcurs_touch\fP(3)
483isendwin/\fBcurs_initscr\fP(3)
484key_defined/\fBkey_defined\fP(3)*
485key_name/\fBcurs_util\fP(3)
486keybound/\fBkeybound\fP(3)*
487keyname/\fBcurs_util\fP(3)
488keyok/\fBkeyok\fP(3)*
489keypad/\fBcurs_inopts\fP(3)
490killchar/\fBcurs_termattrs\fP(3)
491killwchar/\fBcurs_termattrs\fP(3)
492leaveok/\fBcurs_outopts\fP(3)
493longname/\fBcurs_termattrs\fP(3)
494mcprint/\fBcurs_print\fP(3)*
495meta/\fBcurs_inopts\fP(3)
496mouse_trafo/\fBcurs_mouse\fP(3)*
497mouseinterval/\fBcurs_mouse\fP(3)*
498mousemask/\fBcurs_mouse\fP(3)*
499move/\fBcurs_move\fP(3)
500mvadd_wch/\fBcurs_add_wch\fP(3)
501mvadd_wchnstr/\fBcurs_add_wchstr\fP(3)
502mvadd_wchstr/\fBcurs_add_wchstr\fP(3)
503mvaddch/\fBcurs_addch\fP(3)
504mvaddchnstr/\fBcurs_addchstr\fP(3)
505mvaddchstr/\fBcurs_addchstr\fP(3)
506mvaddnstr/\fBcurs_addstr\fP(3)
507mvaddnwstr/\fBcurs_addwstr\fP(3)
508mvaddstr/\fBcurs_addstr\fP(3)
509mvaddwstr/\fBcurs_addwstr\fP(3)
510mvchgat/\fBcurs_attr\fP(3)
511mvcur/\fBterminfo\fP(3)
512mvdelch/\fBcurs_delch\fP(3)
513mvderwin/\fBcurs_window\fP(3)
514mvget_wch/\fBcurs_get_wch\fP(3)
515mvget_wstr/\fBcurs_get_wstr\fP(3)
516mvgetch/\fBcurs_getch\fP(3)
517mvgetn_wstr/\fBcurs_get_wstr\fP(3)
518mvgetnstr/\fBcurs_getstr\fP(3)
519mvgetstr/\fBcurs_getstr\fP(3)
520mvhline/\fBcurs_border\fP(3)
521mvhline_set/\fBcurs_border_set\fP(3)
522mvin_wch/\fBcurs_in_wch\fP(3)
523mvin_wchnstr/\fBcurs_in_wchstr\fP(3)
524mvin_wchstr/\fBcurs_in_wchstr\fP(3)
525mvinch/\fBcurs_inch\fP(3)
526mvinchnstr/\fBcurs_inchstr\fP(3)
527mvinchstr/\fBcurs_inchstr\fP(3)
528mvinnstr/\fBcurs_instr\fP(3)
529mvinnwstr/\fBcurs_inwstr\fP(3)
530mvins_nwstr/\fBcurs_ins_wstr\fP(3)
531mvins_wch/\fBcurs_ins_wch\fP(3)
532mvins_wstr/\fBcurs_ins_wstr\fP(3)
533mvinsch/\fBcurs_insch\fP(3)
534mvinsnstr/\fBcurs_insstr\fP(3)
535mvinsstr/\fBcurs_insstr\fP(3)
536mvinstr/\fBcurs_instr\fP(3)
537mvinwstr/\fBcurs_inwstr\fP(3)
538mvprintw/\fBcurs_printw\fP(3)
539mvscanw/\fBcurs_scanw\fP(3)
540mvvline/\fBcurs_border\fP(3)
541mvvline_set/\fBcurs_border_set\fP(3)
542mvwadd_wch/\fBcurs_add_wch\fP(3)
543mvwadd_wchnstr/\fBcurs_add_wchstr\fP(3)
544mvwadd_wchstr/\fBcurs_add_wchstr\fP(3)
545mvwaddch/\fBcurs_addch\fP(3)
546mvwaddchnstr/\fBcurs_addchstr\fP(3)
547mvwaddchstr/\fBcurs_addchstr\fP(3)
548mvwaddnstr/\fBcurs_addstr\fP(3)
549mvwaddnwstr/\fBcurs_addwstr\fP(3)
550mvwaddstr/\fBcurs_addstr\fP(3)
551mvwaddwstr/\fBcurs_addwstr\fP(3)
552mvwchgat/\fBcurs_attr\fP(3)
553mvwdelch/\fBcurs_delch\fP(3)
554mvwget_wch/\fBcurs_get_wch\fP(3)
555mvwget_wstr/\fBcurs_get_wstr\fP(3)
556mvwgetch/\fBcurs_getch\fP(3)
557mvwgetn_wstr/\fBcurs_get_wstr\fP(3)
558mvwgetnstr/\fBcurs_getstr\fP(3)
559mvwgetstr/\fBcurs_getstr\fP(3)
560mvwhline/\fBcurs_border\fP(3)
561mvwhline_set/\fBcurs_border_set\fP(3)
562mvwin/\fBcurs_window\fP(3)
563mvwin_wch/\fBcurs_in_wch\fP(3)
564mvwin_wchnstr/\fBcurs_in_wchstr\fP(3)
565mvwin_wchstr/\fBcurs_in_wchstr\fP(3)
566mvwinch/\fBcurs_inch\fP(3)
567mvwinchnstr/\fBcurs_inchstr\fP(3)
568mvwinchstr/\fBcurs_inchstr\fP(3)
569mvwinnstr/\fBcurs_instr\fP(3)
570mvwinnwstr/\fBcurs_inwstr\fP(3)
571mvwins_nwstr/\fBcurs_ins_wstr\fP(3)
572mvwins_wch/\fBcurs_ins_wch\fP(3)
573mvwins_wstr/\fBcurs_ins_wstr\fP(3)
574mvwinsch/\fBcurs_insch\fP(3)
575mvwinsnstr/\fBcurs_insstr\fP(3)
576mvwinsstr/\fBcurs_insstr\fP(3)
577mvwinstr/\fBcurs_instr\fP(3)
578mvwinwstr/\fBcurs_inwstr\fP(3)
579mvwprintw/\fBcurs_printw\fP(3)
580mvwscanw/\fBcurs_scanw\fP(3)
581mvwvline/\fBcurs_border\fP(3)
582mvwvline_set/\fBcurs_border_set\fP(3)
583napms/\fBcurs_kernel\fP(3)
584newpad/\fBcurs_pad\fP(3)
585newterm/\fBcurs_initscr\fP(3)
586newwin/\fBcurs_window\fP(3)
587nl/\fBcurs_inopts\fP(3)
588nocbreak/\fBcurs_inopts\fP(3)
589nodelay/\fBcurs_inopts\fP(3)
590noecho/\fBcurs_inopts\fP(3)
591nofilter/\fBcurs_util\fP(3)*
592nonl/\fBcurs_inopts\fP(3)
593noqiflush/\fBcurs_inopts\fP(3)
594noraw/\fBcurs_inopts\fP(3)
595notimeout/\fBcurs_inopts\fP(3)
596overlay/\fBcurs_overlay\fP(3)
597overwrite/\fBcurs_overlay\fP(3)
598pair_content/\fBcurs_color\fP(3)
599pecho_wchar/\fBcurs_pad\fP(3)*
600pechochar/\fBcurs_pad\fP(3)
601pnoutrefresh/\fBcurs_pad\fP(3)
602prefresh/\fBcurs_pad\fP(3)
603printw/\fBcurs_printw\fP(3)
604putp/\fBterminfo\fP(3)
605putwin/\fBcurs_util\fP(3)
606qiflush/\fBcurs_inopts\fP(3)
607raw/\fBcurs_inopts\fP(3)
608redrawwin/\fBcurs_refresh\fP(3)
609refresh/\fBcurs_refresh\fP(3)
610reset_color_pairs/\fBcurs_color\fP(3)*
611reset_prog_mode/\fBcurs_kernel\fP(3)
612reset_shell_mode/\fBcurs_kernel\fP(3)
613resetty/\fBcurs_kernel\fP(3)
614resize_term/\fBresizeterm\fP(3)*
615resizeterm/\fBresizeterm\fP(3)*
616restartterm/\fBterminfo\fP(3)
617ripoffline/\fBcurs_kernel\fP(3)
618savetty/\fBcurs_kernel\fP(3)
619scanw/\fBcurs_scanw\fP(3)
620scr_dump/\fBcurs_scr_dump\fP(3)
621scr_init/\fBcurs_scr_dump\fP(3)
622scr_restore/\fBcurs_scr_dump\fP(3)
623scr_set/\fBcurs_scr_dump\fP(3)
624scrl/\fBcurs_scroll\fP(3)
625scroll/\fBcurs_scroll\fP(3)
626scrollok/\fBcurs_outopts\fP(3)
627set_curterm/\fBterminfo\fP(3)
628set_term/\fBcurs_initscr\fP(3)
629setcchar/\fBcurs_getcchar\fP(3)
630setscrreg/\fBcurs_outopts\fP(3)
631setsyx/\fBcurs_kernel\fP(3)
632setupterm/\fBterminfo\fP(3)
633slk_attr/\fBcurs_slk\fP(3)*
634slk_attr_off/\fBcurs_slk\fP(3)
635slk_attr_on/\fBcurs_slk\fP(3)
636slk_attr_set/\fBcurs_slk\fP(3)
637slk_attroff/\fBcurs_slk\fP(3)
638slk_attron/\fBcurs_slk\fP(3)
639slk_attrset/\fBcurs_slk\fP(3)
640slk_clear/\fBcurs_slk\fP(3)
641slk_color/\fBcurs_slk\fP(3)
642slk_init/\fBcurs_slk\fP(3)
643slk_label/\fBcurs_slk\fP(3)
644slk_noutrefresh/\fBcurs_slk\fP(3)
645slk_refresh/\fBcurs_slk\fP(3)
646slk_restore/\fBcurs_slk\fP(3)
647slk_set/\fBcurs_slk\fP(3)
648slk_touch/\fBcurs_slk\fP(3)
649slk_wset/\fBcurs_slk\fP(3)*
650standend/\fBcurs_attr\fP(3)
651standout/\fBcurs_attr\fP(3)
652start_color/\fBcurs_color\fP(3)
653subpad/\fBcurs_pad\fP(3)
654subwin/\fBcurs_window\fP(3)
655syncok/\fBcurs_window\fP(3)
656term_attrs/\fBcurs_termattrs\fP(3)
657termattrs/\fBcurs_termattrs\fP(3)
658termname/\fBcurs_termattrs\fP(3)
659tgetent/\fBtermcap\fP(3)
660tgetflag/\fBtermcap\fP(3)
661tgetnum/\fBtermcap\fP(3)
662tgetstr/\fBtermcap\fP(3)
663tgoto/\fBtermcap\fP(3)
664tigetflag/\fBterminfo\fP(3)
665tigetnum/\fBterminfo\fP(3)
666tigetstr/\fBterminfo\fP(3)
667timeout/\fBcurs_inopts\fP(3)
668tiparm/\fBterminfo\fP(3)*
669tiparm_s/\fBterminfo\fP(3)*
670tiscan_s/\fBterminfo\fP(3)*
671touchline/\fBcurs_touch\fP(3)
672touchwin/\fBcurs_touch\fP(3)
673tparm/\fBterminfo\fP(3)
674tputs/\fBtermcap\fP(3)
675tputs/\fBterminfo\fP(3)
676trace/\fBcurs_trace\fP(3)*
677typeahead/\fBcurs_inopts\fP(3)
678unctrl/\fBcurs_util\fP(3)
679unget_wch/\fBcurs_get_wch\fP(3)
680ungetch/\fBcurs_getch\fP(3)
681ungetmouse/\fBcurs_mouse\fP(3)*
682untouchwin/\fBcurs_touch\fP(3)
683use_default_colors/\fBdefault_colors\fP(3)*
684use_env/\fBcurs_util\fP(3)
685use_extended_names/\fBcurs_extend\fP(3)*
686use_legacy_coding/\fBlegacy_coding\fP(3)*
687use_tioctl/\fBcurs_util\fP(3)*
688vid_attr/\fBterminfo\fP(3)
689vid_puts/\fBterminfo\fP(3)
690vidattr/\fBterminfo\fP(3)
691vidputs/\fBterminfo\fP(3)
692vline/\fBcurs_border\fP(3)
693vline_set/\fBcurs_border_set\fP(3)
694vw_printw/\fBcurs_printw\fP(3)
695vw_scanw/\fBcurs_scanw\fP(3)
696vwprintw/\fBcurs_printw\fP(3)
697vwscanw/\fBcurs_scanw\fP(3)
698wadd_wch/\fBcurs_add_wch\fP(3)
699wadd_wchnstr/\fBcurs_add_wchstr\fP(3)
700wadd_wchstr/\fBcurs_add_wchstr\fP(3)
701waddch/\fBcurs_addch\fP(3)
702waddchnstr/\fBcurs_addchstr\fP(3)
703waddchstr/\fBcurs_addchstr\fP(3)
704waddnstr/\fBcurs_addstr\fP(3)
705waddnwstr/\fBcurs_addwstr\fP(3)
706waddstr/\fBcurs_addstr\fP(3)
707waddwstr/\fBcurs_addwstr\fP(3)
708wattr_get/\fBcurs_attr\fP(3)
709wattr_off/\fBcurs_attr\fP(3)
710wattr_on/\fBcurs_attr\fP(3)
711wattr_set/\fBcurs_attr\fP(3)
712wattroff/\fBcurs_attr\fP(3)
713wattron/\fBcurs_attr\fP(3)
714wattrset/\fBcurs_attr\fP(3)
715wbkgd/\fBcurs_bkgd\fP(3)
716wbkgdset/\fBcurs_bkgd\fP(3)
717wbkgrnd/\fBcurs_bkgrnd\fP(3)
718wbkgrndset/\fBcurs_bkgrnd\fP(3)
719wborder/\fBcurs_border\fP(3)
720wborder_set/\fBcurs_border_set\fP(3)
721wchgat/\fBcurs_attr\fP(3)
722wclear/\fBcurs_clear\fP(3)
723wclrtobot/\fBcurs_clear\fP(3)
724wclrtoeol/\fBcurs_clear\fP(3)
725wcolor_set/\fBcurs_attr\fP(3)
726wcursyncup/\fBcurs_window\fP(3)
727wdelch/\fBcurs_delch\fP(3)
728wdeleteln/\fBcurs_deleteln\fP(3)
729wecho_wchar/\fBcurs_add_wch\fP(3)
730wechochar/\fBcurs_addch\fP(3)
731wenclose/\fBcurs_mouse\fP(3)*
732werase/\fBcurs_clear\fP(3)
733wget_wch/\fBcurs_get_wch\fP(3)
734wget_wstr/\fBcurs_get_wstr\fP(3)
735wgetbkgrnd/\fBcurs_bkgrnd\fP(3)
736wgetch/\fBcurs_getch\fP(3)
737wgetdelay/\fBcurs_opaque\fP(3)*
738wgetn_wstr/\fBcurs_get_wstr\fP(3)
739wgetnstr/\fBcurs_getstr\fP(3)
740wgetparent/\fBcurs_opaque\fP(3)*
741wgetscrreg/\fBcurs_opaque\fP(3)*
742wgetstr/\fBcurs_getstr\fP(3)
743whline/\fBcurs_border\fP(3)
744whline_set/\fBcurs_border_set\fP(3)
745win_wch/\fBcurs_in_wch\fP(3)
746win_wchnstr/\fBcurs_in_wchstr\fP(3)
747win_wchstr/\fBcurs_in_wchstr\fP(3)
748winch/\fBcurs_inch\fP(3)
749winchnstr/\fBcurs_inchstr\fP(3)
750winchstr/\fBcurs_inchstr\fP(3)
751winnstr/\fBcurs_instr\fP(3)
752winnwstr/\fBcurs_inwstr\fP(3)
753wins_nwstr/\fBcurs_ins_wstr\fP(3)
754wins_wch/\fBcurs_ins_wch\fP(3)
755wins_wstr/\fBcurs_ins_wstr\fP(3)
756winsch/\fBcurs_insch\fP(3)
757winsdelln/\fBcurs_deleteln\fP(3)
758winsertln/\fBcurs_deleteln\fP(3)
759winsnstr/\fBcurs_insstr\fP(3)
760winsstr/\fBcurs_insstr\fP(3)
761winstr/\fBcurs_instr\fP(3)
762winwstr/\fBcurs_inwstr\fP(3)
763wmouse_trafo/\fBcurs_mouse\fP(3)*
764wmove/\fBcurs_move\fP(3)
765wnoutrefresh/\fBcurs_refresh\fP(3)
766wprintw/\fBcurs_printw\fP(3)
767wredrawln/\fBcurs_refresh\fP(3)
768wrefresh/\fBcurs_refresh\fP(3)
769wresize/\fBwresize\fP(3)*
770wscanw/\fBcurs_scanw\fP(3)
771wscrl/\fBcurs_scroll\fP(3)
772wsetscrreg/\fBcurs_outopts\fP(3)
773wstandend/\fBcurs_attr\fP(3)
774wstandout/\fBcurs_attr\fP(3)
775wsyncdown/\fBcurs_window\fP(3)
776wsyncup/\fBcurs_window\fP(3)
777wtimeout/\fBcurs_inopts\fP(3)
778wtouchln/\fBcurs_touch\fP(3)
779wunctrl/\fBcurs_util\fP(3)
780wvline/\fBcurs_border\fP(3)
781wvline_set/\fBcurs_border_set\fP(3)
782.TE
783.PP
784Depending on the configuration,
785additional sets of functions may be available:
786.RS 3
787.TP 5
788\fBcurs_memleaks\fP(3) - curses memory-leak checking
789.TP 5
790\fBcurs_sp_funcs\fP(3) - curses screen-pointer extension
791.TP 5
792\fBcurs_threads\fP(3) - curses thread support
793.TP 5
794\fBcurs_trace\fP(3) - curses debugging routines
795.RE
796.SH RETURN VALUE
797Routines that return an integer return \fBERR\fP upon failure and an
798integer value other than \fBERR\fP upon successful completion, unless
799otherwise noted in the routine descriptions.
800.PP
801As a general rule, routines check for null pointers passed as parameters,
802and handle this as an error.
803.PP
804All macros return the value of the \fBw\fP version, except \fBsetscrreg\fP,
805\fBwsetscrreg\fP, \fBgetyx\fP, \fBgetbegyx\fP, and \fBgetmaxyx\fP.
806The return values of
807\fBsetscrreg\fP,
808\fBwsetscrreg\fP,
809\fBgetyx\fP,
810\fBgetbegyx\fP, and
811\fBgetmaxyx\fP are undefined (i.e., these should not be used as the
812right-hand side of assignment statements).
813.PP
814Functions with a \*(``mv\*('' prefix first perform a cursor movement using
815\fBwmove\fP, and return an error if the position is outside the window,
816or if the window pointer is null.
817Most \*(``mv\*(''-prefixed functions
818(except variadic functions such as \fBmvprintw\fP)
819are provided both as macros and functions.
820.PP
821Routines that return pointers return \fBNULL\fP on error.
822.SH ENVIRONMENT
823The following environment symbols are useful for customizing the
824runtime behavior of the \fBncurses\fP library.
825The most important ones have been already discussed in detail.
826.SS CC command-character
827When set, change occurrences of the command_character
828(i.e., the \fBcmdch\fP capability)
829of the loaded terminfo entries to the value of this variable.
830Very few terminfo entries provide this feature.
831.PP
832Because this name is also used in development environments to represent
833the C compiler's name, \fBncurses\fP ignores it if it does not happen to
834be a single character.
835.SS BAUDRATE
836The debugging library checks this environment variable when the application
837has redirected output to a file.
838The variable's numeric value is used for the baudrate.
839If no value is found, \fBncurses\fP uses 9600.
840This allows testers to construct repeatable test-cases
841that take into account costs that depend on baudrate.
842.SS COLUMNS
843Specify the width of the screen in characters.
844Applications running in a windowing environment usually are able to
845obtain the width of the window in which they are executing.
846If neither the \fBCOLUMNS\fP value nor the terminal's screen size is available,
847\fBncurses\fP uses the size which may be specified in the terminfo database
848(i.e., the \fBcols\fP capability).
849.PP
850It is important that your application use a correct size for the screen.
851This is not always possible because your application may be
852running on a host which does not honor NAWS (Negotiations About Window
853Size), or because you are temporarily running as another user.
854However, setting \fBCOLUMNS\fP and/or \fBLINES\fP overrides the library's
855use of the screen size obtained from the operating system.
856.PP
857Either \fBCOLUMNS\fP or \fBLINES\fP symbols may be specified independently.
858This is mainly useful to circumvent legacy misfeatures of terminal descriptions,
859e.g., xterm which commonly specifies a 65 line screen.
860For best results, \fBlines\fP and \fBcols\fP should not be specified in
861a terminal description for terminals which are run as emulations.
862.PP
863Use the \fBuse_env\fP function to disable all use of external environment
864(but not including system calls) to determine the screen size.
865Use the \fBuse_tioctl\fP function to update \fBCOLUMNS\fP or \fBLINES\fP
866to match the screen size obtained from system calls or the terminal database.
867.SS ESCDELAY
868Specifies the total time, in milliseconds, for which ncurses will
869await a character sequence, e.g., a function key.
870The default value, 1000 milliseconds, is enough for most uses.
871However, it is made a variable to accommodate unusual applications.
872.PP
873The most common instance where you may wish to change this value
874is to work with slow hosts, e.g., running on a network.
875If the host cannot read characters rapidly enough, it will have the same
876effect as if the terminal did not send characters rapidly enough.
877The library will still see a timeout.
878.PP
879Note that xterm mouse events are built up from character sequences
880received from the xterm.
881If your application makes heavy use of multiple-clicking, you may
882wish to lengthen this default value because the timeout applies
883to the composed multi-click event as well as the individual clicks.
884.PP
885In addition to the environment variable,
886this implementation provides a global variable with the same name.
887Portable applications should not rely upon the presence of ESCDELAY
888in either form,
889but setting the environment variable rather than the global variable
890does not create problems when compiling an application.
891.SS HOME
892Tells \fBncurses\fP where your home directory is.
893That is where it may read and write auxiliary terminal descriptions:
894.NS
895$HOME/.termcap
896$HOME/.terminfo
897.NE
898.SS LINES
899Like COLUMNS, specify the height of the screen in characters.
900See COLUMNS for a detailed description.
901.SS MOUSE_BUTTONS_123
902This applies only to the OS/2 EMX port.
903It specifies the order of buttons on the mouse.
904OS/2 numbers a 3-button mouse inconsistently from other
905platforms:
906.NS
9071 = left
908.br
9092 = right
910.br
9113 = middle.
912.NE
913.PP
914This variable lets you customize the mouse.
915The variable must be three numeric digits 1\-3 in any order, e.g., 123 or 321.
916If it is not specified, \fBncurses\fP uses 132.
917.SS NCURSES_ASSUMED_COLORS
918Override the compiled-in assumption that the
919terminal's default colors are white-on-black
920(see \fBdefault_colors\fP(3)).
921You may set the foreground and background color values with this environment
922variable by proving a 2-element list: foreground,background.
923For example, to tell ncurses to not assume anything
924about the colors, set this to "\-1,\-1".
925To make it green-on-black, set it to "2,0".
926Any positive value from zero to the terminfo \fBmax_colors\fP value is allowed.
927.SS NCURSES_CONSOLE2
928This applies only to the MinGW port of ncurses.
929.PP
930The \fBConsole2\fP program's handling of the Microsoft Console API call
931\fBCreateConsoleScreenBuffer\fP is defective.
932Applications which use this will hang.
933However, it is possible to simulate the action of this call by
934mapping coordinates,
935explicitly saving and restoring the original screen contents.
936Setting the environment variable \fBNCGDB\fP has the same effect.
937.SS NCURSES_GPM_TERMS
938This applies only to ncurses configured to use the GPM interface.
939.PP
940If present,
941the environment variable is a list of one or more terminal names
942against which the \fBTERM\fP environment variable is matched.
943Setting it to an empty value disables the GPM interface;
944using the built-in support for xterm, etc.
945.PP
946If the environment variable is absent,
947ncurses will attempt to open GPM if \fBTERM\fP contains \*(``linux\*(''.
948.SS NCURSES_NO_HARD_TABS
949\fBNcurses\fP may use tabs as part of the cursor movement optimization.
950In some cases,
951your terminal driver may not handle these properly.
952Set this environment variable to disable the feature.
953You can also adjust your \fBstty\fP(1) settings to avoid the problem.
954.SS NCURSES_NO_MAGIC_COOKIE
955Some terminals use a magic-cookie feature which requires special handling
956to make highlighting and other video attributes display properly.
957You can suppress the highlighting entirely for these terminals by
958setting this environment variable.
959.SS NCURSES_NO_PADDING
960Most of the terminal descriptions in the terminfo database are written
961for real \*(``hardware\*('' terminals.
962Many people use terminal emulators
963which run in a windowing environment and use curses-based applications.
964Terminal emulators can duplicate
965all of the important aspects of a hardware terminal, but they do not
966have the same limitations.
967The chief limitation of a hardware terminal from the standpoint
968of your application is the management of dataflow, i.e., timing.
969Unless a hardware terminal is interfaced into a terminal concentrator
970(which does flow control),
971it (or your application) must manage dataflow, preventing overruns.
972The cheapest solution (no hardware cost)
973is for your program to do this by pausing after
974operations that the terminal does slowly, such as clearing the display.
975.PP
976As a result, many terminal descriptions (including the vt100)
977have delay times embedded.
978You may wish to use these descriptions,
979but not want to pay the performance penalty.
980.PP
981Set the NCURSES_NO_PADDING environment variable to disable all but mandatory
982padding.
983Mandatory padding is used as a part of special control
984sequences such as \fBflash\fP.
985.SS NCURSES_NO_SETBUF
986This setting is obsolete.
987Before changes
988.RS 3
989.bP
990started with 5.9 patch 20120825
991and
992.bP
993continued
994though 5.9 patch 20130126
995.RE
996.PP
997\fBncurses\fP enabled buffered output during terminal initialization.
998This was done (as in SVr4 curses) for performance reasons.
999For testing purposes, both of \fBncurses\fP and certain applications,
1000this feature was made optional.
1001Setting the NCURSES_NO_SETBUF variable
1002disabled output buffering, leaving the output in the original (usually
1003line buffered) mode.
1004.PP
1005In the current implementation,
1006ncurses performs its own buffering and does not require this workaround.
1007It does not modify the buffering of the standard output.
1008.PP
1009The reason for the change was to make the behavior for interrupts and
1010other signals more robust.
1011One drawback is that certain nonconventional programs would mix
1012ordinary stdio calls with ncurses calls and (usually) work.
1013This is no longer possible since ncurses is not using
1014the buffered standard output but its own output (to the same file descriptor).
1015As a special case, the low-level calls such as \fBputp\fP still use the
1016standard output.
1017But high-level curses calls do not.
1018.SS NCURSES_NO_UTF8_ACS
1019During initialization, the \fBncurses\fP library
1020checks for special cases where VT100 line-drawing (and the corresponding
1021alternate character set capabilities) described in the terminfo are known
1022to be missing.
1023Specifically, when running in a UTF\-8 locale,
1024the Linux console emulator and the GNU screen program ignore these.
1025Ncurses checks the \fBTERM\fP environment variable for these.
1026For other special cases, you should set this environment variable.
1027Doing this tells ncurses to use Unicode values which correspond to
1028the VT100 line-drawing glyphs.
1029That works for the special cases cited,
1030and is likely to work for terminal emulators.
1031.PP
1032When setting this variable, you should set it to a nonzero value.
1033Setting it to zero (or to a nonnumber)
1034disables the special check for \*(``linux\*('' and \*(``screen\*(''.
1035.PP
1036As an alternative to the environment variable,
1037ncurses checks for an extended terminfo capability \fBU8\fP.
1038This is a numeric capability which can be compiled using \fBtic\ \-x\fP.
1039For example
1040.RS 3
1041.ft CW
1042.sp
1043.nf
1044# linux console, if patched to provide working
1045# VT100 shift-in/shift-out, with corresponding font.
1046linux-vt100|linux console with VT100 line-graphics,
1047 U8#0, use=linux,
1048.sp
1049# uxterm with vt100Graphics resource set to false
1050xterm-utf8|xterm relying on UTF-8 line-graphics,
1051 U8#1, use=xterm,
1052.fi
1053.ft
1054.RE
1055.PP
1056The name \*(``U8\*('' is chosen to be two characters,
1057to permit it to be used by applications that use ncurses'
1058termcap interface.
1059.SS NCURSES_TRACE
1060During initialization, the \fBncurses\fP debugging library
1061checks the NCURSES_TRACE environment variable.
1062If it is defined, to a numeric value, \fBncurses\fP calls the \fBtrace\fP
1063function, using that value as the argument.
1064.PP
1065The argument values, which are defined in \fBcurses.h\fP, provide several
1066types of information.
1067When running with traces enabled, your application will write the
1068file \fBtrace\fP to the current directory.
1069.PP
1070See \fBcurs_trace\fP(3) for more information.
1071.SS TERM
1072Denotes your terminal type.
1073Each terminal type is distinct, though many are similar.
1074.PP
1075\fBTERM\fP is commonly set by terminal emulators to help
1076applications find a workable terminal description.
1077Some of those choose a popular approximation, e.g.,
1078\*(``ansi\*('', \*(``vt100\*('', \*(``xterm\*('' rather than an exact fit.
1079Not infrequently, your application will have problems with that approach,
1080e.g., incorrect function-key definitions.
1081.PP
1082If you set \fBTERM\fP in your environment,
1083it has no effect on the operation of the terminal emulator.
1084It only affects the way applications work within the terminal.
1085Likewise, as a general rule (\fBxterm\fP(1) being a rare exception),
1086terminal emulators which allow you to
1087specify \fBTERM\fP as a parameter or configuration value do
1088not change their behavior to match that setting.
1089.SS TERMCAP
1090If the \fBncurses\fP library has been configured with \fItermcap\fP
1091support, \fBncurses\fP will check for a terminal's description in
1092termcap form if it is not available in the terminfo database.
1093.PP
1094The \fBTERMCAP\fP environment variable contains
1095either a terminal description (with newlines stripped out),
1096or a file name telling where the information denoted by
1097the \fBTERM\fP environment variable exists.
1098In either case, setting it directs \fBncurses\fP to ignore
1099the usual place for this information, e.g., /etc/termcap.
1100.SS TERMINFO
1101\fBncurses\fP can be configured to read from multiple terminal databases.
1102The \fBTERMINFO\fP variable overrides the location for
1103the default terminal database.
1104Terminal descriptions (in terminal format) are stored in terminal databases:
1105.bP
1106Normally these are stored in a directory tree,
1107using subdirectories named by the first letter of the terminal names therein.
1108.IP
1109This is the scheme used in System V, which legacy Unix systems use,
1110and the \fBTERMINFO\fP variable is used by \fIcurses\fP applications on those
1111systems to override the default location of the terminal database.
1112.bP
1113If \fBncurses\fP is built to use hashed databases,
1114then each entry in this list may be the path of a hashed database file, e.g.,
1115.NS
1116/usr/share/terminfo.db
1117.NE
1118.IP
1119rather than
1120.NS
1121/usr/share/terminfo/
1122.NE
1123.IP
1124The hashed database uses less disk-space and is a little faster than the
1125directory tree.
1126However,
1127some applications assume the existence of the directory tree,
1128reading it directly
1129rather than using the terminfo library calls.
1130.bP
1131If \fBncurses\fP is built with a support for reading termcap files
1132directly, then an entry in this list may be the path of a termcap file.
1133.bP
1134If the \fBTERMINFO\fP variable begins with
1135\*(``hex:\*('' or \*(``b64:\*('',
1136\fBncurses\fP uses the remainder of that variable as a compiled terminal
1137description.
1138You might produce the base64 format using \fBinfocmp\fP(1):
1139.NS
1140TERMINFO="$(infocmp -0 -Q2 -q)"
1141export TERMINFO
1142.NE
1143.IP
1144The compiled description is used if it corresponds to the terminal identified
1145by the \fBTERM\fP variable.
1146.PP
1147Setting \fBTERMINFO\fP is the simplest,
1148but not the only way to set location of the default terminal database.
1149The complete list of database locations in order follows:
1150.RS 3
1151.bP
1152the last terminal database to which \fBncurses\fP wrote,
1153if any, is searched first
1154.bP
1155the location specified by the TERMINFO environment variable
1156.bP
1157$HOME/.terminfo
1158.bP
1159locations listed in the TERMINFO_DIRS environment variable
1160.bP
1161one or more locations whose names are configured and compiled into the
1162ncurses library, i.e.,
1163.RS 3
1164.bP
1165? (corresponding to the TERMINFO_DIRS variable)
1166.bP
1167/usr/share/terminfo (corresponding to the TERMINFO variable)
1168.RE
1169.RE
1170.SS TERMINFO_DIRS
1171Specifies a list of locations to search for terminal descriptions.
1172Each location in the list is a terminal database as described in
1173the section on the \fBTERMINFO\fP variable.
1174The list is separated by colons (i.e., ":") on Unix, semicolons on OS/2 EMX.
1175.PP
1176There is no corresponding feature in System V terminfo;
1177it is an extension developed for \fBncurses\fP.
1178.SS TERMPATH
1179If \fBTERMCAP\fP does not hold a file name then \fBncurses\fP checks
1180the \fBTERMPATH\fP environment variable.
1181This is a list of filenames separated by spaces or colons (i.e., ":") on Unix,
1182semicolons on OS/2 EMX.
1183.PP
1184If the \fBTERMPATH\fP environment variable is not set,
1185\fBncurses\fP looks in the files
1186.NS
1187/etc/termcap, /usr/share/misc/termcap and $HOME/.termcap,
1188.NE
1189.PP
1190in that order.
1191.PP
1192The library may be configured to disregard the following variables when the
1193current user is the superuser (root), or if the application uses setuid or
1194setgid permissions:
1195.NS
1196$TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
1197.NE
1198.SH ALTERNATE CONFIGURATIONS
1199Several different configurations are possible,
1200depending on the configure script options used when building \fBncurses\fP.
1201There are a few main options whose effects are visible to the applications
1202developer using \fBncurses\fP:
1203.TP 5
1204\-\-disable\-overwrite
1205The standard include for \fBncurses\fP is as noted in \fBSYNOPSIS\fP:
1206.NS
1207\fB#include <curses.h>\fP
1208.NE
1209.IP
1210This option is used to avoid filename conflicts when \fBncurses\fP
1211is not the main implementation of curses of the computer.
1212If \fBncurses\fP is installed disabling overwrite, it puts its headers in
1213a subdirectory, e.g.,
1214.NS
1215\fB#include <ncurses/curses.h>\fP
1216.NE
1217.IP
1218It also omits a symbolic link which would allow you to use \fB\-lcurses\fP
1219to build executables.
1220.TP 5
1221\-\-enable\-widec
1222The configure script renames the library and
1223(if the \fB\-\-disable\-overwrite\fP option is used)
1224puts the header files in a different subdirectory.
1225All of the library names have a \*(``w\*('' appended to them,
1226i.e., instead of
1227.NS
1228\fB\-lncurses\fP
1229.NE
1230.IP
1231you link with
1232.NS
1233\fB\-lncursesw\fP
1234.NE
1235.IP
1236You must also enable the wide-character features in the header file
1237when compiling for the wide-character library
1238to use the extended (wide-character) functions.
1239The symbol which enables these features has changed since XSI Curses, Issue 4:
1240.RS
1241.bP
1242Originally, the wide-character feature required the symbol
1243\fB_XOPEN_SOURCE_EXTENDED\fP
1244but that was only valid for XPG4 (1996).
1245.bP
1246Later, that was deemed conflicting with \fB_XOPEN_SOURCE\fP defined to 500.
1247.bP
1248As of mid-2018,
1249none of the features in this implementation require a \fB_XOPEN_SOURCE\fP
1250feature greater than 600.
1251However, X/Open Curses, Issue 7 (2009) recommends defining it to 700.
1252.bP
1253Alternatively, you can enable the feature by defining \fBNCURSES_WIDECHAR\fP
1254with the caveat that some other header file than \fBcurses.h\fP
1255may require a specific value for \fB_XOPEN_SOURCE\fP
1256(or a system-specific symbol).
1257.RE
1258.IP
1259The \fBcurses.h\fP file which is installed for the wide-character
1260library is designed to be compatible with the normal library's header.
1261Only the size of the \fBWINDOW\fP structure differs, and very few
1262applications require more than a pointer to \fBWINDOW\fPs.
1263.IP
1264If the headers are installed allowing overwrite,
1265the wide-character library's headers should be installed last,
1266to allow applications to be built using either library
1267from the same set of headers.
1268.TP 5
1269\-\-with\-pthread
1270The configure script renames the library.
1271All of the library names have a \*(``t\*('' appended to them
1272(before any \*(``w\*('' added by \fB\-\-enable\-widec\fP).
1273.IP
1274The global variables such as \fBLINES\fP are replaced by macros to
1275allow read-only access.
1276At the same time, setter-functions are provided to set these values.
1277Some applications (very few) may require changes to work with this convention.
1278.TP 5
1279\-\-with\-shared
1280.TP
1281\-\-with\-normal
1282.TP
1283\-\-with\-debug
1284.TP
1285\-\-with\-profile
1286The shared and normal (static) library names differ by their suffixes,
1287e.g., \fBlibncurses.so\fP and \fBlibncurses.a\fP.
1288The debug and profiling libraries add a \*(``_g\*(''
1289and a \*(``_p\*('' to the root names respectively,
1290e.g., \fBlibncurses_g.a\fP and \fBlibncurses_p.a\fP.
1291.TP 5
1292\-\-with\-termlib
1293Low-level functions which do not depend upon whether the library
1294supports wide-characters, are provided in the tinfo library.
1295.IP
1296By doing this, it is possible to share the tinfo library between
1297wide/normal configurations as well as reduce the size of the library
1298when only low-level functions are needed.
1299.IP
1300Those functions are described in these pages:
1301.RS
1302.bP
1303\fBcurs_extend\fP(3) \- miscellaneous curses extensions
1304.bP
1305\fBcurs_inopts\fP(3) \- \fBcurses\fP input options
1306.bP
1307\fBcurs_kernel\fP(3) \- low-level \fBcurses\fP routines
1308.bP
1309\fBcurs_termattrs\fP(3) \- \fBcurses\fP environment query routines
1310.bP
1311\fBtermcap\fP(3) \- \fBcurses\fP emulation of termcap
1312.bP
1313\fBterminfo\fP(3) \- \fBcurses\fP interfaces to terminfo database
1314.bP
1315\fBcurs_util\fP(3) \- miscellaneous \fBcurses\fP utility routines
1316.RE
1317.TP 5
1318\-\-with\-trace
1319The \fBtrace\fP function normally resides in the debug library,
1320but it is sometimes useful to configure this in the shared library.
1321Configure scripts should check for the function's existence rather
1322than assuming it is always in the debug library.
1323.SH FILES
1324.TP 5
1325/usr/share/tabset
1326directory containing initialization files for the terminal capability database
1327/usr/share/terminfo
1328terminal capability database
1329.SH SEE ALSO
1330\fBterminfo\fP(\*n) and related pages whose names begin
1331\*(``curs_\*('' for detailed routine descriptions.
1332.br
1333\fBcurs_variables\fP(3)
1334.br
1335\fBuser_caps\fP(5) for user-defined capabilities
1336.SH EXTENSIONS
1337The \fBncurses\fP library can be compiled with an option (\fB\-DUSE_GETCAP\fP)
1338that falls back to the old-style /etc/termcap file if the terminal setup code
1339cannot find a terminfo entry corresponding to \fBTERM\fP.
1340Use of this feature
1341is not recommended, as it essentially includes an entire termcap compiler in
1342the \fBncurses\fP startup code, at significant cost in core and startup cycles.
1343.PP
1344The \fBncurses\fP library includes facilities for capturing mouse events on
1345certain terminals (including xterm).
1346See the \fBcurs_mouse\fP(3)
1347manual page for details.
1348.PP
1349The \fBncurses\fP library includes facilities for responding to window
1350resizing events, e.g., when running in an xterm.
1351See the \fBresizeterm\fP(3)
1352and \fBwresize\fP(3) manual pages for details.
1353In addition, the library may be configured with a \fBSIGWINCH\fP handler.
1354.PP
1355The \fBncurses\fP library extends the fixed set of function key capabilities
1356of terminals by allowing the application designer to define additional
1357key sequences at runtime.
1358See the \fBdefine_key\fP(3)
1359\fBkey_defined\fP(3),
1360and \fBkeyok\fP(3) manual pages for details.
1361.PP
1362The \fBncurses\fP library can exploit the capabilities of terminals which
1363implement the ISO\-6429 SGR 39 and SGR 49 controls, which allow an application
1364to reset the terminal to its original foreground and background colors.
1365From the users' perspective, the application is able to draw colored
1366text on a background whose color is set independently, providing better
1367control over color contrasts.
1368See the \fBdefault_colors\fP(3) manual page for details.
1369.PP
1370The \fBncurses\fP library includes a function for directing application output
1371to a printer attached to the terminal device.
1372See the \fBcurs_print\fP(3) manual page for details.
1373.SH PORTABILITY
1374The \fBncurses\fP library is intended to be BASE-level conformant with XSI
1375Curses.
1376The EXTENDED XSI Curses functionality
1377(including color support) is supported.
1378.PP
1379A small number of local differences (that is, individual differences between
1380the XSI Curses and \fBncurses\fP calls) are described in \fBPORTABILITY\fP
1381sections of the library man pages.
1382.SS Error checking
1383In many cases, X/Open Curses is vague about error conditions,
1384omitting some of the SVr4 documentation.
1385.PP
1386Unlike other implementations, this one checks parameters such as pointers
1387to WINDOW structures to ensure they are not null.
1388The main reason for providing this behavior is to guard against programmer
1389error.
1390The standard interface does not provide a way for the library
1391to tell an application which of several possible errors were detected.
1392Relying on this (or some other) extension will adversely affect the
1393portability of curses applications.
1394.SS Extensions versus portability
1395Most of the extensions provided by ncurses have not been standardized.
1396Some have been incorporated into other implementations, such as
1397PDCurses or NetBSD curses.
1398Here are a few to consider:
1399.bP
1400The routine \fBhas_key\fP is not part of XPG4, nor is it present in SVr4.
1401See the \fBcurs_getch\fP(3) manual page for details.
1402.bP
1403The routine \fBslk_attr\fP is not part of XPG4, nor is it present in SVr4.
1404See the \fBcurs_slk\fP(3) manual page for details.
1405.bP
1406The routines \fBgetmouse\fP, \fBmousemask\fP, \fBungetmouse\fP,
1407\fBmouseinterval\fP, and \fBwenclose\fP relating to mouse interfacing are not
1408part of XPG4, nor are they present in SVr4.
1409See the \fBcurs_mouse\fP(3) manual page for details.
1410.bP
1411The routine \fBmcprint\fP was not present in any previous curses implementation.
1412See the \fBcurs_print\fP(3) manual page for details.
1413.bP
1414The routine \fBwresize\fP is not part of XPG4, nor is it present in SVr4.
1415See the \fBwresize\fP(3) manual page for details.
1416.bP
1417The WINDOW structure's internal details can be hidden from application
1418programs.
1419See \fBcurs_opaque\fP(3) for the discussion of \fBis_scrollok\fP, etc.
1420.bP
1421This implementation can be configured to provide rudimentary support
1422for multi-threaded applications.
1423See \fBcurs_threads\fP(3) for details.
1424.bP
1425This implementation can also be configured to provide a set of functions which
1426improve the ability to manage multiple screens.
1427See \fBcurs_sp_funcs\fP(3) for details.
1428.SS Padding differences
1429In historic curses versions, delays embedded in the capabilities \fBcr\fP,
1430\fBind\fP, \fBcub1\fP, \fBff\fP and \fBtab\fP activated corresponding delay
1431bits in the UNIX tty driver.
1432In this implementation, all padding is done by sending NUL bytes.
1433This method is slightly more expensive, but narrows the interface
1434to the UNIX kernel significantly and increases the package's portability
1435correspondingly.
1436.SS Header files
1437The header file \fB<curses.h>\fP automatically includes the header files
1438\fB<stdio.h>\fP and \fB<unctrl.h>\fP.
1439.PP
1440X/Open Curses has more to say,
1441but does not finish the story:
1442.RS 4
1443.PP
1444The inclusion of <curses.h> may make visible all symbols
1445from the headers <stdio.h>, <term.h>, <termios.h>, and <wchar.h>.
1446.RE
1447.PP
1448Here is a more complete story:
1449.bP
1450Starting with BSD curses, all implementations have included <stdio.h>.
1451.IP
1452BSD curses included <curses.h> and <unctrl.h> from an internal header
1453"curses.ext" ("ext" was a short name for \fIexterns\fP).
1454.IP
1455BSD curses used <stdio.h> internally (for \fBprintw\fP and \fBscanw\fP),
1456but nothing in <curses.h> itself relied upon <stdio.h>.
1457.bP
1458SVr2 curses added \fBnewterm\fP(3), which relies upon <stdio.h>.
1459That is, the function prototype uses \fBFILE\fP.
1460.IP
1461SVr4 curses added \fBputwin\fP and \fBgetwin\fP, which also use <stdio.h>.
1462.IP
1463X/Open Curses documents all three of these functions.
1464.IP
1465SVr4 curses and X/Open Curses do not require the developer to
1466include <stdio.h> before including <curses.h>.
1467Both document curses showing <curses.h> as the only required header.
1468.IP
1469As a result, standard <curses.h> will always include <stdio.h>.
1470.bP
1471X/Open Curses is inconsistent with respect to SVr4 regarding <unctrl.h>.
1472.IP
1473As noted in \fBcurs_util\fP(3), ncurses includes <unctrl.h> from
1474<curses.h> (like SVr4).
1475.bP
1476X/Open's comments about <term.h> and <termios.h> may refer to HP-UX and AIX:
1477.IP
1478HP-UX curses includes <term.h> from <curses.h>
1479to declare \fBsetupterm\fP in curses.h,
1480but ncurses (and Solaris curses) do not.
1481.IP
1482AIX curses includes <term.h> and <termios.h>.
1483Again, ncurses (and Solaris curses) do not.
1484.bP
1485X/Open says that <curses.h> \fImay\fP include <term.h>,
1486but there is no requirement that it do that.
1487.IP
1488Some programs use functions declared in both <curses.h> and <term.h>,
1489and must include both headers in the same module.
1490Very old versions of AIX curses required including <curses.h>
1491before including <term.h>.
1492.IP
1493Because ncurses header files include the headers needed to
1494define datatypes used in the headers,
1495ncurses header files can be included in any order.
1496But for portability, you should include <curses.h> before <term.h>.
1497.bP
1498X/Open Curses says \fI"may make visible"\fP
1499because including a header file does not necessarily make all symbols
1500in it visible (there are ifdef's to consider).
1501.IP
1502For instance, in ncurses <wchar.h> \fImay\fP be included if
1503the proper symbol is defined, and if ncurses is configured for
1504wide-character support.
1505If the header is included, its symbols may be made visible.
1506That depends on the value used for \fB_XOPEN_SOURCE\fP
1507feature test macro.
1508.bP
1509X/Open Curses documents one required header,
1510in a special case: <stdarg.h> before <curses.h> to prototype
1511the \fBvw_printw\fP and \fBvw_scanw\fP functions
1512(as well as the obsolete
1513the \fBvwprintw\fP and \fBvwscanw\fP functions).
1514Each of those uses a \fBva_list\fP parameter.
1515.IP
1516The two obsolete functions were introduced in SVr3.
1517The other functions were introduced in X/Open Curses.
1518In between, SVr4 curses provided for the possibility that
1519an application might include either <varargs.h> or <stdarg.h>.
1520Initially, that was done by using \fBvoid*\fP for the \fBva_list\fP
1521parameter.
1522Later, a special type (defined in <stdio.h>) was introduced,
1523to allow for compiler type-checking.
1524That special type is always available,
1525because <stdio.h> is always included by <curses.h>.
1526.IP
1527None of the X/Open Curses implementations require an application
1528to include <stdarg.h> before <curses.h> because they either
1529have allowed for a special type, or (like ncurses) include <stdarg.h>
1530directly to provide a portable interface.
1531.SH NOTES
1532If standard output from a \fBncurses\fP program is re-directed to something
1533which is not a tty, screen updates will be directed to standard error.
1534This was an undocumented feature of AT&T System V Release 3 curses.
1535.SH AUTHORS
1536Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
1537Based on \fIpcurses\fP by Pavel Curtis.