From 16be8d10413bbcf822577afd4019d65aba7459e0 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 10 Nov 2007 21:04:35 +0100 Subject: [PATCH] Fix madmutt for stupid terms with only 64 colors. Signed-off-by: Pierre Habouzit --- lib-ui/madtty.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib-ui/madtty.c b/lib-ui/madtty.c index 7a5c222..85bd257 100644 --- a/lib-ui/madtty.c +++ b/lib-ui/madtty.c @@ -955,7 +955,7 @@ void madtty_keypress(madtty_t *t, int keycode) void madtty_init_colors(void) { - if (COLORS > 8) { + if (COLOR_PAIRS > 64) { use_default_colors(); assume_default_colors(-1, -1); has_default = 1; @@ -976,9 +976,16 @@ void madtty_init_colors(void) int madtty_color_pair(int fg, int bg) { - if (fg < -1) - fg = -1; - if (bg < -1) - bg = -1; - return COLOR_PAIR(has_default ? (fg + 1) * 16 + bg + 1 : (7 - fg) * 8 + bg); + if (has_default) { + if (fg < -1) + fg = -1; + if (bg < -1) + bg = -1; + return COLOR_PAIR((fg + 1) * 16 + bg + 1); + } + if (fg < 0) + fg = COLOR_WHITE; + if (bg < 0) + bg = COLOR_BLACK; + return COLOR_PAIR((7 - fg) * 8 + bg); } -- 2.20.1