]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_initscr.3x
ncurses 5.9 - patch 20141018
[ncurses.git] / man / curs_initscr.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2013,2014 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.20 2014/03/01 22:31:22 tom Exp $
30 .TH curs_initscr 3X ""
31 .de bP
32 .IP \(bu 4
33 ..
34 .ie \n(.g .ds `` \(lq
35 .el       .ds `` ``
36 .ie \n(.g .ds '' \(rq
37 .el       .ds '' ''
38 .na
39 .hy 0
40 .SH NAME
41 \fBinitscr\fR,
42 \fBnewterm\fR,
43 \fBendwin\fR,
44 \fBisendwin\fR,
45 \fBset_term\fR,
46 \fBdelscreen\fR \- \fBcurses\fR screen initialization and manipulation routines
47 .ad
48 .hy
49 .SH SYNOPSIS
50 \fB#include <curses.h>\fR
51 .sp
52 \fBWINDOW *initscr(void);\fR
53 .br
54 \fBint endwin(void);\fR
55 .br
56 \fBbool isendwin(void);\fR
57 .br
58 \fBSCREEN *newterm(char *type, FILE *outfd, FILE *infd);\fR
59 .br
60 \fBSCREEN *set_term(SCREEN *new);\fR
61 .br
62 \fBvoid delscreen(SCREEN* sp);\fR
63 .br
64 .SH DESCRIPTION
65 \fBinitscr\fR is normally the first \fBcurses\fR routine to call when
66 initializing a program.
67 A few special routines sometimes need to be called before it;
68 these are \fBslk_init\fR, \fBfilter\fR, \fBripoffline\fR,
69 \fBuse_env\fR.
70 For multiple-terminal applications,
71 \fBnewterm\fR may be called before \fBinitscr\fR.
72 .PP
73 The initscr code determines the terminal type and initializes all \fBcurses\fR
74 data structures.
75 \fBinitscr\fR also causes the first call to \fBrefresh\fR to clear the screen.
76 If errors occur, \fBinitscr\fR writes an appropriate error
77 message to standard error and exits;
78 otherwise, a pointer is returned to \fBstdscr\fR.
79 .PP
80 A program that outputs to more than one terminal should use the \fBnewterm\fR
81 routine for each terminal instead of \fBinitscr\fR.
82 A program that needs to inspect capabilities,
83 so it can continue to run in a line-oriented mode if the
84 terminal cannot support a screen-oriented program, would also use
85 \fBnewterm\fR.
86 The routine \fBnewterm\fR should be called once for each terminal.
87 It returns a variable of type \fBSCREEN *\fR which should be saved
88 as a reference to that terminal.
89 \fBnewterm\fP's arguments are
90 .bP
91 the \fItype\fR of the terminal to be used in place of \fB$TERM\fR,
92 .bP
93 a file pointer for output to the terminal, and
94 .bP
95 another file pointer for input from the terminal
96 .PP
97 If the \fItype\fR parameter is \fBNULL\fR, \fB$TERM\fR will be used.
98 .PP
99 The program must also call
100 \fBendwin\fR for each terminal being used before exiting from \fBcurses\fR.
101 If \fBnewterm\fR is called more than once for the same terminal, the first
102 terminal referred to must be the last one for which \fBendwin\fR is called.
103 .PP
104 A program should always call \fBendwin\fR before exiting or escaping from
105 \fBcurses\fR mode temporarily.
106 This routine
107 .bP
108 restores tty modes,
109 .bP
110 moves the cursor to the lower left-hand corner of the screen and
111 .bP
112 resets the terminal into
113 the proper non-visual mode.
114 .PP
115 Calling \fBrefresh\fR or \fBdoupdate\fR after a
116 temporary escape causes the program to resume visual mode.
117 .PP
118 The \fBisendwin\fR routine returns \fBTRUE\fR if \fBendwin\fR has been
119 called without any subsequent calls to \fBwrefresh\fR,
120 and \fBFALSE\fR otherwise.
121 .PP
122 The \fBset_term\fR routine is used to switch between different terminals.
123 The screen reference \fBnew\fR becomes the new current terminal.
124 The previous terminal is returned by the routine.
125 This is the only routine which manipulates \fBSCREEN\fR pointers;
126 all other routines affect only the current terminal.
127 .PP
128 The \fBdelscreen\fR routine frees storage associated with the
129 \fBSCREEN\fR data structure.
130 The \fBendwin\fR routine does not do
131 this, so \fBdelscreen\fR should be called after \fBendwin\fR if a
132 particular \fBSCREEN\fR is no longer needed.
133 .SH RETURN VALUE
134 \fBendwin\fR returns the integer \fBERR\fR upon failure and \fBOK\fR
135 upon successful completion.
136 .PP
137 Routines that return pointers always return \fBNULL\fR on error.
138 .PP
139 X/Open defines no error conditions.
140 In this implementation
141 .bP
142 \fBendwin\fP returns an error if the terminal was not initialized.
143 .bP
144 \fBnewterm\fP
145 returns an error if it cannot allocate the data structures for the screen,
146 or for the top-level windows within the screen,
147 i.e.,
148 \fBcurscr\fP, \fBnewscr\fP, or \fBstdscr\fP.
149 .bP
150 \fBset_term\fP
151 returns no error.
152 .SH NOTES
153 Note that \fBinitscr\fR and \fBnewterm\fR may be macros.
154 .SH PORTABILITY
155 These functions are described in the XSI Curses standard, Issue 4.
156 It specifies that portable applications must not
157 call \fBinitscr\fR more than once.
158 .PP
159 Old versions of curses, e.g., BSD 4.4, may have returned a null pointer
160 from \fBinitscr\fR when an error is detected, rather than exiting.
161 It is safe but redundant to check the return value of \fBinitscr\fR
162 in XSI Curses.
163 .PP
164 If the TERM variable is missing or empty, \fBinitscr\fP uses the
165 value \*(``unknown\*('',
166 which normally corresponds to a terminal entry with the \fIgeneric\fP
167 (\fIgn\fP) capability.
168 Generic entries are detected by \fBsetupterm\fP(3X) and cannot be
169 used for full-screen operation.
170 Other implementations may handle a missing/empty TERM variable differently.
171 .SH SEE ALSO
172 \fBcurses\fR(3X),
173 \fBcurs_kernel\fR(3X),
174 \fBcurs_refresh\fR(3X),
175 \fBcurs_slk\fR(3X),
176 \fBcurs_terminfo\fR(3X),
177 \fBcurs_util\fR(3X),
178 \fBcurs_variables\fR(3X).