DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

curs_terminfo(S)


curs_terminfo: setupterm, setterm, set_curterm, del_curterm, restartterm, tparm, tputs, putp, vidputs, vidattr, mvcur, tigetflag, tigetnum, tigetstr -- curses interfaces to terminfo database

Syntax

cc ... -ltinfo

#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);

Description

setupterm- define the terminal-dependent variables

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) routines are more suitable and their use is recommended.

setupterm

Initially, setupterm(S) should be called. initscr(S) and newterm(S) call it automatically. This defines the set of terminal-dependent variables (listed in terminfo(M) ). The terminfo variables lines and columns are initialized by setupterm( ) as follows:

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) to instantiate them. All terminfo strings (including the output of tparm( )) should be printed with tputs(S) or putp(S). Call the reset_shell_mode(S) to restore the tty modes before exiting (see curs_kernel(S)).

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) 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.

setterm

The setterm(S) routine is being replaced by setupterm( ). The call

setupterm(term, 1, (int *)0)

acts the same as setterm(term). setterm( ) is included here for compatibility and is supported at Level 2.

set_curterm

The set_curterm(S) routine sets the variable cur_term to nterm, and makes all of the terminfo boolean, numeric, and string variables use the values from nterm.

del_curterm

The del_curterm(S) routine frees the space pointed to by oterm and makes it available for further use. If oterm is the same as cur_term, references to any of the terminfo boolean, numeric, or string variables thereafter may refer to invalid memory locations until setupterm( ) is called again.

restartterm

The restartterm(S) routine is like setupterm( ) and initscr( ), except that it is called after memory is restored 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.

tparm

The tparm( ) routine formats the string str using the remaining parameters. A pointer is returned to the result of str with the parameters applied.

tputs and putp

The tputs( ) routine applies padding information (divide-specific formatting) to the string str and outputs it. The str must be a terminfo string variable or the return value from tparm( ), tgetstr(S), or tgoto(S).

affcnt is the number of lines affected, or 1 if not applicable.

putc(S) is a routine like putchar(S) 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( ).

vidputs and vidattr

The routine vidputs(S) displays the string on the terminal in the video attribute mode attrs, which is any combination of the attributes listed in curses(S) The characters are passed to the routine putc( ), which is like putchar( ).

The routine vidattr(S) is like vidputs( ), except that it outputs through putchar( ).

mvcur

The routine mvcur(S) provides low-level cursor motion.

tigetflag, tigetnum, and tigetstr

The routines tigetflag(S), tigetnum(S) and tigetstr(S) return the value of the capability corresponding to the terminfo capname passed to them, such as xenl.

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) codes, and the full C names for each of the terminfo variables.

Return values

All routines return the integer ERR on failure and an integer value other than ERR on successful completion, unless otherwise noted in the preceding routine descriptions.

Routines that return pointers always return NULL on error.

Warning

The header file curses.h automatically includes the header files stdio.h and unctrl.h.

The setupterm( ) routine should be used in place of setterm( ).

The following can be macros: vidattr( ) and vidputs( ).

Files


/usr/lib/libtinfo.a
the library

See also

curses(S), curs_initscr(S), curs_kernel(S), curs_termcap(S), putc(S), terminfo(F) terminfo(M)

Standards conformance

setupterm(S), setterm(S), set_curterm(S), del_curterm(S), restartterm(S), tparm(S), tputs(S), putp(S), vidputs(S), vidattr(S), mvcur(S), tigetflag(S), tigetnum(S), and tigetstr(S) are not part of any currently supported standard; they were developed by UNIX System Laboratories, Inc. and are maintained by The SCO Group.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003