Commit 3e2c3e7b authored by deuce's avatar deuce
Browse files

Add special handling for 256-color mode... since we're not sure what BOLD

on explicit colors will do, use all 16 colors.

Also, if we have 16 or more colors, set CONIO_OPT_BRIGHT_BACKGROUND

This fixes bugs running syncterm -iC in syncterm.
parent 7e4220fe
......@@ -275,6 +275,8 @@ int try_curses_init(int mode)
cio_api.suspend=curs_suspend;
cio_api.resume=curs_resume;
cio_api.beep=curs_beep;
cio_api.setvideoflags=curs_setvideoflags;
cio_api.getvideoflags=curs_getvideoflags;
#if defined(NCURSES_VERSION_MAJOR) || defined (__NetBSD__)
cio_api.ESCDELAY=&ESCDELAY;
#endif
......
......@@ -54,6 +54,7 @@ static unsigned char curs_nextgetch=0;
static int lastattr=0;
static long mode;
static int vflags=0;
static short curses_color(short color)
{
......@@ -76,21 +77,21 @@ static short curses_color(short color)
case 7 :
return(COLOR_WHITE);
case 8 :
return(COLOR_BLACK);
return(COLOR_BLACK+8);
case 9 :
return(COLOR_BLUE);
return(COLOR_BLUE+8);
case 10 :
return(COLOR_GREEN);
return(COLOR_GREEN+8);
case 11 :
return(COLOR_CYAN);
return(COLOR_CYAN+8);
case 12 :
return(COLOR_RED);
return(COLOR_RED+8);
case 13 :
return(COLOR_MAGENTA);
return(COLOR_MAGENTA+8);
case 14 :
return(COLOR_YELLOW);
return(COLOR_YELLOW+8);
case 15 :
return(COLOR_WHITE);
return(COLOR_WHITE+8);
}
return(0);
}
......@@ -586,20 +587,37 @@ void curs_textattr(int attr)
{
chtype attrs=A_NORMAL;
int colour;
int fg,bg;
if (lastattr==attr)
return;
lastattr=attr;
if (attr & 8) {
attrs |= A_BOLD;
}
fg = attr & 0x0f;
bg = attr & 0xf0;
if (vflags & CIOLIB_VIDEO_NOBRIGHT)
fg &= 0x07;
if (!(vflags & CIOLIB_VIDEO_BGBRIGHT))
bg &= 0x70;
if (attr & 128)
{
attrs |= A_BLINK;
if (!(vflags & CIOLIB_VIDEO_NOBLINK))
attrs |= A_BLINK;
}
if (COLORS >= 16) {
colour = COLOR_PAIR( ((fg|bg)+1) );
}
else {
if (fg & 8) {
attrs |= A_BOLD;
}
colour = COLOR_PAIR( ((fg&7)|(bg&0x70))+1 );
}
colour = COLOR_PAIR( ((attr&7)|((attr>>1)&56))+1 );
#ifdef NCURSES_VERSION_MAJOR
attrset(attrs);
color_set(colour,NULL);
......@@ -692,9 +710,18 @@ int curs_initciolib(long inmode)
atexit(curs_suspend);
/* Set up color pairs */
for(bg=0;bg<8;bg++) {
for(fg=0;fg<8;fg++) {
init_pair(++pair,curses_color(fg),curses_color(bg));
if (COLORS >= 16) {
for(bg=0;bg<16;bg++) {
for(fg=0;fg<16;fg++) {
init_pair(++pair,curses_color(fg),curses_color(bg));
}
}
}
else {
for(bg=0;bg<8;bg++) {
for(fg=0;fg<8;fg++) {
init_pair(++pair,curses_color(fg),curses_color(bg));
}
}
}
mode = inmode;
......@@ -707,6 +734,8 @@ int curs_initciolib(long inmode)
mousemask(0,NULL);
#endif
if (COLORS >= 16)
cio_api.options = CONIO_OPT_BRIGHT_BACKGROUND;
curs_textmode(0);
return(1);
}
......@@ -1005,3 +1034,15 @@ int curs_beep(void)
{
return(beep());
}
int curs_getvideoflags(void)
{
return vflags;
}
void curs_setvideoflags(int flags)
{
flags &= (CIOLIB_VIDEO_NOBRIGHT|CIOLIB_VIDEO_BGBRIGHT|CIOLIB_VIDEO_NOBLINK);
if (COLORS < 16)
flags &= ~CIOLIB_VIDEO_BGBRIGHT;
}
......@@ -64,6 +64,8 @@ void curs_textmode(int mode);
int curs_hidemouse(void);
int curs_showmouse(void);
int curs_beep(void);
int curs_getvideoflags(void);
void curs_setvideoflags(int flags);
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment