Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -275,6 +275,8 @@ int try_curses_init(int mode) ...@@ -275,6 +275,8 @@ int try_curses_init(int mode)
cio_api.suspend=curs_suspend; cio_api.suspend=curs_suspend;
cio_api.resume=curs_resume; cio_api.resume=curs_resume;
cio_api.beep=curs_beep; cio_api.beep=curs_beep;
cio_api.setvideoflags=curs_setvideoflags;
cio_api.getvideoflags=curs_getvideoflags;
#if defined(NCURSES_VERSION_MAJOR) || defined (__NetBSD__) #if defined(NCURSES_VERSION_MAJOR) || defined (__NetBSD__)
cio_api.ESCDELAY=&ESCDELAY; cio_api.ESCDELAY=&ESCDELAY;
#endif #endif
......
...@@ -54,6 +54,7 @@ static unsigned char curs_nextgetch=0; ...@@ -54,6 +54,7 @@ static unsigned char curs_nextgetch=0;
static int lastattr=0; static int lastattr=0;
static long mode; static long mode;
static int vflags=0;
static short curses_color(short color) static short curses_color(short color)
{ {
...@@ -76,21 +77,21 @@ static short curses_color(short color) ...@@ -76,21 +77,21 @@ static short curses_color(short color)
case 7 : case 7 :
return(COLOR_WHITE); return(COLOR_WHITE);
case 8 : case 8 :
return(COLOR_BLACK); return(COLOR_BLACK+8);
case 9 : case 9 :
return(COLOR_BLUE); return(COLOR_BLUE+8);
case 10 : case 10 :
return(COLOR_GREEN); return(COLOR_GREEN+8);
case 11 : case 11 :
return(COLOR_CYAN); return(COLOR_CYAN+8);
case 12 : case 12 :
return(COLOR_RED); return(COLOR_RED+8);
case 13 : case 13 :
return(COLOR_MAGENTA); return(COLOR_MAGENTA+8);
case 14 : case 14 :
return(COLOR_YELLOW); return(COLOR_YELLOW+8);
case 15 : case 15 :
return(COLOR_WHITE); return(COLOR_WHITE+8);
} }
return(0); return(0);
} }
...@@ -586,20 +587,37 @@ void curs_textattr(int attr) ...@@ -586,20 +587,37 @@ void curs_textattr(int attr)
{ {
chtype attrs=A_NORMAL; chtype attrs=A_NORMAL;
int colour; int colour;
int fg,bg;
if (lastattr==attr) if (lastattr==attr)
return; return;
lastattr=attr; lastattr=attr;
if (attr & 8) { fg = attr & 0x0f;
attrs |= A_BOLD; bg = attr & 0xf0;
}
if (vflags & CIOLIB_VIDEO_NOBRIGHT)
fg &= 0x07;
if (!(vflags & CIOLIB_VIDEO_BGBRIGHT))
bg &= 0x70;
if (attr & 128) if (attr & 128)
{ {
if (!(vflags & CIOLIB_VIDEO_NOBLINK))
attrs |= A_BLINK; attrs |= A_BLINK;
} }
colour = COLOR_PAIR( ((attr&7)|((attr>>1)&56))+1 );
if (COLORS >= 16) {
colour = COLOR_PAIR( ((fg|bg)+1) );
}
else {
if (fg & 8) {
attrs |= A_BOLD;
}
colour = COLOR_PAIR( ((fg&7)|(bg&0x70))+1 );
}
#ifdef NCURSES_VERSION_MAJOR #ifdef NCURSES_VERSION_MAJOR
attrset(attrs); attrset(attrs);
color_set(colour,NULL); color_set(colour,NULL);
...@@ -692,11 +710,20 @@ int curs_initciolib(long inmode) ...@@ -692,11 +710,20 @@ int curs_initciolib(long inmode)
atexit(curs_suspend); atexit(curs_suspend);
/* Set up color pairs */ /* Set up color pairs */
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(bg=0;bg<8;bg++) {
for(fg=0;fg<8;fg++) { for(fg=0;fg<8;fg++) {
init_pair(++pair,curses_color(fg),curses_color(bg)); init_pair(++pair,curses_color(fg),curses_color(bg));
} }
} }
}
mode = inmode; mode = inmode;
#ifdef NCURSES_VERSION_MAJOR #ifdef NCURSES_VERSION_MAJOR
if(mousemask(BUTTON1_PRESSED|BUTTON1_RELEASED|BUTTON2_PRESSED|BUTTON2_RELEASED|BUTTON3_PRESSED|BUTTON3_RELEASED|REPORT_MOUSE_POSITION,NULL)==(BUTTON1_PRESSED|BUTTON1_RELEASED|BUTTON2_PRESSED|BUTTON2_RELEASED|BUTTON3_PRESSED|BUTTON3_RELEASED|REPORT_MOUSE_POSITION)) { if(mousemask(BUTTON1_PRESSED|BUTTON1_RELEASED|BUTTON2_PRESSED|BUTTON2_RELEASED|BUTTON3_PRESSED|BUTTON3_RELEASED|REPORT_MOUSE_POSITION,NULL)==(BUTTON1_PRESSED|BUTTON1_RELEASED|BUTTON2_PRESSED|BUTTON2_RELEASED|BUTTON3_PRESSED|BUTTON3_RELEASED|REPORT_MOUSE_POSITION)) {
...@@ -707,6 +734,8 @@ int curs_initciolib(long inmode) ...@@ -707,6 +734,8 @@ int curs_initciolib(long inmode)
mousemask(0,NULL); mousemask(0,NULL);
#endif #endif
if (COLORS >= 16)
cio_api.options = CONIO_OPT_BRIGHT_BACKGROUND;
curs_textmode(0); curs_textmode(0);
return(1); return(1);
} }
...@@ -1005,3 +1034,15 @@ int curs_beep(void) ...@@ -1005,3 +1034,15 @@ int curs_beep(void)
{ {
return(beep()); 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); ...@@ -64,6 +64,8 @@ void curs_textmode(int mode);
int curs_hidemouse(void); int curs_hidemouse(void);
int curs_showmouse(void); int curs_showmouse(void);
int curs_beep(void); int curs_beep(void);
int curs_getvideoflags(void);
void curs_setvideoflags(int flags);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment