Curses: Drawing Boxes -- sending control chars

Dominic Dunlop domo at riddle.UUCP
Mon Sep 5 19:59:02 AEST 1988


In article <873 at wpg.UUCP> russ at wpg.UUCP (Russell Lawrence) writes:
>
>The curses box() function draws crude boxes around windows using ascii 
>characters like '|' and '-' that are passed to the function as 
>arguments.  By contrast, I'd like to write a better box drawing routine 
>that would take advantage of box drawing graphics capabilities on some 
>terminals.  Unfortunately, the terminfo definitions don't include any 
>parameters that would be appropriate, and the tic(1M) program won't 
>allow me to define new ones.

Er... Oh, yes it does.  Oh, yes it will.  If you look in the _UNIX System V
Programmer's Guide_ (AT&T select code 307-225, or available at bookstores
in the Prentice-Hall edition), chapter 10, _Curses/terminfo_, you will find
a section called ``Using Advanced curses Features'' which describes the use
of ACS_* characters from an alternate character set to draw boxes.  There's
even an example program, which uses the box() function to do the job: box()
will use the ACS characters in preference to `+' and `-', provided that the
necessary characters are defined.  The definition is a little baroque:
Moving to _UNIX System V Programmer's Reference Manual_ (select code
307-226, or from Prentice Hall), section TERMINFO(4), you (eventually) find
a section called ``Line Graphics''.  This discusses the ``acsc'' (alternate
character set characters) capability, a single string containing your
terminal's half of a mapping between the VT100's alternate character set
and your terminal's alternate character set.  So, if you feed tic a
terminal description containing an acsc=... capability, you should get
prettier boxes when you use the curses box() function.  Admittedly, this is
all theory: I've never had to do it myself in anger -- although I've spent
plenty of time persuading applications authors that they should be doing
it, rather than...

>I figured I could get around the problem 
>by concocting a small database containing the command strings for the 
>various terminals we use in our office...

Please, please, don't do this.  Maintaining non-standard extensions to
curses, termcap and terminfo has been one of the banes of my life.  Every
(supply your own adjective) application does it differently.  No more
unnecessary diversity, please.  (Even if I don't get to maintain it.)
-- 
Dominic Dunlop
domo at sphinx.co.uk  domo at riddle.uucp



More information about the Comp.unix.questions mailing list