From 257b4b360c75f806dc30985aaee696d2fe1d117e Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 25 Oct 2002 04:53:16 +0000 Subject: [PATCH] * sldisply.c: Patch to swap blue and red colors for setf/setb capabilities. Needed on QNX Neutrino. Reported by Pavel Shirshov --- slang/ChangeLog | 6 ++++++ slang/sldisply.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/slang/ChangeLog b/slang/ChangeLog index 16d7532a4..0a2511c89 100644 --- a/slang/ChangeLog +++ b/slang/ChangeLog @@ -1,3 +1,9 @@ +2002-10-25 Pavel Roskin + + * sldisply.c: Patch to swap blue and red colors for setf/setb + capabilities. Needed on QNX Neutrino. + Reported by Pavel Shirshov + 2002-10-07 Pavel Roskin * include/jdmacros.h: Define SLMEMSET and SLMEMCPY diff --git a/slang/sldisply.c b/slang/sldisply.c index cec0c8c5a..4bcc9063a 100644 --- a/slang/sldisply.c +++ b/slang/sldisply.c @@ -160,6 +160,13 @@ static Ansi_Color_Type Ansi_Color_Map[JMAX_COLORS] = {RGB(0, 1, 0, 1, 1, 1), SLTT_REV_MASK, NULL} }; +static int Is_Color_BGR = 0; /* 0 if least significant bit is blue, not red */ +#define COLOR_ARG(color) (Is_Color_BGR ? RGB_to_BGR[color] : color) +static int RGB_to_BGR[] = +{ + 0, 4, 2, 6, 1, 5, 3, 7 +}; + static char *Color_Fg_Str = "\033[3%dm"; static char *Color_Bg_Str = "\033[4%dm"; static char *Default_Color_Fg_Str = "\033[39m"; @@ -1315,7 +1322,7 @@ static void write_attributes (SLtt_Char_Type fgbg) if (fg0 == SLSMG_COLOR_DEFAULT) tt_write_string (Default_Color_Fg_Str); else - tt_printf (Color_Fg_Str, fg0, 0); + tt_printf (Color_Fg_Str, COLOR_ARG(fg0), 0); } if (unknown_attributes @@ -1324,7 +1331,7 @@ static void write_attributes (SLtt_Char_Type fgbg) if (bg0 == SLSMG_COLOR_DEFAULT) tt_write_string (Default_Color_Bg_Str); else - tt_printf (Color_Bg_Str, bg0, 0); + tt_printf (Color_Bg_Str, COLOR_ARG(bg0), 0); } } @@ -2320,6 +2327,7 @@ int SLtt_initialize (char *term) { Color_Fg_Str = SLtt_tgetstr ("Sf"); /* setf */ Color_Bg_Str = SLtt_tgetstr ("Sb"); /* setb */ + Is_Color_BGR = 1; } if ((Max_Terminfo_Colors = SLtt_tgetnum ("Co")) < 0)