termcap str + params -> control seq. How?

Risto Kankkunen kankkune at cs.Helsinki.FI
Thu Apr 4 22:41:10 AEST 1991


Thanks for your answers. I asked:

> What is the standard way to apply parameters to the termcap strings you
> have read with tgetent?

Peter da Silva suggested using tgoto. I was a bit hesitated to use that
as the (SunOS) manual page implies it might contain much special case
handling for cursor addressing:

     char *
     tgoto(cm, destcol, destline)
     char *cm;

     tgoto() returns a cursor addressing string decoded  from  cm
     to  go  to  column  destcol  in  line destline.  It uses the
     external variables UP (from the up capability) and BC (if bc
     is  given  rather than bs) if necessary to avoid placing \n,
     ^D or ^@ in  the  returned  string.

tgoto also takes only two parameters, but in my case that would be
sufficient. Buster Irby pointed out that in the curses(3x) manual page
there is the function tparm(str, p1, p2, p3, ...), which seems to be
just what I wanted. I had glanced also the curses documentation, but I
had missed this.

However, like Peter da Silva notes, this is a system V routine, and for
portability my best bet is to use tgoto (and hope the cursor addressing
special code doesn't mess things up). I just wonder, why there wasn't a
tparm-like function in every termcap library from the beginning (the
code must essentially be there in tgoto...).

 Risto Kankkunen                   kankkune at cs.Helsinki.FI (Internet)
 Department of Computer Science    kankkunen at finuh          (Bitnet)
 University of Helsinki, Finland   ..!mcsun!uhecs!kankkune   (UUCP)



More information about the Comp.unix.programmer mailing list