X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/tweak/blobdiff_plain/6e182d98f1e2191523a4a0b8532a73819d6dca8d..6a8be6e6dea40e898fe4af00f27ac04f1fa82ef0:/curses.c diff --git a/curses.c b/curses.c index f11d777..2ca5ef2 100644 --- a/curses.c +++ b/curses.c @@ -1,13 +1,12 @@ +#include "tweak.h" + #include #include #include #include #include - #include -#include "tweak.h" - int display_rows, display_cols; void display_beep(void) @@ -28,8 +27,10 @@ void display_setup(void) move(0,0); refresh(); get_screen_size(); - if (has_colors()) + if (has_colors()) { start_color(); + use_default_colors(); + } } void display_cleanup(void) @@ -60,7 +61,7 @@ void display_write_chars(char *str, int len) #define MAXCOLOURS 32 int attrs[MAXCOLOURS]; -void display_define_colour(int colour, int fg, int bg) +void display_define_colour(int colour, int fg, int bg, int reverse) { static int colours[8] = { COLOR_BLACK, @@ -73,11 +74,19 @@ void display_define_colour(int colour, int fg, int bg) COLOR_WHITE, }; - assert(colour >= 0 && colour < MAXCOLOURS && colour < COLOR_PAIRS-2); - - assert(!(bg & ~7)); /* bold backgrounds are nonportable */ - init_pair(colour+1, colours[fg & 7], colours[bg]); - attrs[colour] = (fg & 8 ? A_BOLD : 0) | COLOR_PAIR(colour+1); + if (fg < 0 && bg < 0) { + attrs[colour] = 0; + } else { + assert(colour >= 0 && colour < MAXCOLOURS); + assert(!(bg & ~7)); /* bold backgrounds are nonportable */ + if (colour < COLOR_PAIRS-2) { + init_pair(colour+1, colours[fg & 7], colours[bg]); + attrs[colour] = (fg & 8 ? A_BOLD : 0) | COLOR_PAIR(colour+1); + } else { + /* can't allocate a colour pair, so we just use b&w attrs */ + attrs[colour] = (fg & 8 ? A_BOLD : 0) | (reverse ? A_REVERSE : 0); + } + } } void display_set_colour(int colour)