'\"macro stdmacro
.if n .pH g3x.curs_termin @(#)curs_termin	40.3 of 12/15/89
.\" Copyright 1989 AT&T
.\" ident	"@(#)svid_ti:ti_lib/curs_termin	1.5"
.nr X
.if \nX=0 .ds x} curs_terminfo 3X "" "\&"
.if \nX=1 .ds x} curs_terminfo 3X ""
.if \nX=2 .ds x} curs_terminfo 3X "" "\&"
.if \nX=3 .ds x} curs_terminfo "" "" "\&"
.TH \*(x}
.SH NAME
\f4curs_terminfo\f2: \f4 setupterm\f1, \f4setterm\f1, \f4set_curterm\f1, \f4del_curterm\f1, \f4restartterm\f1, \f4tparm\f1, \f4tputs\f1, \f4putp\f1, \f4vidputs\f1, \f4vidattr\f1, \f4mvcur\f1, \f4tigetflag\f1, \f4tigetnum\f1, \f4tigetstr\f1 \- \f4curses\fP interfaces to terminfo database
.SH SYNOPSIS
.nf
.ft 4
#include <curses.h>
#include <term.h>
.sp
int setupterm(char *term, int fildes, int *errret);
.sp 0.5
int setterm(char *term);
.sp 0.5
int set_curterm(TERMINAL *nterm);
.sp 0.5
int del_curterm(TERMINAL *oterm);
.sp 0.5
int restartterm(char *term, int fildes, int *errret);
.sp 0.5
char *tparm(char *str, long int p1, long int p2, long int p3,
	long int p4, long int p5, long int p6, long int p7,
	long int p8, long int p9);
