1988-11-23 10:59:09 +00:00
|
|
|
(*
|
|
|
|
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*)
|
|
|
|
|
|
|
|
(*
|
|
|
|
Module: Interface to termcap database
|
|
|
|
From: Unix manual chapter 3
|
1994-06-24 14:02:31 +00:00
|
|
|
Version: $Id$
|
1988-11-23 10:59:09 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
(*$R-*)
|
|
|
|
IMPLEMENTATION MODULE Termcap;
|
|
|
|
|
|
|
|
IMPORT XXTermcap;
|
1991-03-05 13:47:08 +00:00
|
|
|
FROM SYSTEM IMPORT ADR, ADDRESS;
|
|
|
|
FROM Unix IMPORT gtty;
|
|
|
|
FROM Arguments IMPORT
|
|
|
|
GetEnv;
|
1988-11-23 10:59:09 +00:00
|
|
|
|
1988-11-24 11:46:31 +00:00
|
|
|
TYPE STR = ARRAY[1..32] OF CHAR;
|
|
|
|
STRCAP = POINTER TO STR;
|
|
|
|
|
1988-11-23 10:59:09 +00:00
|
|
|
VAR Buf, Buf1 : ARRAY [1..1024] OF CHAR;
|
|
|
|
BufCnt : INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE Tgetent(name: ARRAY OF CHAR) : INTEGER;
|
|
|
|
VAR i: INTEGER;
|
1988-11-25 13:49:07 +00:00
|
|
|
x: STRCAP;
|
|
|
|
sp: STR;
|
1988-11-23 10:59:09 +00:00
|
|
|
BEGIN
|
|
|
|
i := XXTermcap.tgetent(ADR(Buf), ADR(name));
|
1988-11-24 11:46:31 +00:00
|
|
|
BufCnt := 1;
|
1988-11-25 13:49:07 +00:00
|
|
|
IF gtty(1, ADR(sp)) < 0 THEN
|
|
|
|
ELSE
|
|
|
|
XXTermcap.ospeed := ORD(sp[2]);
|
|
|
|
END;
|
1988-11-23 10:59:09 +00:00
|
|
|
IF i > 0 THEN
|
1988-11-25 13:49:07 +00:00
|
|
|
IF Tgetstr("pc", x) THEN
|
|
|
|
XXTermcap.PC := x^[1];
|
|
|
|
ELSE XXTermcap.PC := 0C;
|
1988-11-24 11:46:31 +00:00
|
|
|
END;
|
1988-11-25 13:49:07 +00:00
|
|
|
IF Tgetstr("up", x) THEN ; END; XXTermcap.UP := x;
|
|
|
|
IF Tgetstr("bc", x) THEN ; END; XXTermcap.BC := x;
|
1988-11-23 10:59:09 +00:00
|
|
|
END;
|
|
|
|
RETURN i;
|
|
|
|
END Tgetent;
|
|
|
|
|
|
|
|
PROCEDURE Tgetnum(id: ARRAY OF CHAR): INTEGER;
|
|
|
|
BEGIN
|
|
|
|
RETURN XXTermcap.tgetnum(ADR(id));
|
|
|
|
END Tgetnum;
|
|
|
|
|
|
|
|
PROCEDURE Tgetflag(id: ARRAY OF CHAR): BOOLEAN;
|
|
|
|
BEGIN
|
|
|
|
RETURN XXTermcap.tgetflag(ADR(id)) = 1;
|
|
|
|
END Tgetflag;
|
|
|
|
|
1988-11-24 11:46:31 +00:00
|
|
|
PROCEDURE Tgoto(cm: STRCAP; col, line: INTEGER): STRCAP;
|
1988-11-23 10:59:09 +00:00
|
|
|
BEGIN
|
|
|
|
RETURN XXTermcap.tgoto(cm, col, line);
|
|
|
|
END Tgoto;
|
|
|
|
|
1988-11-25 13:49:07 +00:00
|
|
|
PROCEDURE Tgetstr(id: ARRAY OF CHAR; VAR res: STRCAP) : BOOLEAN;
|
1988-11-23 10:59:09 +00:00
|
|
|
VAR a, a2: ADDRESS;
|
|
|
|
b: CARDINAL;
|
|
|
|
BEGIN
|
|
|
|
a := ADR(Buf1[BufCnt]);
|
|
|
|
a2 := XXTermcap.tgetstr(ADR(id), ADR(a));
|
1988-11-25 13:49:07 +00:00
|
|
|
res := a2;
|
1988-11-23 10:59:09 +00:00
|
|
|
IF a2 = NIL THEN
|
1988-11-25 13:49:07 +00:00
|
|
|
RETURN FALSE;
|
1988-11-23 10:59:09 +00:00
|
|
|
END;
|
|
|
|
b := a - a2;
|
|
|
|
INC(BufCnt, b);
|
1988-11-25 13:49:07 +00:00
|
|
|
RETURN TRUE;
|
1988-11-23 10:59:09 +00:00
|
|
|
END Tgetstr;
|
|
|
|
|
1988-11-24 11:46:31 +00:00
|
|
|
PROCEDURE Tputs(cp: STRCAP; affcnt: INTEGER; p: PUTPROC);
|
1988-11-23 10:59:09 +00:00
|
|
|
BEGIN
|
|
|
|
XXTermcap.tputs(cp, affcnt, XXTermcap.PUTPROC(p));
|
|
|
|
END Tputs;
|
|
|
|
|
1988-11-25 13:49:07 +00:00
|
|
|
PROCEDURE InitTermcap;
|
|
|
|
VAR Bf: STR;
|
|
|
|
BEGIN
|
|
|
|
IF GetEnv("TERM", Bf) = 0 THEN
|
|
|
|
Bf := "dumb";
|
|
|
|
END;
|
|
|
|
IF Tgetent(Bf) <= 0 THEN
|
|
|
|
END;
|
|
|
|
END InitTermcap;
|
|
|
|
|
1988-11-23 10:59:09 +00:00
|
|
|
BEGIN
|
1988-11-25 13:49:07 +00:00
|
|
|
InitTermcap;
|
1988-11-23 10:59:09 +00:00
|
|
|
END Termcap.
|