application, of course). A couple of declarations and prototypes had
to be moved higher up main.c (Apple's gcc installation is pleasingly
pedantic, and I'm not quite sure how I got away with the previous
code for so long!), and I've also had to arrange that Tweak can cope
with curses being unwilling to allocate colour pairs.
git-svn-id: svn://svn.tartarus.org/sgt/tweak@5211
cda61777-01e9-0310-a592-
d414129be87e
#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,
if (fg < 0 && bg < 0) {
attrs[colour] = 0;
} else {
- assert(colour >= 0 && colour < MAXCOLOURS && colour < COLOR_PAIRS-2);
+ assert(colour >= 0 && colour < MAXCOLOURS);
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 (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);
+ }
}
}
display_setup();
- display_define_colour(COL_BUFFER, -1, -1);
- display_define_colour(COL_SELECT, 0, 7);
- display_define_colour(COL_STATUS, 11, 4);
- display_define_colour(COL_ESCAPE, 9, 0);
- display_define_colour(COL_INVALID, 11, 0);
+ display_define_colour(COL_BUFFER, -1, -1, FALSE);
+ display_define_colour(COL_SELECT, 0, 7, TRUE);
+ display_define_colour(COL_STATUS, 11, 4, TRUE);
+ display_define_colour(COL_ESCAPE, 9, 0, FALSE);
+ display_define_colour(COL_INVALID, 11, 0, FALSE);
for (i=0; i<256; i++) {
sprintf(hex[i], "%02X", i);
display_refresh ();
}
+volatile int safe_update, update_required;
+void update (void);
+
/*
* Get a string, in the "minibuffer". Return TRUE on success, FALSE
* on break. Possibly syntax-highlight the entered string for
#endif
}
-volatile int safe_update, update_required;
-
void update (void) {
display_recheck_size();
fix_offset ();
SLsmg_write_nchars(str, len);
}
-void display_define_colour(int colour, int fg, int bg)
+void display_define_colour(int colour, int fg, int bg, int reverse)
{
static char *colours[16] = {
"black", "red", "green", "brown",
extern void display_refresh(void);
extern void display_write_str(char *str);
extern void display_write_chars(char *str, int len);
-extern void display_define_colour(int colour, int fg, int bg);
+extern void display_define_colour(int colour, int fg, int bg, int reverse);
extern void display_set_colour(int colour);
extern void display_clear_to_eol(void);
extern int display_getkey(void);