Screen colors & terminfo trivia

Stacey Campbell staceyc at sco.COM
Thu May 30 06:08:57 AEST 1991


In article <7667 at spdcc.SPDCC.COM> rbraun at spdcc.COM (Rich Braun) writes:
>I'm in the midst of porting a DOS application to SCO Unix, and have
>run into a design issue which might have been solved already.  The
>application uses 16 colors (I think; maybe only 8) for character-
>oriented displays.  It handles character colors by simply setting
>values in the high byte of each element of the display memory
>(which is a 80 x 25 x 2-byte array).

You might consider using curses level routines instead of the
lower level terminfo routines.  It sounds like your DOS app does
its own screen handling and you are hoping to plug in terminfo
calls for the output.  In the long run you will probably get
better screen optimizations using curses.  curses also knows
how to deal with terminals that don't have certain attributes
or features, using curses would mean not duplicating that (very
tedious) work in your own app.

SCO Unix offers the standard System V 3.2 color curses library.
Both curses and terminfo deal with color.  Check the setf, setb, op,
ccc, (et. al.) terminfo capabilities.  At the curses level check
start_color(), COLOR_PAIR(), init_pair(), A_COLOR, etc. routines
and macros.

The current shipping SCO console terminfo file implements
the 8 defined ANSI colors in foreground and background, this
gives you 64 defined color pairs.  If you are willing to alter
the terminfo file setf and setb caps then you can implement
16 foreground and background colors, though that will move
your terminfo file and application(s) away from the "standard"
that the curses COLOR_[whatever] macros seem to be creating
(which I personally stuck to when doing the SCO Professional 2.1
color work).

>SCO documentation doesn't even tell you that the escape sequences
>to set colors are <ESC>[=H, <ESC>[=F, etc.

Check your terminfo file to see how the standard ANSI colors
are used, my personal setf and setb entries have been changed
because I don't like the ANSI dark yellow, I change it to bright
yellow;

	setb=\E[=0G\E[%?%p1%{3}%=%t=14G%e4%p1%dm%;,
	setf=\E[=7F\E[%?%p1%{3}%=%t=14F%e3%p1%dm%;,

Simply checking the output of setcolor is a straightforward
way of determining the other non-ANSI SCO console color sequences.

>On a semi-related point, I'd like to be able to set attributes in
>the character map without having to fetch the characters out and
>put them back.  (For highlighting menu items, etc.)  The DOS code
>uses functions like "set_attr (x,y,numchars,attrbits)" to do this,
>and I don't see an equivalent in terminfo.  Yet I'm pretty sure
>the internals of terminfo should easily allow this.

The terminfo level of routines has no idea of what your screen looks
like, the calls simply output characters, parameterizing and turning
on screen attributes where required.  Terminals cannot be accessed
as memory mapped devices via terminfo or curses; that is, you cannot
directly tweak some bit in memory that the video hardware will recognize
as "standout mode" for that screen character.  Most terminals
require you to move the cursor to a position, output the sequence
to switch on the attribute, output everything, turn off the attribute.
There are many special cases in the above sequence, nearly all dealt
with by curses, but not terminfo.  As far as terminfo and curses are
concerned, the console is just another terminal attached to a /dev/tty.

>Any suggestions or sample code?

I can send some demo color curses code.  I have never written a
terminal-generalized color terminfo application, that is potentially
a very painful task.
-- 
                             Stacey Campbell       
                        Internet: staceyc at sco.com
     UUCP: {uunet,ucscc,att,sq,altos,lotus,sun,microsoft}!sco!staceyc



More information about the Comp.unix.sysv386 mailing list