.sp 0.5
int tputs(char *str, int affcnt, int (*putc)(char));
.sp 0.5
int putp(char *str);
.sp 0.5
int vidputs(chtype attrs, int (*putc)(char));
.sp 0.5
int vidattr(chtype attrs);
.sp 0.5
int mvcur(int oldrow, int oldcol, int newrow, int newcol);
.sp 0.5
int tigetflag(char *capname);
.sp 0.5
int tigetnum(char *capname);
.sp 0.5
int tigetstr(char *capname);
.ft 1
.fi
.SH DESCRIPTION
These low-level routines must be called by programs that have to deal
directly with the \f2terminfo\fP database to handle certain terminal
capabilities, such as programming function keys.
For all other functionality, \f4curses\fP routines are more suitable
and their use is recommended.
.P
Initially, \f4setupterm\f1 should be called.
Note that \f4setupterm\f1 is automatically called by
\f4initscr\f1 and \f4newterm\f1.
This defines the set of terminal-dependent variables [listed
in \f4terminfo\fP(4)].
The \f2terminfo\f1 variables \f4lines\f1 and \f4columns\f1
are initialized by \f4setupterm\f1 as follows:  If
\f4use_env(FALSE)\fP has been called, values for \f4lines\fP
and \f4columns\fP specified in \f2terminfo\fP are used.
Otherwise,
if the environment variables \f4LINES\fP and \f4COLUMNS\fP exist, their
values 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 \f4lines\f1 and \f4columns\f1 specified
in the \f2terminfo\f1 database are used.
.P
The header files \f4<curses.h>\f1 and \f4<term.h>\f1 should be
included
(in this order)
to get the definitions for these strings, numbers, and flags.
Parameterized strings should be passed through \f4tparm\f1
to instantiate them.
All \f2terminfo\f1 strings [including the output of \f4tparm\f1]
should be printed with \f4tputs\f1 or \f4putp\f1.
Call the \f4reset_shell_mode\f1 to restore the tty modes before exiting
[see curs_kernel(3X)].
Programs which use cursor addressing should output
\f4enter_ca_mode\f1 upon startup and should output \f4exit_ca_mode\f1
before exiting.
Programs desiring shell escapes should call \f4reset_shell_mode\f1
and output \f4exit_ca_mode\f1 before the shell is called and
should output \f4enter_ca_mode\f1 and call \f4reset_prog_mode\f1
after returning from the shell.
.PP
The \f4setupterm\f1 routine reads in the \f2terminfo\f1 database,
initializing the \f2terminfo\f1 structures,
but does not set up the output virtualization structures used by \f4curses\fP.
The terminal type is the character string \f2term;\f1
if \f2term\f1 is null, the environment variable \f4TERM\f1 is used.
All output is to file descriptor \f4fildes\f1 which is initialized
for output.
If \f2errret\f1 is not null, then \f4setupterm\f1 returns \f4OK\f1
or \f4ERR\f1 and stores
a status value in the integer pointed to by \f2errret\f1.
A status of \f41\f1 in \f2errret\f1 is normal,
\f40\f1 means that the terminal could not be found,
and \f4\-1\f1 means that the \f2terminfo\fP database could not be found.
If \f2errret\f1 is null, \f4setupterm\f1
prints an error message upon finding an error and exits.
Thus, the simplest call is:
.RS
\f4setupterm((char *)0, 1, (int *)0);\f1,
.RE
which uses all the defaults and sends the output to \f4stdout\fP.
.P
The \f4setterm\fP routine is being replaced by \f4setupterm\fP.
The call:
.RS
\f4setupterm(\f2term\fP, 1, (int *)0)\f1
.RE
provides the same functionality as \f4setterm(\f2term\fP)\f1.
The \f4\%setterm\fP routine is included here for compatibility and
is supported at Level 2.
.P
The \f4set_curterm\f1 routine
sets the variable \f4cur_term\f1 to \f2nterm\f1,
and makes all of the \f2terminfo\fP boolean, numeric,
and string variables use the values from \f2nterm.\f1
.P
The \f4del_curterm\f1 routine frees the space pointed to by
\f2oterm\f1 and makes it available for further use.
If \f2oterm\f1 is the same as \f4cur_term\f1,
references to any of the \f2terminfo\fP boolean, numeric,
and string variables thereafter may refer to invalid memory locations
until another \f4setupterm\f1 has been called.
.P
The \f4restartterm\f1 routine is similar to \f4setupterm\f1 and
\f4initscr\fP,
except that it is called after restoring memory to a previous state.
It assumes that the windows and the input and output options
are the same as when memory was saved,
but the terminal type and baud rate may be different.
.P
The \f4tparm\f1 routine instantiates the string \f2str\f1
with parameters \f2pi\f1.
A pointer is returned to the result of \f2str\f1 with the parameters
applied.
.P
The \f4tputs\f1 routine applies padding information to the string
\f2str\f1 and outputs it.
The \f2str\f1 must be a terminfo string variable or the
return value from \f4tparm\f1,
\f4tgetstr\f1,
or \f4tgoto\f1.
\f2affcnt\f1
is the number of lines affected,
or 1 if not applicable.
\f2putc\f1 is a \f4putchar\f1-like
routine to which the characters are passed, one at a time.
.PP
The \f4putp\f1 routine calls \f4tputs(\f2str\fP, 1, putchar)\f1.
Note that the output of \f4putp\fP always goes to \f4stdout\fP,
not to the \f2fildes\fP specified in \f4setupterm\fP.
.P
The \f4vidputs\f1 routine displays
the string on the terminal in the video attribute mode
\f2attrs\f1, which is any combination of the attributes listed in
\f4curses\fP(3X).
The characters are passed to the \f4putchar\f1-like routine \f2putc\f1.
.P
The \f4vidattr\f1 routine is like the \f4vidputs\f1 routine,
except that it outputs through \f4putchar\f1.
.P
The \f4mvcur\f1 routine provides low-level cursor motion.
.P
The \f4tigetflag\f1,
\f4tigetnum\f1 and \f4tigetstr\f1
routines return the value of the capability corresponding to
the \f2terminfo\fP \f2capname\f1 passed to them, such as \f4xenl\f1.
.P
With the \f4tigetflag\f1 routine,
the value \f4\-1\f1 is returned if \f2capname\f1 is not a boolean capability.
.P
With the \f4tigetnum\f1 routine,
the value \f4\-2\f1 is returned if \f2capname\f1 is not a numeric capability.
.P
With the \f4tigetstr\f1 routine,
the value \f4(char *)\-1\f1 is returned if \f2capname\f1 is not
a string capability.
.P
The \f2capname\f1 for each capability is given in the
table column entitled \f2capname\f1 code in the capabilities
section of \f4terminfo\fP(4).
.P
\f4char *boolnames\f1, \f4*boolcodes\f1, \f4*boolfnames\f1
.P
\f4char *numnames\f1, \f4*numcodes\f1, \f4*numfnames\f1
.P
\f4char *strnames\f1, \f4*strcodes\f1, \f4*strfnames\f1
.P
These null-terminated arrays contain the
\f2capnames\f1,
the
\f2termcap\f1
codes, and the full C names, for each of the \f2terminfo\fP variables.
.SH RETURN VALUE
All routines return the integer \f4ERR\f1 upon
failure and an integer value other than \f4ERR\f1
upon successful completion,
unless otherwise noted in the preceding routine descriptions.
.P
Routines that return pointers always return \f4NULL\f1
on error.
.SH NOTES
.P
The header file \f4<curses.h>\f1 automatically includes the header files
\f4<stdio.h>\f1 and \f4<unctrl.h>\f1.
.PP
The \f4setupterm\fP routine should be used in place of \f4setterm\fP.
.PP
Note that \f4vidattr\fP and \f4vidputs\fP may be macros.
.SH SEE ALSO
.na
\f4curses\fP(3X),
\f4curs_initscr\fP(3X),
\f4curs_kernel\fP(3X),
\f4curs_termcap\fP(3X),
\f4putc\fP(3S),
\f4terminfo\fP(4).
.ad
