Modula-2 || Compiler & Tools || Library || Search Engine


Ulm's Modula-2 Library:
TermCap


NAME

TermCap - interface to terminal capability data base

SYNOPSIS

TYPE OutProc = PROCEDURE (CHAR);
TYPE DelayProc = PROCEDURE (CARDINAL);
TYPE Term = RECORD (* ... *) END;


PROCEDURE SetupTerm(tname: ARRAY OF CHAR; VAR tinfo: Term) : BOOLEAN; PROCEDURE Tparm(VAR out: ARRAY OF CHAR; fmt: ARRAY OF CHAR); PROCEDURE Tparm1(VAR out: ARRAY OF CHAR; fmt: ARRAY OF CHAR; arg1: ARRAY OF BYTE); PROCEDURE Tputs(str: ARRAY OF CHAR; affcnt: CARDINAL; outc: OutProc); PROCEDURE TputsDelay(str: ARRAY OF CHAR; affcnt: CARDINAL; outc: OutProc; delay: DelayProc);

DESCRIPTION

TermCap allows to access the termcap database as described in termcap(5). The routines are similar to the termcap level routines of curses(3V) but no output is generated nor any ioctl-calls are done. This allows TermCap to work for more than one terminal at a time.

SetupTerm looks for a terminal description for tname (an empty string causes the environment parameter TERM to be taken). On success tinfo is filled and TRUE is returned. Failures result from unknown terminals or corrupted termcap database entries.

The type Term is generated from /usr/etc/termcap and win/misc/term. The components for which exist a long name in win/misc/term, start with an upper case letter. Underlines followed by lower case letters are replaced by upper case (e.g. cursor_address becomes CursorAddress). The others start with 'T' followed by the two character code of the capability (see termcap(5)). Capabilities are of three different types: String (fixed length character array), INTEGER, and BOOLEAN. Capabilities in Term which are not defined in the database are set accordingly to empty strings, -1, and FALSE.

Tparm, are used to decode the capability fmt and to instantiate the parameters into out. Delay information still remains in out. These routines abort with a message on StdIO.stderr on errors in fmt or on too few parameters.

Tputs prints str using outc and interpretes the delay information which sometimes depends on the number of lines affected affcnt (give 1 if not applicable). Because the baud-rate is not known no padding will be done. Instead, a busy-loop with system calls (resolution see Clock.UnitsPerSecond) does the work.

TputsDelay works like Tputs but calls delay if delay informations are found. The delay time is given in tenth of milliseconds.

CAVEAT

This module is provided on older BSD-systems only.

SEE ALSO

curses(3V), terminfo(5)

AUTHOR

Harald Ruess
Edited by: borchert, last change: 1997/02/25, revision: 1.2, converted to HTML: 1997/04/28

Modula-2 || Compiler & Tools || Library || Search Engine