curses and color
Ronald Joe Record
rr at sco.COM
Thu Jan 31 08:25:45 AEST 1991
staceyc at sco.COM (Stacey Campbell) writes:
|In article <1991Jan17.064429.13943 at vpnet.chi.il.us> jimr at vpnet.chi.il.us (Jim Rendant) writes:
|>Are ther any tips for using curses and color windows, pads etc...
|You will also note that after running a terminfo curses color application
|on a SCO Unix console that the default screen attributes will be set
|to the terminfo "op" entry. This may not correspond to what you have
|setup with the setcolor command. Here is a little bit of code that will
|restore the setcolor fg and bg colors after a color curses application
|has been run;
| <deleted Stacey's code>
==========================================================================
Here's something similar to what staceyc posted which in addition saves
and restores the "graphics" and "inverse" mode color attributes. I usually
call save_colors() just prior to initscr() and rest_colors() after endwin()
and just prior to exiting the application. The routine has_colors() is
a curses routine so this is only meant to be linked into a curses app.
#include <curses.h>
#include <sys/console.h>
static int cur_tty[3] = { -1, -1, -1 };
save_colors() {
if (has_colors() == TRUE) {
cur_tty[0] = ioctl( 0, GIO_ATTR, 0);
printf( "\033[7m" );
fflush( stdout );
cur_tty[1] = ioctl( 0, GIO_ATTR, 0);
printf( "\033[12m" );
fflush( stdout );
cur_tty[2] = ioctl( 0, GIO_ATTR, 0);
printf( "\033[10;0m" );
}
}
rest_colors() {
if (has_colors() == TRUE) {
if (cur_tty[0] != -1)
{
printf( "\033[=%dF\033[=%dG",
(cur_tty[0])&0x0f, ((cur_tty[0])&0xf0)>>4);
}
if (cur_tty[1] != -1)
{
printf( "\033[=%dH\033[=%dI",
(cur_tty[1])&0x0f, ((cur_tty[1])&0xf0)>>4);
}
if (cur_tty[2] != -1)
{
printf( "\033[=%dJ\033[=%dK",
(cur_tty[2])&0x0f, ((cur_tty[2])&0xf0)>>4);
}
}
}
--
"A boy without mischief is like a bowling ball without a liquid center."
--Homer Simpson
More information about the Comp.unix.sysv386
mailing list