'\"macro stdmacro
.if n .pH g3x.curs_initscr @(#)curs_initscr	40.3 of 12/15/89
.\" Copyright 1989 AT&T
.\" ident	"@(#)svid_ti:ti_lib/curs_initscr	1.3"
.nr X
.if \nX=0 .ds x} curs_initscr 3X "" "\&"
.if \nX=1 .ds x} curs_initscr 3X ""
.if \nX=2 .ds x} curs_initscr 3X "" "\&"
.if \nX=3 .ds x} curs_initscr "" "" "\&"
.TH \*(x}
.SH NAME
\f4curs_initscr\f2: \f4 initscr\f1, \f4newterm\f1, \f4endwin\f1, \f4isendwin\f1, \f4set_term\f1, \f4delscreen\f1 \- \f4curses\fP screen initialization and manipulation routines
.SH SYNOPSIS
.nf
.ft 4
#include <curses.h>
.sp
WINDOW *initscr(void);
.sp .5
int endwin(void);
.sp .5
int isendwin(void);
.sp .5
SCREEN *newterm(char *type, FILE *outfd, FILE *infd);
.sp .5
SCREEN *set_term(SCREEN *new);
.sp .5
void delscreen(SCREEN* sp);
.ft 1
.fi
.SH DESCRIPTION
\f4initscr\f1 is almost always the first routine that should be
called (the exceptions are \f4slk_init\f1, \f4filter\f1,
\f4ripoffline\f1,
\f4use_env\fP and, for multiple-terminal applications,
\f4newterm\fP.)
This determines the terminal type and initializes all
\f4curses\fP data structures.
\f4initscr\f1 also causes the first call to
\f4refresh\f1 to clear the screen.
If errors occur,
\f4initscr\f1 writes an appropriate error message to
standard error and exits;
otherwise,
a pointer is returned to \f4stdscr\f1.
If the program needs an indication of error conditions,
\f4newterm(\)\f1 should be used instead of \f4initscr\f1;
\f4initscr\f1 should only be called once per application.
.P
A program that outputs to more than one terminal should use
the \f4newterm\f1 routine for each terminal instead of
\f4initscr\f1.
A program that needs an indication of error conditions, so it can
continue to run in a line-oriented mode if the terminal
cannot support a screen-oriented program,
would also use this routine.
The routine \f4newterm\f1
should be called once for each terminal.
It returns a variable of type
\f4SCREEN *\f1
which should be saved as a reference to that terminal.
The arguments are the \f2type\f1 of the terminal to be used in place of
\f4$TERM\f1,
a file pointer for output to the terminal,
and another file pointer for input from the terminal (if \f2type\fP is
\f4NULL\fP, \f4$TERM\fP will be used).
The program must also call
\f4endwin\f1
for each terminal being used before exiting from curses.
If \f4newterm\f1 is called more than once for the same terminal,
the first terminal referred to must be the last one for
which \f4endwin\f1 is called.
.P
A program should always call \f4endwin\f1
before exiting or escaping from \f4curses\fP mode temporarily.
This routine restores tty modes, moves the cursor to the lower
left-hand corner of the screen and resets the terminal
into the proper non-visual mode.
Calling \f4refresh\f1 or \f4doupdate\f1
after a temporary escape causes the program to resume visual mode.
.P
The \f4isendwin\f1 routine
returns \f4TRUE\f1 if \f4endwin\f1 has been called without
any subsequent calls to \f4wrefresh\f1, and \f4FALSE\fP otherwise.
.P
The \f4set_term\f1 routine is used to switch
between different terminals.
The screen reference
\f4new\f1
becomes the new current terminal.
The previous terminal is returned by the routine.
This is the only routine which manipulates
\f4SCREEN\f1 pointers;
all other routines affect only the current terminal.
.P
The \f4delscreen\fP routine frees storage associated with the
\f4SCREEN\fP data structure.  The \f4endwin\fP routine does not
do this, so \f4delscreen\fP should be called after \f4endwin\fP
if a particular \f4SCREEN\fP is no longer needed.
.SH RETURN VALUE
\f4endwin\fP returns the integer \f4ERR\f1 upon
failure and \f4OK\f1
upon successful completion.
.P
Routines that return pointers always return \f4NULL\f1 on error.
.SH NOTES
.P
The header file \f4<curses.h>\f1 automatically includes the header files
\f4<stdio.h>\f1 and \f4<unctrl.h>\f1.
.PP
Note that \f4initscr\fP and \f4newterm\fP may be macros.
.SH SEE ALSO
.na
\f4curses\fP(3X),
\f4curs_kernel\fP(3X),
\f4curs_refresh\fP(3X),
\f4curs_slk\fP(3X),
\f4curs_util\fP(3X).
.ad
