Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!unido!sbsvax!greim From: greim@sbsvax.UUCP (Michael Greim) Newsgroups: comp.unix.questions Subject: Re: Curses: Drawing Boxes -- sending control chars Summary: How I did it. Message-ID: <618@sbsvax.UUCP> Date: 30 Aug 88 10:31:16 GMT References: <873@wpg.UUCP> <338@sobeco.UUCP> Organization: Universitaet des Saarlandes, Saarbruecken, West Germany Lines: 70 In article <338@sobeco.UUCP>, mfp@sobeco.UUCP (Mark F. Proudman) writes: > In article <873@wpg.UUCP>, russ@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@sbsvax.UUCP | Universitaet des Saarlandes CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 voice: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany # include