From dc1e2fe77a99263de102a8e1d8819e929339a7bb Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sat, 10 Nov 2007 21:09:00 +0100 Subject: [PATCH] Fix madtty_color_pair for terms with only 8 colors. Signed-off-by: Pierre Habouzit --- madtty/madtty.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/madtty/madtty.c b/madtty/madtty.c index 5b51618..8994454 100644 --- a/madtty/madtty.c +++ b/madtty/madtty.c @@ -671,7 +671,7 @@ static uint16_t const vt100_0[62] = { // 41 .. 7e 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, // 78-7e }; -void madtty_putc(madtty_t *t, wchar_t wc) +static void madtty_putc(madtty_t *t, wchar_t wc) { int width = 0; @@ -963,7 +963,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; @@ -984,5 +984,16 @@ void madtty_init_colors(void) int madtty_color_pair(int fg, int bg) { - return 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