diff --git a/src/conio/ciolib.c b/src/conio/ciolib.c index ee75cea3498b73dcfe83da8b8c745c65f4d91a6f..53b26eac61d5e3cb00535cca7a879fe3db8c2676 100644 --- a/src/conio/ciolib.c +++ b/src/conio/ciolib.c @@ -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 diff --git a/src/conio/curs_cio.c b/src/conio/curs_cio.c index db97b72841e38054300a9f6319c2e83fb5b2364a..d1c50e1dc662b51aed4cec47e763dc5478d9290b 100644 --- a/src/conio/curs_cio.c +++ b/src/conio/curs_cio.c @@ -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; +} diff --git a/src/conio/curs_cio.h b/src/conio/curs_cio.h index fd7d6a5536d13ee9affec89338909f80b76dec1c..b4a490c9962e9c3d6338cae649213057ac1acb7b 100644 --- a/src/conio/curs_cio.h +++ b/src/conio/curs_cio.h @@ -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