]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_initscr.3x
66aae13cab1d72aff6432d19dc5efef9d041fc99
[ncurses.git] / man / curs_initscr.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998 Free Software Foundation, Inc.                        *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_initscr.3x,v 1.8 1999/09/18 23:52:30 tom Exp $
30 .TH curs_initscr 3X ""
31 .SH NAME
32 \fBinitscr\fR, \fBnewterm\fR, \fBendwin\fR,
33 \fBisendwin\fR, \fBset_term\fR, \fBdelscreen\fR - \fBcurses\fR screen
34 initialization and manipulation routines
35 .SH SYNOPSIS
36 \fB#include <curses.h>\fR
37
38 \fBWINDOW *initscr(void);\fR
39 .br
40 \fBint endwin(void);\fR
41 .br
42 \fBint isendwin(void);\fR
43 .br
44 \fBSCREEN *newterm(const char *type, FILE *outfd, FILE *infd);\fR
45 .br
46 \fBSCREEN *set_term(SCREEN *new);\fR
47 .br
48 \fBvoid delscreen(SCREEN* sp);\fR
49 .br
50 .SH DESCRIPTION
51 \fBinitscr\fR is normally the first \fBcurses\fR routine to call when
52 initializing a program.  A few special routines sometimes need to be
53 called before it; these are \fBslk_init\fR, \fBfilter\fR, \fBripoffline\fR,
54 \fBuse_env\fR.  For multiple-terminal applications, \fBnewterm\fR may be
55 called before \fBinitscr\fR.
56
57 The initscr code determines the terminal type and initializes all \fBcurses\fR
58 data structures.  \fBinitscr\fR also causes the first call to \fBrefresh\fR to
59 clear the screen.  If errors occur, \fBinitscr\fR writes an appropriate error
60 message to standard error and exits; otherwise, a pointer is returned to
61 \fBstdscr\fR.
62
63 A program that outputs to more than one terminal should use the \fBnewterm\fR
64 routine for each terminal instead of \fBinitscr\fR.  A program that needs to
65 inspect capabilities, so it can continue to run in a line-oriented mode if the
66 terminal cannot support a screen-oriented program, would also use
67 \fBnewterm\fR.  The routine \fBnewterm\fR should be called once for each
68 terminal.  It returns a variable of type \fBSCREEN *\fR which should be saved
69 as a reference to that terminal.  The arguments are the \fItype\fR of the
70 terminal to be used in place of \fB$TERM\fR, a file pointer for output to the
71 terminal, and another file pointer for input from the terminal (if \fItype\fR
72 is \fBNULL\fR, \fB$TERM\fR will be used).  The program must also call
73 \fBendwin\fR for each terminal being used before exiting from \fBcurses\fR.
74 If \fBnewterm\fR is called more than once for the same terminal, the first
75 terminal referred to must be the last one for which \fBendwin\fR is called.
76
77 A program should always call \fBendwin\fR before exiting or escaping from
78 \fBcurses\fR mode temporarily.  This routine restores tty modes, moves the
79 cursor to the lower left-hand corner of the screen and resets the terminal into
80 the proper non-visual mode.  Calling \fBrefresh\fR or \fBdoupdate\fR after a
81 temporary escape causes the program to resume visual mode.
82
83 The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
84 called without any subsequent calls to \fBwrefresh\fR, and \fBFALSE\fR
85 otherwise.
86
87 The \fBset_term\fR routine is used to switch between different
88 terminals.  The screen reference \fBnew\fR becomes the new current
89 terminal.  The previous terminal is returned by the routine.  This is
90 the only routine which manipulates \fBSCREEN\fR pointers; all other
91 routines affect only the current terminal.
92
93 The \fBdelscreen\fR routine frees storage associated with the
94 \fBSCREEN\fR data structure.  The \fBendwin\fR routine does not do
95 this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
96 particular \fBSCREEN\fR is no longer needed.
97 .SH RETURN VALUE
98 \fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
99 upon successful completion.
100
101 Routines that return pointers always return \fBNULL\fR on error.
102 .SH NOTES
103 Note that \fBinitscr\fR and \fBnewterm\fR may be macros.
104 .SH PORTABILITY
105 These functions are described in the XSI Curses standard, Issue 4.  It
106 specifies that portable applications must not call \fBinitscr\fR more than
107 once.
108
109 Old versions of curses, e.g., BSD 4.4, may have returned a null pointer
110 from \fBinitscr\fR when an error is detected, rather than exiting.
111 It is safe but redundant to check the return value of \fBinitscr\fR 
112 in XSI Curses.
113 .SH SEE ALSO
114 \fBcurses\fR(3X), \fBcurs_kernel\fR(3X), \fBcurs_refresh\fR(3X),
115 \fBcurs_slk\fR(3X), \fBcurs_util\fR(3X)
116 .\"#
117 .\"# The following sets edit modes for GNU EMACS
118 .\"# Local Variables:
119 .\"# mode:nroff
120 .\"# fill-column:79
121 .\"# End: