Curses: Drawing Boxes -- sending control chars

Michael Greim greim at sbsvax.UUCP
Tue Aug 30 20:31:16 AEST 1988


In article <338 at sobeco.UUCP>, mfp at sobeco.UUCP (Mark F. Proudman) writes:
> 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 
> 
> I have just written a menu handler, to run on vt[123]xx terminals.
> The attribute bits of each curses displayed character include one
> #defined as A_PROTECT.  Normally useless; I changed the terminfo sgr
> string so that A_PROTECT (p8 I think) invokes a change to graphics 
> character set sequence.  When I want a graphic, I just addch the ascii
> equivalent, with A_PROTECT on.
> 
> Of course, your box routine  will have to know which character
> position each graphic is in.  Possibly download a DEC compatible graphic
> character set, if your terminals don't have one.  Or implement your
> idea of a database of graphic characters:  Having stolen an attribute
> bit, you won't need escape sequences in the database.  Or simply put a
> lot of if's in your code (gross, non portable but effective).
> 
I have written an extension to 4.3BSD curses, which I called CURRY.
Curry uses termcap, I had no terminfo sources then. You can specify
4 attributes (reverse, blink, underline, half intens) and use characters
from 4 character sets.
I added some capabilities to termcap:
	r0-r9, ra-rf : strings to turn on attributes reverse, blink, underline
			and halfintensity and the combinations thereof.
	s0-s3 : si means switch to character set i
	SG : string of pairs (number, character); number is the character set
		number (0 - 3), character is any ASCII character.
		The positions in this string have meaning, the first entry is
		horizontal bar, the second vertical bar, the third the upper
		left corner, ...
With these I could rewrite box so that it uses the characters with
their character set attribute in SG.

I have written some demo programs which use these line drawing (semi
graphic) characters. I changed some of these to use terminfo, just
to see, how the performance might change. For this I had a problem
similar to yours.

With terminfo I would suggest, if you cannot or don't want to change
terminfo that you specified an environment variable containing
- vertical bar char
- horizontal bar char
- top left corner
...
Write a new terminfo entry using as smacs (start alternate character set) and
rmacs (end alternate character set) the sequences for "turn on semi
graphics mode" and "turn off semi graphics mode".
Then write your own routine to box a portion of the screen using the
characters from the environment variable with the A_ALTCHARSET attribute.

If you find this a kludge or too ugly, you will have to change
terminfo. But let me know, because in the near future I will do a
rewrite of Pavel Curtis pcurses and terminfo package,
while including good features from my Curry.

	-mg
-- 
UUCP:  ...!uunet!unido!sbsvax!greim   | Michael T. Greim
       or greim at sbsvax.UUCP           | Universitaet des Saarlandes
CSNET: greim%sbsvax.uucp at Germany.CSnet| FB 10 - Informatik (Dept. of CS)
ARPA:  greim%sbsvax.uucp at uunet.UU.NET | Bau 36, Im Stadtwald 15
voice: +49 681 302 2434               | D-6600 Saarbruecken 11, West Germany

# include <disclaimers/std.h>



More information about the Comp.unix.questions mailing list