initscr(3X) initscr(3X)
NAME
initscr, newterm - screen initialisation functions
SYNOPSIS
cc [flag ...] file ... -lcurses [library ...]
#include <curses.h>
WINDOW *initscr(void);
SCREEN *newterm(char *type, FILE *outfile, FILE *infile);
DESCRIPTION
The initscr() function determines the terminal type and initialises
all implementation data structures. The TERM environment variable
specifies the terminal type. The initscr() function also causes the
first refresh operation to clear the screen. If errors occur,
initscr() writes an appropriate error message to standard error and
exits. The only functions that can be called before initscr() or
newterm() are filter(), ripoffline(), slkinit(), useenv() and the
functions whose prototypes are defined in <term.h>. Portable applica-
tions must not call initscr() twice.
The newterm() function can be called as many times as desired to
attach a terminal device. The type argument points to a string speci-
fying the terminal type, except that if type is a null pointer, the
TERM environment variable is used. The outfile and infile arguments
are file pointers for output to the terminal and input from the termi-
nal, respectively. It is unspecified whether Curses modifies the
buffering mode of these file pointers. The newterm() function should
be called once for each terminal.
The initscr() function is equivalent to:
newterm(getenv("TERM"), stdout, stdin); return stdscr;
If the current disposition for the signals SIGINT, SIGQUIT or SIGTSTP
is SIGDFL, then initscr() may also install a handler for the signal,
which may remain in effect for the life of the process or until the
process changes the disposition of the signal.
The initscr() and newterm() functions initialise the curterm external
variable.
RETURN VALUE
Upon successful completion, initscr() returns a pointer to stdscr.
Otherwise, it does not return.
Upon successful completion, newterm() returns a pointer to the speci-
fied terminal. Otherwise, it returns a null pointer.
Page 1 Reliant UNIX 5.44 Printed 11/98
initscr(3X) initscr(3X)
ERRORS
No errors are defined.
NOTES
A program that outputs to more than one terminal should use newterm()
for each terminal instead of initscr(). A program that needs an indi-
cation of error conditions, so it can continue to run in a line-
oriented mode if the terminal cannot support a screen-oriented pro-
gram, would also use this function.
Applications should perform any required handling of the SIGINT,
SIGQUIT or SIGTSTP signals before calling initscr().
SEE ALSO
curses(3X), delscreen(3X), doupdate(3X), delcurterm(3X), filter(3X),
slkattroff(3X), useenv(3X), curses(5), term(5).
Page 2 Reliant UNIX 5.44 Printed 11/98