2 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
4 <STRONG>initscr</STRONG>, <STRONG>newterm</STRONG>, <STRONG>endwin</STRONG>, <STRONG>isendwin</STRONG>, <STRONG>set_term</STRONG>, <STRONG>delscreen</STRONG> -
5 <STRONG>curses</STRONG> screen initialization and manipulation routines
10 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
12 <STRONG>WINDOW</STRONG> <STRONG>*initscr(void);</STRONG>
13 <STRONG>int</STRONG> <STRONG>endwin(void);</STRONG>
14 <STRONG>int</STRONG> <STRONG>isendwin(void);</STRONG>
15 <STRONG>SCREEN</STRONG> <STRONG>*newterm(const</STRONG> <STRONG>char</STRONG> <STRONG>*type,</STRONG> <STRONG>FILE</STRONG> <STRONG>*outfd,</STRONG> <STRONG>FILE</STRONG>
16 <STRONG>*infd);</STRONG>
17 <STRONG>SCREEN</STRONG> <STRONG>*set_term(SCREEN</STRONG> <STRONG>*new);</STRONG>
18 <STRONG>void</STRONG> <STRONG>delscreen(SCREEN*</STRONG> <STRONG>sp);</STRONG>
22 <H2>DESCRIPTION</H2><PRE>
23 <STRONG>initscr</STRONG> is normally the first <STRONG>curses</STRONG> routine to call when
24 initializing a program. A few special routines sometimes
25 need to be called before it; these are <STRONG>slk_init</STRONG>, <STRONG>filter</STRONG>,
26 <STRONG>ripoffline</STRONG>, <STRONG>use_env</STRONG>. For multiple-terminal applications,
27 <STRONG>newterm</STRONG> may be called before <STRONG>initscr</STRONG>.
29 The initscr code determines the terminal type and initial-
30 izes all <STRONG>curses</STRONG> data structures. <STRONG>initscr</STRONG> also causes the
31 first call to <STRONG>refresh</STRONG> to clear the screen. If errors
32 occur, <STRONG>initscr</STRONG> writes an appropriate error message to
33 standard error and exits; otherwise, a pointer is returned
34 to <STRONG>stdscr</STRONG>.
36 A program that outputs to more than one terminal should
37 use the <STRONG>newterm</STRONG> routine for each terminal instead of
38 <STRONG>initscr</STRONG>. A program that needs to inspect capabilities, so
39 it can continue to run in a line-oriented mode if the ter-
40 minal cannot support a screen-oriented program, would also
41 use <STRONG>newterm</STRONG>. The routine <STRONG>newterm</STRONG> should be called once
42 for each terminal. It returns a variable of type <STRONG>SCREEN</STRONG> <STRONG>*</STRONG>
43 which should be saved as a reference to that terminal.
44 The arguments are the <EM>type</EM> of the terminal to be used in
45 place of <STRONG>$TERM</STRONG>, a file pointer for output to the terminal,
46 and another file pointer for input from the terminal (if
47 <EM>type</EM> is <STRONG>NULL</STRONG>, <STRONG>$TERM</STRONG> will be used). The program must also
48 call <STRONG>endwin</STRONG> for each terminal being used before exiting
49 from <STRONG>curses</STRONG>. If <STRONG>newterm</STRONG> is called more than once for the
50 same terminal, the first terminal referred to must be the
51 last one for which <STRONG>endwin</STRONG> is called.
53 A program should always call <STRONG>endwin</STRONG> before exiting or
54 escaping from <STRONG>curses</STRONG> mode temporarily. This routine
55 restores tty modes, moves the cursor to the lower left-
56 hand corner of the screen and resets the terminal into the
57 proper non-visual mode. Calling <STRONG>refresh</STRONG> or <STRONG>doupdate</STRONG> after
58 a temporary escape causes the program to resume visual
60 called without any subsequent calls to <STRONG>wrefresh</STRONG>, and <STRONG>FALSE</STRONG>
63 The <STRONG>set_term</STRONG> routine is used to switch between different
64 terminals. The screen reference <STRONG>new</STRONG> becomes the new cur-
65 rent terminal. The previous terminal is returned by the
66 routine. This is the only routine which manipulates
67 <STRONG>SCREEN</STRONG> pointers; all other routines affect only the cur-
70 The <STRONG>delscreen</STRONG> routine frees storage associated with the
71 <STRONG>SCREEN</STRONG> data structure. The <STRONG>endwin</STRONG> routine does not do
72 this, so <STRONG>delscreen</STRONG> should be called after <STRONG>endwin</STRONG> if a par-
73 ticular <STRONG>SCREEN</STRONG> is no longer needed.
77 <H2>RETURN VALUE</H2><PRE>
78 <STRONG>endwin</STRONG> returns the integer <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> upon
79 successful completion.
81 Routines that return pointers always return <STRONG>NULL</STRONG> on error.
86 Note that <STRONG>initscr</STRONG> and <STRONG>newterm</STRONG> may be macros.
90 <H2>PORTABILITY</H2><PRE>
91 These functions are described in the XSI Curses standard,
92 Issue 4. It specifies that portable applications must not
93 call <STRONG>initscr</STRONG> more than once.
97 <H2>SEE ALSO</H2><PRE>
98 <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>, <STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3X)</A></STRONG>, <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3X)</A></STRONG>,
99 <STRONG><A HREF="curs_slk.3x.html">curs_slk(3X)</A></STRONG>, <STRONG><A HREF="curs_util.3x.html">curs_util(3X)</A></STRONG>