-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.
-(The BSD-style \fB\%@TSET@\fP(1) utility also performs this function.)
-See subsection \*(``Tabs and Initialization\*('' of \fBterminfo\fP(5).
-.SS Datatypes
-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.
-A default window called \fBstdscr\fP, which is the size of the terminal
-screen, is supplied.
-Others may be created with \fBnewwin\fP.
-.PP
-Note that \fBcurses\fP does not handle overlapping windows, that's done by
-the \fBpanel\fP(3X) library.
-This means that you can either use
-\fBstdscr\fP or divide the screen into tiled windows and not using
-\fBstdscr\fP at all.
-Mixing the two will result in unpredictable, and undesired, effects.
-.PP
-Windows are referred to by variables declared as \fBWINDOW *\fP.
-These data structures are manipulated with routines described here and
-elsewhere in the \fBncurses\fP manual pages.
-Among those, the most basic
-routines are \fBmove\fP and \fBaddch\fP.
-More general versions of
-these routines are included with names beginning with \fBw\fP,
-allowing the user to specify a window.
-The routines not beginning
-with \fBw\fP affect \fBstdscr\fP.
-.PP
-After using routines to manipulate a window, \fBrefresh\fP(3X) is called,
-telling \fBcurses\fP to make the user's CRT screen look like
-\fBstdscr\fP.
-The characters in a window are actually of type
-\fBchtype\fP, (character and attribute data) so that other information
-about the character may also be stored with each character.
-.PP
-Special windows called \fIpads\fP 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 \fBcurs_pad\fP(3X) for more information.
-.PP
-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, \fBcurses\fP 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 \fB<curses.h>\fP,
-such as \fBA_REVERSE\fP, \fBACS_HLINE\fP, and \fBKEY_LEFT\fP.
-.SS Environment variables
-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.
-This would affect a program running in an AT&T 630 layer,
-for example, where the size of a
-screen is changeable (see \fBENVIRONMENT\fP).
-.PP
-If the environment variable \fBTERMINFO\fP is defined, any program using
-\fBcurses\fP checks for a local terminal definition before checking in the
-standard place.
-For example, if \fBTERM\fP is set to \fBatt4424\fP, then the
-compiled terminal definition is found in
-.PP
-.RS 4
-.EX
-\fB\*d/a/att4424\fP.
-.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
-.PP
-.RS 4
-.EX
-\fB$HOME/myterms/a/att4424\fP,
-.EE
-.RE
-.PP
-and if that fails, it then checks
-.PP
-.RS 4
-.EX
-\fB\*d/a/att4424\fP.
-.EE
-.RE
-.PP
-This is useful for developing experimental definitions or when write
-permission in \fB\*d\fP is not available.
-.PP
-The integer variables \fBLINES\fP and \fBCOLS\fP are defined in
-\fB<curses.h>\fP and will be filled in by \fBinitscr\fP with the size of the
-screen.
-The constants \fBTRUE\fP and \fBFALSE\fP have the values \fB1\fP and
-\fB0\fP, respectively.
+A
+.I curses
+program then often enters an event loop of some sort.
+Call \fB\%endwin\fP(3X) before exiting.
+.SS Overview
+A
+.I curses
+library abstracts the terminal screen by representing all or part of it
+as a
+.I \%WINDOW
+data structure.
+A
+.I window
+is a rectangular grid of character cells,
+addressed by row and column coordinates
+.RI ( y ,
+.IR x ),
+with the upper left corner as (0, 0).
+A window called
+.BR \%stdscr ,
+the same size as the terminal screen,
+is always available.
+Create others with \fB\%newwin\fP(3X).
+.PP
+A
+.I curses
+library does not manage overlapping windows
+(but see below).
+You can either use
+.B \%stdscr
+to manage one screen-filling window,
+or tile the screen into non-overlapping windows and not use
+.B \%stdscr
+at all.
+Mixing the two approaches will result in unpredictable and undesired
+effects.
+.PP
+Functions permit manipulation of a window and the
+.I cursor
+identifying the cell within it at which the next output operation will
+occur.
+Among those,
+the most basic are \fB\%move\fP(3X) and \fB\%addch\fP(3X):
+these place the cursor and write a character to
+.BR \%stdscr ,
+respectively.
+.PP
+Frequent changes to the terminal screen can cause unpleasant flicker or
+inefficient use of the communication channel to the device,
+so as a rule the library does not update it automatically.
+Therefore,
+after using
+.I curses
+functions to accumulate a set of desired updates that make sense to
+present together,
+call \fB\%refresh\fP(3X) to tell the library to make the user's screen
+look like \fBstdscr\fP.
+The library
+.\" X/Open Curses Issue 7 assumes some optimization will be done, but
+.\" does not mandate it in any way.
+.I optimizes
+its output by computing a minimal volume of operations to mutate the
+screen from its state at the previous refresh to the new one.
+Effective optimization demands accurate information about the terminal
+device:
+the management of such information is the province of the
+\fB\%terminfo\fP(3X) API,
+a feature of every standard
+.I curses
+implementation.
+.PP
+Special windows called
+.I pads
+may also be manipulated.
+These are not constrained to the size of the terminal screen and their
+contents need not be completely displayed.
+See \fB\%curs_pad\fP(3X).
+.PP
+Many terminals support configuration of character cell foreground and
+background colors as well as rendering
+.I attributes ,
+which cause characters to show up in such modes as
+boldfaced,
+underlined,
+or in reverse video.
+See \fB\%curs_attr\fP(3X).
+.PP
+.I curses
+predefines constants for a small set of forms-drawing graphics
+corresponding to the DEC Alternate Character Set (ACS),
+a feature of VT100 and other terminals.
+See \fB\%addch\fP(3X).
+.PP
+.I curses
+is implemented using the operating system's terminal driver;
+key events are received not as scan codes but as byte sequences.
+Graphical keycaps
+(alphanumeric and punctuation keys,
+and the space)
+appear as-is.
+Everything else,
+including the tab,
+enter/return,
+keypad,
+arrow,
+and function keys,
+appears as a control character or a multibyte
+.I "escape sequence."
+.I curses
+translates the latter into unique
+.I "key codes."
+See \fB\%getch\fP(3X).
+.PP
+.I \%ncurses
+provides reimplementations of the SVr4 \fBpanel\fP(3X), \fBform\fP(3X),
+and \fBmenu\fP(3X) libraries;
+they permit overlapping windows and ease construction of user interfaces
+with
+.IR curses .
+.SS "Initialization"
+The selection of an appropriate value of
+.I TERM
+in the process environment is essential to correct
+.I curses
+and
+.I \%term\%info
+library operation.
+A well-configured system selects a correct
+.I TERM
+value automatically;
+\fB\%tset\fP(1) may assist with troubleshooting exotic situations.
+.PP
+If you change the terminal type,
+export the shell's
+.I TERM
+variable,
+then run \fB\%tset\fP(1) or the
+.RB \*(`` "@TPUT@ init" \*(''
+command.
+See subsection \*(``Tabs and Initialization\*('' of \fB\%terminfo\fP(5).
+.PP
+If the environment variables
+.I \%LINES
+and
+.I \%COLUMNS
+are set,
+or if the
+.I curses
+program is executing in a graphical windowing environment,
+the information obtained thence overrides that obtained by
+.IR \%term\%info .
+An
+.I \%ncurses
+extension supports resizable terminals;
+see \fB\%wresize\fP(3X).
+.PP
+If the environment variable
+.I \%TERMINFO
+is defined,
+a
+.I curses
+program checks first for a terminal type description in the location it
+identifies.
+.I \%TERMINFO
+is useful for developing type descriptions or when write permission to
+.I \%@TERMINFO@
+is not available.
+.PP
+See section \*(``ENVIRONMENT\*('' below.
+.SS "Naming Conventions"
+.I curses
+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
+.I \%WINDOW
+pointer argument;
+those with a \*(``mv\*('' prefix first perform cursor movement using
+\fB\%wmove\fP(3X);
+a \*(``mvw\*('' prefix indicates both.
+The \*(``w\*('' function is typically the elemental one;
+the removal of this prefix usually indicates operation on
+.BR \%stdscr .
+.PP
+Four functions prefixed with \*(``p\*('' require a pad argument.
+.PP
+In function synopses,
+.I \%ncurses
+man pages apply the following names to parameters.