|
|
#include <curses.h> #include <term.h>int setupterm(char *term, int fildes, int *errret); int setterm(char *term); TERMINAL *set_curterm(TERMINAL *nterm); int del_curterm(TERMINAL *oterm); int restartterm(char *term, int fildes, int *errret); char *tparm(char *str, ...); int tputs(char *str, int affcnt, int (*putc)(int)); int putp(char *str); int vidputs(chtype attrs, int (*putc)(int)); int vidattr(chtype attrs); int mvcur(int oldrow, int oldcol, int newrow, int newcol); int tigetflag(char *capname); int tigetnum(char *capname); int tigetstr(char *capname);
setterm- define the terminal-dependent variables (older command)
set_curterm- set the variable cur_term
del_curterm- free the space pointed to by oterm
restartterm- reset the terminal-dependent variables to saved values
tparm- fill in the terminfo capability str with parameters file
tputs- pad and output the specified string using putc
putp- output the specified string to stdout using putchar
vidputs- display the specified characters with video attributes via putc
vidattr- display the specified characters with video attributes via putchar
mvcur- move the cursor
tigetflag- check whether capname is boolean
tigetnum-
check whether capname is numeric
tigetstr- check whether capname is string
These low-level routines must be called by programs that have to deal directly with the terminfo database to handle certain terminal capabilities, such as programming function keys. For all other functionality, curses(S-osr5) routines are more suitable and their use is recommended.
The header files curses.h and term.h should be included (in this order) to get the definitions for these strings, numbers, and flags.
Parameterized strings should be passed through tparm(S-osr5) to instantiate them. All terminfo strings (including the output of tparm( )) should be printed with tputs(S-osr5) or putp(S-osr5). Call the reset_shell_mode(S-osr5) to restore the tty modes before exiting (see curs_kernel(S-osr5)).
Programs that use cursor addressing should output enter_ca_mode on startup and output exit_ca_mode before exiting.
Programs needing shell escapes should call reset_shell_mode( ) and output exit_ca_mode before the shell is called; and should output enter_ca_mode and call reset_prog_mode(S-osr5) after returning from the shell.
The
setupterm( )
routine reads in the
terminfo
database, initializing the
terminfo
structures,
but does not set up the output virtualization structures used by
curses.
The terminal type is the character string term;
if term is null, the environment variable TERM is used.
All output is to file descriptor
fildes
which is initialized for output.
If
errret
is not null, then
setupterm( )
returns OK
or ERR and stores
a status value in the integer pointed to by
errret.
A status of 1 in
errret
is normal,
0 means that the terminal could not be found,
and -1 means that the
terminfo
database could not be found.
If
errret
is null,
setupterm( )
prints an error message on finding an error and exits.
Thus, the simplest call is
setupterm((char *)0, 1, (int *)0);
which uses all the defaults and sends the output to
stdout.
acts the same as setterm(term). setterm( ) is included here for compatibility and is supported at Level 2.
affcnt is the number of lines affected, or 1 if not applicable.
putc(S-osr5) is a routine like putchar(S-osr5) to which the characters are passed, one at a time.
The putp( ) routine calls tputs(str, 1, putchar). The output of putp( ) always goes to stdout, not to the fildes specified in setupterm( ).
The routine vidattr(S-osr5) is like vidputs( ), except that it outputs through putchar( ).
The routine tigetflag( ) returns -1 unless capname is a boolean capability.
The routine tigetnum( ) returns -2 unless capname is a numeric capability.
The routine tigetstr( ) returns the value (char *) -1 unless capname is a string capability.
The capname for each capability is listed in the
table column ``Capname'' in the ``Terminal Capabilities'' section of
the man page for
terminfo(M):
char boolnames, boolcodes, boolfnames
char numnames, numcodes, numfnames
char strnames, strcodes, strfnames
These null-terminated arrays contain the capnames, the termcap(S-osr5) codes, and the full C names for each of the terminfo variables.
Routines that return pointers always return NULL on error.
The setupterm( ) routine should be used in place of setterm( ).
The following can be macros: vidattr( ) and vidputs( ).