- The library uses the locale which the calling program has initialized.
- That is normally done with <STRONG>setlocale(3)</STRONG>:
-
- <STRONG>setlocale(LC_ALL,</STRONG> <STRONG>"");</STRONG>
-
- If the locale is not initialized, the library assumes that characters
- are printable as in ISO-8859-1, to work with certain legacy programs.
- You should initialize the locale and not rely on specific details of
- the library when the locale has not been setup.
-
- The function <STRONG>initscr</STRONG> or <STRONG>newterm</STRONG> must be called to initialize the
- library before any of the other routines that deal with windows and
- screens are used. The routine <STRONG><A HREF="curs_initscr.3x.html">endwin(3x)</A></STRONG> must be called before
- exiting.
-
- To get character-at-a-time input without echoing (most interactive,
- screen oriented programs want this), the following sequence should be
- used:
-
- <STRONG>initscr();</STRONG> <STRONG>cbreak();</STRONG> <STRONG>noecho();</STRONG>
-
- Most programs would additionally use the sequence:
-
- <STRONG>intrflush(stdscr,</STRONG> <STRONG>FALSE);</STRONG>
- <STRONG>keypad(stdscr,</STRONG> <STRONG>TRUE);</STRONG>
-
- Before a <STRONG>curses</STRONG> 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 <STRONG>tput</STRONG> <STRONG>init</STRONG> command after the shell
- environment variable <STRONG>TERM</STRONG> has been exported. <STRONG>tset(1)</STRONG> is usually
- responsible for doing this. [See <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG> for further details.]
-
-
-</PRE><H3><a name="h3-Datatypes">Datatypes</a></H3><PRE>
- The <STRONG>ncurses</STRONG> library permits manipulation of data structures, called
- <EM>windows</EM>, which can be thought of as two-dimensional arrays of
- characters representing all or part of a CRT screen. A default window
- called <STRONG>stdscr</STRONG>, which is the size of the terminal screen, is supplied.
- Others may be created with <STRONG>newwin</STRONG>.
-
- Note that <STRONG>curses</STRONG> does not handle overlapping windows, that's done by
- the <STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG> library. This means that you can either use <STRONG>stdscr</STRONG> or
- divide the screen into tiled windows and not using <STRONG>stdscr</STRONG> at all.
- Mixing the two will result in unpredictable, and undesired, effects.
-
- Windows are referred to by variables declared as <STRONG>WINDOW</STRONG> <STRONG>*</STRONG>. These data
- structures are manipulated with routines described here and elsewhere
- in the <STRONG>ncurses</STRONG> manual pages. Among those, the most basic routines are
- <STRONG>move</STRONG> and <STRONG>addch</STRONG>. More general versions of these routines are included
- with names beginning with <STRONG>w</STRONG>, allowing the user to specify a window.
- The routines not beginning with <STRONG>w</STRONG> affect <STRONG>stdscr</STRONG>.
-
- After using routines to manipulate a window, <STRONG><A HREF="curs_refresh.3x.html">refresh(3x)</A></STRONG> is called,
- telling <STRONG>curses</STRONG> to make the user's CRT screen look like <STRONG>stdscr</STRONG>. The
- characters in a window are actually of type <STRONG>chtype</STRONG>, (character and
- attribute data) so that other information about the character may also
- be stored with each character.
-
- Special windows called <EM>pads</EM> may also be manipulated. These are windows
- which are not constrained to the size of the screen and whose contents
- need not be completely displayed. See <STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG> for more
- information.
-
- In addition to drawing characters on the screen, video attributes and
- colors may be supported, causing the characters to show up in such
- modes as underlined, in reverse video, or in color on terminals that
- support such display enhancements. Line drawing characters may be
- specified to be output. On input, <STRONG>curses</STRONG> is also able to translate
- arrow and function keys that transmit escape sequences into single
- values. The video attributes, line drawing characters, and input
- values use names, defined in <STRONG><curses.h></STRONG>, such as <STRONG>A_REVERSE</STRONG>, <STRONG>ACS_HLINE</STRONG>,
- and <STRONG>KEY_LEFT</STRONG>.
-
-
-</PRE><H3><a name="h3-Environment-variables">Environment variables</a></H3><PRE>
- If the environment variables <STRONG>LINES</STRONG> and <STRONG>COLUMNS</STRONG> are set, or if the
- program is executing in a window environment, line and column
- information in the environment will override information read by
- <EM>terminfo</EM>. This would affect a program running in an AT&T 630 layer,
- for example, where the size of a screen is changeable (see
- <STRONG>ENVIRONMENT</STRONG>).
-
- If the environment variable <STRONG>TERMINFO</STRONG> is defined, any program using
- <STRONG>curses</STRONG> checks for a local terminal definition before checking in the
- standard place. For example, if <STRONG>TERM</STRONG> is set to <STRONG>att4424</STRONG>, then the
- compiled terminal definition is found in
-
- <STRONG>/usr/share/terminfo/a/att4424</STRONG>.
-
- (The <STRONG>a</STRONG> is copied from the first letter of <STRONG>att4424</STRONG> to avoid creation of
- huge directories.) However, if <STRONG>TERMINFO</STRONG> is set to <STRONG>$HOME/myterms</STRONG>,
- <STRONG>curses</STRONG> first checks
-
- <STRONG>$HOME/myterms/a/att4424</STRONG>,
-
- and if that fails, it then checks
-
- <STRONG>/usr/share/terminfo/a/att4424</STRONG>.
-
- This is useful for developing experimental definitions or when write
- permission in <STRONG>/usr/share/terminfo</STRONG> is not available.
-
- The integer variables <STRONG>LINES</STRONG> and <STRONG>COLS</STRONG> are defined in <STRONG><curses.h></STRONG> and will
- be filled in by <STRONG>initscr</STRONG> with the size of the screen. The constants
- <STRONG>TRUE</STRONG> and <STRONG>FALSE</STRONG> have the values <STRONG>1</STRONG> and <STRONG>0</STRONG>, respectively.
-
- The <STRONG>curses</STRONG> routines also define the <STRONG>WINDOW</STRONG> <STRONG>*</STRONG> variable <STRONG>curscr</STRONG> which is
- used for certain low-level operations like clearing and redrawing a
- screen containing garbage. The <STRONG>curscr</STRONG> can be used in only a few
- routines.
-
-
-</PRE><H3><a name="h3-Routine-and-Argument-Names">Routine and Argument Names</a></H3><PRE>
- Many <STRONG>curses</STRONG> routines have two or more versions. The routines prefixed
- with <EM>w</EM> require a window argument. The routines prefixed with <EM>p</EM> require
- a pad argument. Those without a prefix generally use <STRONG>stdscr</STRONG>.
-
- The routines prefixed with <STRONG>mv</STRONG> require a <EM>y</EM> and <EM>x</EM> coordinate to move to
- before performing the appropriate action. The <STRONG>mv</STRONG> routines imply a call
- to <STRONG>move</STRONG> before the call to the other routine. The coordinate <EM>y</EM> always
- refers to the row (of the window), and <EM>x</EM> always refers to the column.
- The upper left-hand corner is always (0,0), not (1,1).
-
- The routines prefixed with <STRONG>mvw</STRONG> take both a window argument and <EM>x</EM> and <EM>y</EM>
- coordinates. The window argument is always specified before the
- coordinates.
-
- In each case, <EM>win</EM> is the window affected, and <EM>pad</EM> is the pad affected;
- <EM>win</EM> and <EM>pad</EM> are always pointers to type <STRONG>WINDOW</STRONG>.
-
- Option setting routines require a Boolean flag <EM>bf</EM> with the value <STRONG>TRUE</STRONG>
- or <STRONG>FALSE</STRONG>; <EM>bf</EM> is always of type <STRONG>bool</STRONG>. Most of the data types used in
- the library routines, such as <STRONG>WINDOW</STRONG>, <STRONG>SCREEN</STRONG>, <STRONG>bool</STRONG>, and <STRONG>chtype</STRONG> are
- defined in <STRONG><curses.h></STRONG>. Types used for the terminfo routines such as
- <STRONG>TERMINAL</STRONG> are defined in <STRONG><term.h></STRONG>.
-
- This manual page describes functions which may appear in any
- configuration of the library. There are two common configurations of
- the library:
-
- <EM>ncurses</EM>
- the "normal" library, which handles 8-bit characters. The
- normal (8-bit) library stores characters combined with
- attributes in <STRONG>chtype</STRONG> data.
-
- Attributes alone (no corresponding character) may be stored in
- <STRONG>chtype</STRONG> or the equivalent <STRONG>attr_t</STRONG> data. In either case, the data
- is stored in something like an integer.
-
- Each cell (row and column) in a <STRONG>WINDOW</STRONG> is stored as a <STRONG>chtype</STRONG>.
-
- <EM>ncursesw</EM>
- the so-called "wide" library, which handles multibyte
- characters (see the section on <STRONG>ALTERNATE</STRONG> <STRONG>CONFIGURATIONS</STRONG>). The
- "wide" library includes all of the calls from the "normal"
- library. It adds about one third more calls using data types
- which store multibyte characters:
-
- <STRONG>cchar_t</STRONG>
- corresponds to <STRONG>chtype</STRONG>. However it is a structure, because
- more data is stored than can fit into an integer. The
- characters are large enough to require a full integer
- value - and there may be more than one character per cell.
- The video attributes and color are stored in separate
- fields of the structure.
-
- Each cell (row and column) in a <STRONG>WINDOW</STRONG> is stored as a
- <STRONG>cchar_t</STRONG>.
-
- The <STRONG><A HREF="curs_getcchar.3x.html">setcchar(3x)</A></STRONG> and <STRONG><A HREF="curs_getcchar.3x.html">getcchar(3x)</A></STRONG> functions store and
- retrieve the data from a <STRONG>cchar_t</STRONG> structure.
-
- <STRONG>wchar_t</STRONG>
- stores a "wide" character. Like <STRONG>chtype</STRONG>, this may be an
- integer.
-
- <STRONG>wint_t</STRONG>
- stores a <STRONG>wchar_t</STRONG> or <STRONG>WEOF</STRONG> - not the same, though both may
- have the same size.
-
- The "wide" library provides new functions which are analogous
- to functions in the "normal" library. There is a naming
- convention which relates many of the normal/wide variants: a
- "_w" is inserted into the name. For example, <STRONG>waddch</STRONG> becomes
- <STRONG>wadd_wch</STRONG>.
-
-
-</PRE><H3><a name="h3-Routine-Name-Index">Routine Name Index</a></H3><PRE>
- The following table lists the <STRONG>curses</STRONG> routines provided in the "normal"
- and "wide" libraries and the names of the manual pages on which they
- are described. Routines flagged with "*" are ncurses-specific, not
- described by XPG4 or present in SVr4.
-
- <STRONG>curses</STRONG> Routine Name Manual Page Name
+ The selection of an appropriate value of <EM>TERM</EM> in the process
+ environment is essential to correct <EM>curses</EM> and <EM>terminfo</EM> library
+ operation. A well-configured system selects a correct <EM>TERM</EM> value
+ automatically; <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG> may assist with troubleshooting exotic
+ situations.
+
+ If you change the terminal type, export the shell's <EM>TERM</EM> variable, then
+ run <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG> or the "<STRONG>tput</STRONG> <STRONG>init</STRONG>" command. See subsection "Tabs and
+ Initialization" of <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
+
+ If the environment variables <EM>LINES</EM> and <EM>COLUMNS</EM> are set, or if the
+ <EM>curses</EM> program is executing in a graphical windowing environment, the
+ information obtained thence overrides that obtained by <EM>terminfo</EM>. An
+ <EM>ncurses</EM> extension supports resizable terminals; see <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>.
+
+ If the environment variable <EM>TERMINFO</EM> is defined, a <EM>curses</EM> program
+ checks first for a terminal type description in the location it
+ identifies. <EM>TERMINFO</EM> is useful for developing type descriptions or
+ when write permission to <EM>/usr/share/terminfo</EM> is not available.
+
+ See section "ENVIRONMENT" below.
+
+
+</PRE><H3><a name="h3-Naming-Conventions">Naming Conventions</a></H3><PRE>
+ <EM>curses</EM> offers many functions in variant forms using a regular set of
+ alternatives to the name of an elemental one. Those prefixed with "w"
+ require a <EM>WINDOW</EM> pointer argument; those with a "mv" prefix first
+ perform cursor movement using <STRONG><A HREF="curs_move.3x.html">wmove(3x)</A></STRONG>; a "mvw" prefix indicates both.
+ The "w" function is typically the elemental one; the removal of this
+ prefix usually indicates operation on <STRONG>stdscr</STRONG>.
+
+ Four functions prefixed with "p" require a pad argument.
+
+ In function synopses, <EM>ncurses</EM> man pages apply the following names to
+ parameters. We introduce the character types in the next subsection.
+
+ <EM>bf</EM> a <EM>bool</EM> (<STRONG>TRUE</STRONG> or <STRONG>FALSE</STRONG>)
+ <EM>c</EM> a <EM>char</EM> or <EM>int</EM>
+ <EM>ch</EM> a <EM>chtype</EM>
+ <EM>wc</EM> a <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> or <EM>wint</EM><STRONG>_</STRONG><EM>t</EM>
+ <EM>wch</EM> a <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM>
+ <EM>win</EM> pointer to a <EM>WINDOW</EM>
+ <EM>pad</EM> pointer to a <EM>WINDOW</EM> that is a pad
+
+
+</PRE><H3><a name="h3-Wide-and-Non-wide-Character-Configurations">Wide and Non-wide Character Configurations</a></H3><PRE>
+ This man page primarily surveys functions that appear in any
+ configuration of the library. There are two common configurations; see
+ section "ALTERNATE CONFIGURATIONS" below.
+
+ <EM>ncurses</EM> is the library in its "non-wide" configuration, handling only
+ eight-bit characters. It stores a character combined with
+ attributes and a color pair in a <EM>chtype</EM> datum, which is often
+ an alias of <EM>int</EM>. A string of <EM>curses</EM> characters is similar to
+ a C <EM>char</EM> string; a <EM>chtype</EM> string ends with an integral <STRONG>0</STRONG>, the
+ null <EM>curses</EM> character.
+
+ Attributes and a color pair selection (with no corresponding
+ character) can be stored in variables of <EM>chtype</EM> or <EM>attr</EM><STRONG>_</STRONG><EM>t</EM>
+ type. In either case, they are accessed via an integral bit
+ mask.
+
+ Each cell of a <EM>WINDOW</EM> is stored as a <EM>chtype</EM>.
+
+ <EM>ncursesw</EM> is the library in its "wide" configuration, which handles
+ character encodings requiring a larger data type than <EM>char</EM> (a
+ byte-sized type) can represent. It provides additional
+ functions that complement those in the non-wide library where
+ the size of the underlying character type is significant. A
+ somewhat regular naming convention relates many of the wide
+ variants to their non-wide counterparts; where a non-wide
+ function name contains "ch" or "str", prefix it with "_w" to
+ obtain the wide counterpart. For example, <STRONG>waddch</STRONG> becomes
+ <STRONG>wadd_wch</STRONG>. (Exceptions that add only "w" comprise <STRONG>addwstr</STRONG>,
+ <STRONG>inwstr</STRONG>, and their variants.)
+
+ This convention is inapplicable to some non-wide function
+ names, so other transformations are used for the wide
+ configuration: the window background management function
+ "bkgd" becomes "bkgrnd"; the window border-drawing and
+ -clearing functions are suffixed with "_set"; and character
+ attribute manipulation functions like "attron" become
+ "attr_on".
+
+ <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> corresponds to the non-wide configuration's <EM>chtype</EM>.
+ It is a structure type because it requires more
+ storage than fits into a standard scalar type. A
+ character code may not be representable as a <EM>char</EM>,
+ and moreover more than one character may occupy a
+ cell (as with accent marks and other diacritics).
+ Each character is of type <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM>; a complex
+ character contains one spacing character and zero or
+ more non-spacing characters (see below). A string
+ of complex characters ends with a <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM> whose
+ <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> member is the null wide character.
+ Attributes and a color pair selection are stored in
+ separate fields of the structure, not combined into
+ an integer as in <EM>chtype</EM>.
+
+ Each cell of a <EM>WINDOW</EM> is stored as a <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM>.
+
+ <STRONG><A HREF="curs_getcchar.3x.html">setcchar(3x)</A></STRONG> and <STRONG><A HREF="curs_getcchar.3x.html">getcchar(3x)</A></STRONG> store and retrieve <EM>cchar</EM><STRONG>_</STRONG><EM>t</EM>
+ data. The wide library API of <EM>ncurses</EM> depends on two data
+ types standardized by ISO C95.
+
+ <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> stores a wide character. Like <EM>chtype</EM>, it may be an
+ alias of <EM>int</EM>. Depending on the character encoding,
+ a wide character may be <EM>spacing</EM>, meaning that it
+ occupies a character cell by itself and typically
+ accompanies cursor advancement, or <EM>non-spacing</EM>,
+ meaning that it occupies the same cell as a spacing
+ character, is often regarded as a "modifier" of the
+ base glyph with which it combines, and typically
+ does not advance the cursor.
+
+ <EM>wint</EM><STRONG>_</STRONG><EM>t</EM> can store a <EM>wchar</EM><STRONG>_</STRONG><EM>t</EM> or the constant <STRONG>WEOF</STRONG>,
+ analogously to the <EM>int</EM>-sized character manipulation
+ functions of ISO C and its constant <STRONG>EOF</STRONG>.
+
+
+</PRE><H3><a name="h3-Function-Name-Index">Function Name Index</a></H3><PRE>
+ The following table lists the <EM>curses</EM> functions provided in the non-wide
+ and wide APIs and the corresponding man pages that describe them.
+ Those flagged with "*" are <EM>ncurses</EM>-specific, neither described by
+ X/Open Curses nor present in SVr4.
+
+ <STRONG><EM>curses</EM></STRONG> Function Name Man Page