Article View: comp.lang.prolog
Article #3400Re: screen control
From: Richard A. O'Keefe
Date: Sun, 29 May 1988 04:25
Date: Sun, 29 May 1988 04:25
37 lines
2421 bytes
2421 bytes
In article <701@mtfmi.UUCP>, dbrod@mtfmi.UUCP (D.BRODERICK) writes:
> If your version of Prolog does not have screen control predicates,
> but you are familiar with the Unix(tm) tput(1) command
It's worth pointing out that
(a) tput is a System V feature, not present in most BSDs (but SunOS has it).
(b) There are some non-trivial differences between V.2 tput and V.3 tput
(as I found the hard way when some scripts I wrote on a V.3 system
didn't work on a V.2 system.)
(c) Some of the things tput returns are numbers, for example
tput lines
prints the number of lines on the screen. Suppose that is 24.
The "get_tput" script provided by D.BRODERICK will write this as '24',
which is an atom. You may want to have another script which writes
things unquoted so that you can access such terminal properties.
(d) Some of the things tput reports are "boolean", for example
tput hc # is it a hard-copy terminal?
always prints nothing. Instead the answer is to be found in the exit
code (0 means yes, non-zero means no). You may want a third script
if tput -T$1 $2 ; then
echo "tput($2, '$1', true)."
else
echo "tput($2, '$1', false)."
fi
for use with boolean capabilities.
(e) tput writes things out verbatim, without escape characters. Some
Prolog systems may discard CRs or do other odd things with strange
characters. (Quintus Prolog is safe, but watch out for terminal
capabilities containing apostrophes.)
If the Prolog dialect you are using has an interface to C (as many have)
you would be better off writing an interface to 'curses'; since 'curses'
is available for IBM PCs and VAX/VMS as well as for UNIX this may be more
portable than using tput. In particular, if you use curses, you don't
have to figure out how to parse the 'cup' capability (rather hairy).
Then too, I for one would rather hide the rather bizarre capability
names (quickly now: what does eslok do?) from my Prolog code.
Technical Details
Message-ID:
<1034@cresswell.quintus.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!amdcad!sun!quintus!okReferences:
<701@mtfmi.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!amdcad!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: screen control Keywords: screen control tput character based Message-ID: <1034@cresswell.quintus.UUCP> Date: 29 May 88 04:25:44 GMT References: <701@mtfmi.UUCP> Organization: Quintus Computer Systems, Mountain View, CA Lines: 37