- Initially, <B>setupterm</B> should be called. Note that
- <B>setupterm</B> is automatically called by <B>initscr</B> and <B>newterm</B>.
- This defines the set of terminal-dependent variables
- [listed in <B><A HREF="terminfo.5.html">terminfo(5)</A></B>]. The <B>terminfo</B> variables <B>lines</B> and
- <B>columns</B> are initialized by <B>setupterm</B> as follows: If
- <B>use_env(FALSE)</B> has been called, values for <B>lines</B> and
- <B>columns</B> specified in <B>terminfo</B> are used. Otherwise, if the
- environment variables <B>LINES</B> and <B>COLUMNS</B> exist, their val-
- ues are used. If these environment variables do not exist
- and the program is running in a window, the current window
- size is used. Otherwise, if the environment variables do
- not exist, the values for <B>lines</B> and <B>columns</B> specified in
- the <B>terminfo</B> database are used.
-
- The header files <B>curses.h</B> and <B>term.h</B> should be included
- (in this order) to get the definitions for these strings,
- numbers, and flags. Parameterized strings should be
- passed through <B>tparm</B> to instantiate them. All <B>terminfo</B>
- strings [including the output of <B>tparm</B>] should be printed
- with <B>tputs</B> or <B>putp</B>. Call the <B>reset_shell_mode</B> to restore
- the tty modes before exiting [see <B><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></B>].
- Programs which use cursor addressing should output
- <B>enter_ca_mode</B> upon startup and should output <B>exit_ca_mode</B>
- before exiting. Programs desiring shell escapes should
- call
-
- <B>reset_shell_mode</B> and output <B>exit_ca_mode</B> before the shell
- is called and should output <B>enter_ca_mode</B> and call
- <B>reset_prog_mode</B> after returning from the shell.
-
- The <B>setupterm</B> routine reads in the <B>terminfo</B> database, ini-
- tializing the <B>terminfo</B> structures, but does not set up the
- output virtualization structures used by <B>curses</B>. The ter-
- minal type is the character string <I>term</I>; if <I>term</I> is null,
- the environment variable <B>TERM</B> is used. All output is to
- file descriptor <B>fildes</B> which is initialized for output.
- If <I>errret</I> is not null, then <B>setupterm</B> returns <B>OK</B> or <B>ERR</B>
- and stores a status value in the integer pointed to by
- <I>errret</I>. A return value of <B>OK</B> combined with status of <B>1</B> in
- <I>errret</I> is normal. If <B>ERR</B> is returned, examine <I>errret</I>:
-
- <B>1</B> means that the terminal is hardcopy, cannot be
- used for curses applications.
-
- <B>0</B> means that the terminal could not be found, or
- that it is a generic type, having too little
- information for curses applications to run.
-
- <B>-1</B> means that the <B>terminfo</B> database could not be
- found.
-
- If <I>errret</I> is null, <B>setupterm</B> prints an error message upon
- finding an error and exits. Thus, the simplest call is:
-
- <B>setupterm((char</B> <B>*)0,</B> <B>1,</B> <B>(int</B> <B>*)0);</B>,