.\" authorization. *
.\"***************************************************************************
.\"
-.\" $Id: ncurses.3x,v 1.159 2023/06/17 17:50:37 tom Exp $
-.hy 0
-.TH ncurses 3X 2023-06-17 "ncurses 6.4" "Library calls"
-.ie \n(.g .ds `` \(lq
-.el .ds `` ``
-.ie \n(.g .ds '' \(rq
-.el .ds '' ''
+.\" $Id: ncurses.3x,v 1.181 2023/11/25 14:32:36 tom Exp $
+.TH ncurses 3X 2023-11-25 "ncurses 6.4" "Library calls"
+.ie \n(.g \{\
+.ds `` \(lq
+.ds '' \(rq
+.\}
+.el \{\
+.ie t .ds `` ``
+.el .ds `` ""
+.ie t .ds '' ''
+.el .ds '' ""
+.\}
.de bP
.ie n .IP \(bu 4
.el .IP \(bu 2
..
-.de NS
-.ie n .sp
-.el .sp .5
-.ie n .in +4
-.el .in +2
-.nf
-.ft CR \" Courier
-..
-.de NE
-.fi
-.ft R
-.ie n .in -4
-.el .in -2
-..
-.ds n 5
+.
.ds d @TERMINFO@
.SH NAME
-\fBncurses\fP \- CRT screen handling and optimization package
+\fB\%ncurses\fP \-
+character-cell terminal interface with optimized output
.SH SYNOPSIS
-\fB#include <curses.h>\fP
-.br
+.nf
+\fB#include <curses.h>
+.fi
.SH DESCRIPTION
The \fBncurses\fP library routines give the user a terminal-independent method
of updating character screens with reasonable optimization.
version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).
.PP
The \fBncurses\fP library emulates the curses library of
-System V Release 4 UNIX,
+System V Release 4 Unix (\*(``SVr4\*(''),
and XPG4 (X/Open Portability Guide) curses (also known as XSI curses).
XSI stands for X/Open System Interfaces Extension.
The \fBncurses\fP library is freely redistributable in source form.
-Differences from the SVr4
-curses are summarized under the
-\fIEXTENSIONS\fP and \fIPORTABILITY\fP sections below and
-described in detail in the respective
-\fIEXTENSIONS\fP, \fIPORTABILITY\fP and \fIBUGS\fP sections
-of individual man pages.
.PP
-The \fBncurses\fP library also provides many useful extensions,
-i.e., features which cannot be implemented by a simple add-on library
-but which require access to the internals of the library.
+\fI\%ncurses\fP man pages employ several sections to clarify matters of
+usage and interoperability with other \fIcurses\fP implementations.
+.bP
+\*(``NOTES\*('' describes matters and caveats of which any user of the
+\fI\%ncurses\fP API should be aware,
+such as limitations on the size of an underlying integral type or the
+availability of a preprocessor macro for a function
+(which prevents its address from being taken).
+This section also describes implementation details that will be
+significant to the programmer but which are not standardized.
+.bP
+\*(``EXTENSIONS\*('' presents \fI\%ncurses\fP innovations beyond the
+X/Open Curses standard and/or the SVr4 \fIcurses\fP implementation.
+They are termed \fIextensions\fP to indicate that they cannot be
+implemented solely by using the library API, but require access to the
+library's internal state.
+.bP
+\*(``PORTABILITY\*('' discusses matters
+(beyond the exercise of extensions)
+that should be considered when writing to a \fIcurses\fP standard,
+or to multiple implementations.
+.bP
+\*(``HISTORY\*('' examines points of detail in \fI\%ncurses\fP and other
+\fIcurses\fP implementations over the decades of their development,
+particularly where precedent or inertia have frustrated better design
+(and,
+in a few cases,
+where such inertia has been overcome).
.PP
A program using these routines must be linked with the \fB\-lncurses\fP option,
or (if it has been generated) with the debugging library \fB\-lncurses_g\fP.
(Your system integrator may also have installed these libraries under
the names \fB\-lcurses\fP and \fB\-lcurses_g\fP.)
-The ncurses_g library generates trace logs (in a file called \*(``trace\*('' in the
-current directory) that describe curses actions.
+The ncurses_g library generates trace logs
+(in a file called \*(``trace\*('' in the current directory)
+that describe curses actions.
See also the section on \fBALTERNATE CONFIGURATIONS\fP.
.PP
The \fBncurses\fP package supports: overall screen, window and pad
routines; color manipulation; use of soft label keys; terminfo capabilities;
and access to low-level terminal-manipulation routines.
.SS Initialization
-.PP
The library uses the locale which the calling program has initialized.
That is normally done with \fBsetlocale\fP(3):
-.NS
+.PP
+.RS 4
+.EX
\fBsetlocale(LC_ALL, "");\fP
-.NE
+.EE
+.RE
.PP
If the locale is not initialized,
the library assumes that characters are printable as in ISO\-8859\-1,
To get character-at-a-time input without echoing (most
interactive, screen oriented programs want this), the following
sequence should be used:
-.NS
+.PP
+.RS 4
+.EX
\fBinitscr(); cbreak(); noecho();\fP
-.NE
+.EE
+.RE
.PP
Most programs would additionally use the sequence:
-.NS
+.PP
+.RS 4
+.EX
\fBintrflush(stdscr, FALSE);\fP
\fBkeypad(stdscr, TRUE);\fP
-.NE
+.EE
+.RE
.PP
Before a \fBcurses\fP program is run, the tab stops of the terminal
should be set and its initialization strings, if defined, must be output.
This can be done by executing the \fB@TPUT@ init\fP command
after the shell environment variable \fBTERM\fP has been exported.
-\fB@TSET@(1)\fP is usually responsible for doing this.
-[See \fBterminfo\fP(\*n) for further details.]
+(The BSD-style \fB\%@TSET@\fP(1) utility also performs this function.)
+See subsection \*(``Tabs and Initialization\*('' of \fBterminfo\fP(5).
.SS Datatypes
-.PP
The \fBncurses\fP library permits manipulation of data structures,
called \fIwindows\fP, which can be thought of as two-dimensional
arrays of characters representing all or part of a CRT screen.
drawing characters, and input values use names, defined in \fB<curses.h>\fP,
such as \fBA_REVERSE\fP, \fBACS_HLINE\fP, and \fBKEY_LEFT\fP.
.SS Environment variables
-.PP
If the environment variables \fBLINES\fP and \fBCOLUMNS\fP are set, or if the
program is executing in a window environment, line and column information in
the environment will override information read by \fIterminfo\fP.
standard place.
For example, if \fBTERM\fP is set to \fBatt4424\fP, then the
compiled terminal definition is found in
-.NS
+.PP
+.RS 4
+.EX
\fB\*d/a/att4424\fP.
-.NE
+.EE
+.RE
.PP
(The \fBa\fP is copied from the first letter of \fBatt4424\fP to avoid
creation of huge directories.) However, if \fBTERMINFO\fP is set to
\fB$HOME/myterms\fP, \fBcurses\fP first checks
-.NS
+.PP
+.RS 4
+.EX
\fB$HOME/myterms/a/att4424\fP,
-.NE
+.EE
+.RE
.PP
and if that fails, it then checks
-.NS
+.PP
+.RS 4
+.EX
\fB\*d/a/att4424\fP.
-.NE
+.EE
+.RE
.PP
This is useful for developing experimental definitions or when write
permission in \fB\*d\fP is not available.
a \*(``_w\*('' is inserted into the name.
For example, \fBwaddch\fP becomes \fBwadd_wch\fP.
.RE
-.PP
.\"
.SS Routine Name Index
The following table lists the \fBcurses\fP routines provided in
instr/\fBcurs_instr\fP(3X)
intrflush/\fBcurs_inopts\fP(3X)
inwstr/\fBcurs_inwstr\fP(3X)
+is_cbreak/\fBcurs_inopts\fP(3X)*
is_cleared/\fBcurs_opaque\fP(3X)*
+is_echo/\fBcurs_inopts\fP(3X)*
is_idcok/\fBcurs_opaque\fP(3X)*
is_idlok/\fBcurs_opaque\fP(3X)*
is_immedok/\fBcurs_opaque\fP(3X)*
is_keypad/\fBcurs_opaque\fP(3X)*
is_leaveok/\fBcurs_opaque\fP(3X)*
is_linetouched/\fBcurs_touch\fP(3X)
+is_nl/\fBcurs_inopts\fP(3X)*
is_nodelay/\fBcurs_opaque\fP(3X)*
is_notimeout/\fBcurs_opaque\fP(3X)*
is_pad/\fBcurs_opaque\fP(3X)*
+is_raw/\fBcurs_inopts\fP(3X)*
is_scrollok/\fBcurs_opaque\fP(3X)*
is_subwin/\fBcurs_opaque\fP(3X)*
is_syncok/\fBcurs_opaque\fP(3X)*
overlay/\fBcurs_overlay\fP(3X)
overwrite/\fBcurs_overlay\fP(3X)
pair_content/\fBcurs_color\fP(3X)
-pecho_wchar/\fBcurs_pad\fP(3X)*
+pecho_wchar/\fBcurs_pad\fP(3X)
pechochar/\fBcurs_pad\fP(3X)
pnoutrefresh/\fBcurs_pad\fP(3X)
prefresh/\fBcurs_pad\fP(3X)
slk_restore/\fBcurs_slk\fP(3X)
slk_set/\fBcurs_slk\fP(3X)
slk_touch/\fBcurs_slk\fP(3X)
-slk_wset/\fBcurs_slk\fP(3X)*
+slk_wset/\fBcurs_slk\fP(3X)
standend/\fBcurs_attr\fP(3X)
standout/\fBcurs_attr\fP(3X)
start_color/\fBcurs_color\fP(3X)
tigetnum/\fBcurs_terminfo\fP(3X)
tigetstr/\fBcurs_terminfo\fP(3X)
timeout/\fBcurs_inopts\fP(3X)
-tiparm/\fBcurs_terminfo\fP(3X)*
+tiparm/\fBcurs_terminfo\fP(3X)
tiparm_s/\fBcurs_terminfo\fP(3X)*
tiscan_s/\fBcurs_terminfo\fP(3X)*
touchline/\fBcurs_touch\fP(3X)
.PP
Routines that return pointers return \fBNULL\fP on error.
.SH ENVIRONMENT
-.PP
The following environment symbols are useful for customizing the
runtime behavior of the \fBncurses\fP library.
The most important ones have been already discussed in detail.
.SS CC command-character
-.PP
When set, change occurrences of the command_character
(i.e., the \fBcmdch\fP capability)
of the loaded terminfo entries to the value of this variable.
the C compiler's name, \fBncurses\fP ignores it if it does not happen to
be a single character.
.SS BAUDRATE
-.PP
The debugging library checks this environment variable when the application
has redirected output to a file.
The variable's numeric value is used for the baudrate.
This allows testers to construct repeatable test-cases
that take into account costs that depend on baudrate.
.SS COLUMNS
-.PP
Specify the width of the screen in characters.
Applications running in a windowing environment usually are able to
obtain the width of the window in which they are executing.
Use the \fBuse_tioctl\fP function to update \fBCOLUMNS\fP or \fBLINES\fP
to match the screen size obtained from system calls or the terminal database.
.SS ESCDELAY
-.PP
Specifies the total time, in milliseconds, for which ncurses will
await a character sequence, e.g., a function key.
The default value, 1000 milliseconds, is enough for most uses.
.SS HOME
Tells \fBncurses\fP where your home directory is.
That is where it may read and write auxiliary terminal descriptions:
-.NS
+.PP
+.RS 4
+.EX
$HOME/.termcap
$HOME/.terminfo
-.NE
+.EE
+.RE
.SS LINES
-.PP
Like COLUMNS, specify the height of the screen in characters.
See COLUMNS for a detailed description.
.SS MOUSE_BUTTONS_123
-.PP
This applies only to the OS/2 EMX port.
It specifies the order of buttons on the mouse.
OS/2 numbers a 3-button mouse inconsistently from other
platforms:
-.NS
+.PP
+.RS 4
+.EX
1 = left
-.br
2 = right
-.br
3 = middle.
-.NE
+.EE
+.RE
.PP
This variable lets you customize the mouse.
The variable must be three numeric digits 1\-3 in any order, e.g., 123 or 321.
If it is not specified, \fBncurses\fP uses 132.
.SS NCURSES_ASSUMED_COLORS
-.PP
Override the compiled-in assumption that the
terminal's default colors are white-on-black
(see \fBdefault_colors\fP(3X)).
explicitly saving and restoring the original screen contents.
Setting the environment variable \fBNCGDB\fP has the same effect.
.SS NCURSES_GPM_TERMS
-.PP
This applies only to ncurses configured to use the GPM interface.
.PP
If present,
If the environment variable is absent,
ncurses will attempt to open GPM if \fBTERM\fP contains \*(``linux\*(''.
.SS NCURSES_NO_HARD_TABS
-.PP
\fBNcurses\fP may use tabs as part of the cursor movement optimization.
In some cases,
your terminal driver may not handle these properly.
Set this environment variable to disable the feature.
You can also adjust your \fBstty\fP(1) settings to avoid the problem.
.SS NCURSES_NO_MAGIC_COOKIE
-.PP
Some terminals use a magic-cookie feature which requires special handling
to make highlighting and other video attributes display properly.
You can suppress the highlighting entirely for these terminals by
setting this environment variable.
.SS NCURSES_NO_PADDING
-.PP
Most of the terminal descriptions in the terminfo database are written
for real \*(``hardware\*('' terminals.
Many people use terminal emulators
standard output.
But high-level curses calls do not.
.SS NCURSES_NO_UTF8_ACS
-.PP
During initialization, the \fBncurses\fP library
checks for special cases where VT100 line-drawing (and the corresponding
alternate character set capabilities) described in the terminfo are known
ncurses checks for an extended terminfo capability \fBU8\fP.
This is a numeric capability which can be compiled using \fB@TIC@\ \-x\fP.
For example
+.PP
.RS 3
-.ft CW
-.sp
-.nf
+.EX
# linux console, if patched to provide working
-# VT100 shift-in/shift-out, with corresponding font.
-linux-vt100|linux console with VT100 line-graphics,
+# VT100 shift\-in/shift\-out, with corresponding font.
+linux\-vt100|linux console with VT100 line\-graphics,
U8#0, use=linux,
-.sp
+
# uxterm with vt100Graphics resource set to false
-xterm-utf8|xterm relying on UTF-8 line-graphics,
+xterm\-utf8|xterm relying on UTF\-8 line\-graphics,
U8#1, use=xterm,
-.fi
-.ft
+.EE
.RE
.PP
The name \*(``U8\*('' is chosen to be two characters,
to permit it to be used by applications that use ncurses'
termcap interface.
.SS NCURSES_TRACE
-.PP
During initialization, the \fBncurses\fP debugging library
checks the NCURSES_TRACE environment variable.
If it is defined, to a numeric value, \fBncurses\fP calls the \fBtrace\fP
.PP
See \fBcurs_trace\fP(3X) for more information.
.SS TERM
-.PP
Denotes your terminal type.
Each terminal type is distinct, though many are similar.
.PP
In either case, setting it directs \fBncurses\fP to ignore
the usual place for this information, e.g., /etc/termcap.
.SS TERMINFO
-.PP
\fBncurses\fP can be configured to read from multiple terminal databases.
The \fBTERMINFO\fP variable overrides the location for
the default terminal database.
This is the scheme used in System V, which legacy Unix systems use,
and the \fBTERMINFO\fP variable is used by \fIcurses\fP applications on those
systems to override the default location of the terminal database.
-.bP
+.IP \(bu 4
If \fBncurses\fP is built to use hashed databases,
then each entry in this list may be the path of a hashed database file, e.g.,
-.NS
+.RS 4
+.PP
+.RS 4
+.EX
/usr/share/terminfo.db
-.NE
-.IP
+.EE
+.RE
+.PP
rather than
-.NS
+.PP
+.RS 4
+.EX
/usr/share/terminfo/
-.NE
-.IP
+.EE
+.RE
+.PP
The hashed database uses less disk-space and is a little faster than the
directory tree.
However,
some applications assume the existence of the directory tree,
reading it directly
rather than using the terminfo library calls.
+.RE
.bP
If \fBncurses\fP is built with a support for reading termcap files
directly, then an entry in this list may be the path of a termcap file.
-.bP
+.IP \(bu 4
If the \fBTERMINFO\fP variable begins with
\*(``hex:\*('' or \*(``b64:\*('',
\fBncurses\fP uses the remainder of that variable as a compiled terminal
description.
You might produce the base64 format using \fBinfocmp\fP(1M):
-.NS
-TERMINFO="$(infocmp -0 -Q2 -q)"
+.RS 4
+.PP
+.RS 4
+.EX
+TERMINFO="$(infocmp \-0 \-Q2 \-q)"
export TERMINFO
-.NE
-.IP
+.EE
+.RE
+.PP
The compiled description is used if it corresponds to the terminal identified
by the \fBTERM\fP variable.
+.RE
.PP
Setting \fBTERMINFO\fP is the simplest,
but not the only way to set location of the default terminal database.
@TERMINFO@ (corresponding to the TERMINFO variable)
.RE
.RE
-.PP
.SS TERMINFO_DIRS
-.PP
Specifies a list of locations to search for terminal descriptions.
Each location in the list is a terminal database as described in
the section on the \fBTERMINFO\fP variable.
There is no corresponding feature in System V terminfo;
it is an extension developed for \fBncurses\fP.
.SS TERMPATH
-.PP
If \fBTERMCAP\fP does not hold a file name then \fBncurses\fP checks
the \fBTERMPATH\fP environment variable.
This is a list of filenames separated by spaces or colons (i.e., ":") on Unix,
.PP
If the \fBTERMPATH\fP environment variable is not set,
\fBncurses\fP looks in the files
-.NS
+.PP
+.RS 4
+.EX
/etc/termcap, /usr/share/misc/termcap and $HOME/.termcap,
-.NE
+.EE
+.RE
.PP
in that order.
.PP
The library may be configured to disregard the following variables when the
current user is the superuser (root), or if the application uses setuid or
setgid permissions:
-.NS
+.PP
+.RS 4
+.EX
$TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
-.NE
+.EE
+.RE
.SH ALTERNATE CONFIGURATIONS
-.PP
Several different configurations are possible,
depending on the configure script options used when building \fBncurses\fP.
There are a few main options whose effects are visible to the applications
.TP 5
\-\-disable\-overwrite
The standard include for \fBncurses\fP is as noted in \fBSYNOPSIS\fP:
-.NS
+.RS 5
+.PP
+.RS 4
+.EX
\fB#include <curses.h>\fP
-.NE
-.IP
+.EE
+.RE
+.PP
This option is used to avoid filename conflicts when \fBncurses\fP
is not the main implementation of curses of the computer.
If \fBncurses\fP is installed disabling overwrite, it puts its headers in
a subdirectory, e.g.,
-.NS
+.PP
+.RS 4
+.EX
\fB#include <ncurses/curses.h>\fP
-.NE
-.IP
+.EE
+.RE
+.PP
It also omits a symbolic link which would allow you to use \fB\-lcurses\fP
to build executables.
+.RE
.TP 5
\-\-enable\-widec
The configure script renames the library and
puts the header files in a different subdirectory.
All of the library names have a \*(``w\*('' appended to them,
i.e., instead of
-.NS
+.RS 5
+.PP
+.RS 4
+.EX
\fB\-lncurses\fP
-.NE
-.IP
+.EE
+.RE
+.PP
you link with
-.NS
+.PP
+.RS 4
+.EX
\fB\-lncursesw\fP
-.NE
-.IP
+.EE
+.RE
+.PP
You must also enable the wide-character features in the header file
when compiling for the wide-character library
to use the extended (wide-character) functions.
The symbol which enables these features has changed since XSI Curses, Issue 4:
-.RS
.bP
Originally, the wide-character feature required the symbol
\fB_XOPEN_SOURCE_EXTENDED\fP
with the caveat that some other header file than \fBcurses.h\fP
may require a specific value for \fB_XOPEN_SOURCE\fP
(or a system-specific symbol).
-.RE
-.IP
+.PP
The \fBcurses.h\fP file which is installed for the wide-character
library is designed to be compatible with the normal library's header.
Only the size of the \fBWINDOW\fP structure differs, and very few
applications require more than a pointer to \fBWINDOW\fPs.
-.IP
+.PP
If the headers are installed allowing overwrite,
the wide-character library's headers should be installed last,
to allow applications to be built using either library
from the same set of headers.
+.RE
.TP 5
\-\-with\-pthread
The configure script renames the library.
than assuming it is always in the debug library.
.SH FILES
.TP 5
-@DATADIR@/tabset
-directory containing initialization files for the terminal capability database
-@TERMINFO@
-terminal capability database
-.SH SEE ALSO
-\fBterminfo\fP(\*n) and related pages whose names begin
-\*(``curs_\*('' for detailed routine descriptions.
-.br
-\fBcurs_variables\fP(3X)
-.br
-\fBuser_caps\fP(5) for user-defined capabilities
+.I @DATADIR@/tabset
+tab stop initialization database
+.TP
+.I \*d
+compiled terminal capability database
+.SH NOTES
+If standard output from a \fBncurses\fP program is re-directed to something
+which is not a tty, screen updates will be directed to standard error.
+This was an undocumented feature of AT&T System V Release 3 curses.
+.PP
+See subsection \*(``Header files\*('' below regarding symbols exposed by
+inclusion of \fI\%curses.h\fP.
.SH EXTENSIONS
The \fBncurses\fP library can be compiled with an option (\fB\-DUSE_GETCAP\fP)
that falls back to the old-style /etc/termcap file if the terminal setup code
the XSI Curses and \fBncurses\fP calls) are described in \fBPORTABILITY\fP
sections of the library man pages.
.SS Error checking
-.PP
In many cases, X/Open Curses is vague about error conditions,
omitting some of the SVr4 documentation.
.PP
Relying on this (or some other) extension will adversely affect the
portability of curses applications.
.SS Extensions versus portability
-.PP
Most of the extensions provided by ncurses have not been standardized.
Some have been incorporated into other implementations, such as
PDCurses or NetBSD curses.
improve the ability to manage multiple screens.
See \fBcurs_sp_funcs\fP(3X) for details.
.SS Padding differences
-.PP
In historic curses versions, delays embedded in the capabilities \fBcr\fP,
\fBind\fP, \fBcub1\fP, \fBff\fP and \fBtab\fP activated corresponding delay
-bits in the UNIX tty driver.
+bits in the Unix tty driver.
In this implementation, all padding is done by sending NUL bytes.
This method is slightly more expensive, but narrows the interface
-to the UNIX kernel significantly and increases the package's portability
+to the Unix kernel significantly and increases the package's portability
correspondingly.
.SS Header files
-The header file \fB<curses.h>\fP automatically includes the header files
-\fB<stdio.h>\fP and \fB<unctrl.h>\fP.
+The header file \fI\%curses.h\fP itself includes the header files
+\fI\%stdio.h\fP and \fI\%unctrl.h\fP.
.PP
X/Open Curses has more to say,
but does not finish the story:
to include <stdarg.h> before <curses.h> because they either
have allowed for a special type, or (like ncurses) include <stdarg.h>
directly to provide a portable interface.
-.SH NOTES
-.PP
-If standard output from a \fBncurses\fP program is re-directed to something
-which is not a tty, screen updates will be directed to standard error.
-This was an undocumented feature of AT&T System V Release 3 curses.
.SH AUTHORS
Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
Based on \fIpcurses\fP by Pavel Curtis.
+.SH SEE ALSO
+\fB\%terminfo\fP(5) and related pages whose names begin
+\*(``curs_\*('' for detailed routine descriptions.
+.br
+\fB\%curs_variables\fP(3X)
+.br
+\fB\%user_caps\fP(5) for user-defined capabilities