Increase the size of the 'message' buffer, which is currently
[sgt/tweak] / curses.c
index f11d777..2ca5ef2 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -1,13 +1,12 @@
+#include "tweak.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <assert.h>
-
 #include <curses.h>
 
-#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)