From 2d8dd0b29ef350731e2f1afa26af7b02f7649347 Mon Sep 17 00:00:00 2001 From: Hisham Date: Tue, 23 May 2017 14:02:34 -0300 Subject: [PATCH] Work around the strange behavior of gray. --- CRT.c | 34 +++++++++++++++++++++++----------- CRT.h | 6 +++++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CRT.c b/CRT.c index 0d516989..b6fe00e6 100644 --- a/CRT.c +++ b/CRT.c @@ -18,7 +18,9 @@ in the source distribution for its full text. #include #include -#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j) +#define ColorIndex(i,j) ((7-i)*8+j) + +#define ColorPair(i,j) COLOR_PAIR(ColorIndex(i,j)) #define Black COLOR_BLACK #define Red COLOR_RED @@ -29,6 +31,8 @@ in the source distribution for its full text. #define Cyan COLOR_CYAN #define White COLOR_WHITE +#define ColorPairGrayBlack ColorPair(Magenta,Magenta) + #define KEY_WHEELUP KEY_F(20) #define KEY_WHEELDOWN KEY_F(21) #define KEY_RECLICK KEY_F(22) @@ -183,7 +187,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [LED_COLOR] = ColorPair(Green,Black), [TASKS_RUNNING] = A_BOLD | ColorPair(Green,Black), [PROCESS] = A_NORMAL, - [PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Black), + [PROCESS_SHADOW] = A_BOLD | ColorPairGrayBlack, [PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Black), [PROCESS_MEGABYTES] = ColorPair(Cyan,Black), [PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan,Black), @@ -195,7 +199,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD] = ColorPair(Green,Black), [PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Green,Black), [BAR_BORDER] = A_BOLD, - [BAR_SHADOW] = A_BOLD | ColorPair(Black,Black), + [BAR_SHADOW] = A_BOLD | ColorPairGrayBlack, [SWAP] = ColorPair(Red,Black), [GRAPH_1] = A_BOLD | ColorPair(Cyan,Black), [GRAPH_2] = ColorPair(Cyan,Black), @@ -360,7 +364,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [LED_COLOR] = ColorPair(Green,Black), [TASKS_RUNNING] = ColorPair(Green,Black), [PROCESS] = ColorPair(Black,Black), - [PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Black), + [PROCESS_SHADOW] = A_BOLD | ColorPairGrayBlack, [PROCESS_TAG] = ColorPair(White,Blue), [PROCESS_MEGABYTES] = ColorPair(Blue,Black), [PROCESS_BASENAME] = ColorPair(Green,Black), @@ -372,7 +376,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD] = ColorPair(Blue,Black), [PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue,Black), [BAR_BORDER] = ColorPair(Blue,Black), - [BAR_SHADOW] = ColorPair(Black,Black), + [BAR_SHADOW] = ColorPairGrayBlack, [SWAP] = ColorPair(Red,Black), [GRAPH_1] = A_BOLD | ColorPair(Cyan,Black), [GRAPH_2] = ColorPair(Cyan,Black), @@ -478,7 +482,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [LED_COLOR] = ColorPair(Green,Black), [TASKS_RUNNING] = A_BOLD | ColorPair(Green,Black), [PROCESS] = ColorPair(Cyan,Black), - [PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Black), + [PROCESS_SHADOW] = A_BOLD | ColorPairGrayBlack, [PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Black), [PROCESS_MEGABYTES] = A_BOLD | ColorPair(Green,Black), [PROCESS_BASENAME] = A_BOLD | ColorPair(Green,Black), @@ -555,7 +559,7 @@ void CRT_init(int delay, int colorScheme) { for (int i = 0; i < LAST_COLORELEMENT; i++) { unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i]; - CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPair(Black,Black)) ? ColorPair(White,Black) : color; + CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPairGrayBlack) ? ColorPair(White,Black) : color; } halfdelay(CRT_delay); @@ -664,12 +668,20 @@ void CRT_setColors(int colorScheme) { CRT_colorScheme = colorScheme; if (colorScheme == COLORSCHEME_BLACKNIGHT) { for (int i = 0; i < 8; i++) - for (int j = 0; j < 8; j++) - init_pair((7-i)*8+j, i, j); + for (int j = 0; j < 8; j++) { + if (ColorIndex(i,j) != ColorIndex(Magenta,Magenta)) { + init_pair(ColorIndex(i,j), i, j); + } + } + init_pair(ColorIndex(Magenta,Magenta), 8, 0); } else { for (int i = 0; i < 8; i++) - for (int j = 0; j < 8; j++) - init_pair((7-i)*8+j, i, (j==0?-1:j)); + for (int j = 0; j < 8; j++) { + if (ColorIndex(i,j) != ColorIndex(Magenta,Magenta)) { + init_pair(ColorIndex(i,j), i, (j==0?-1:j)); + } + } + init_pair(ColorIndex(Magenta,Magenta), 8, -1); } CRT_colors = CRT_colorSchemes[colorScheme]; } diff --git a/CRT.h b/CRT.h index fb824136..6391e890 100644 --- a/CRT.h +++ b/CRT.h @@ -9,7 +9,9 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ -#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j) +#define ColorIndex(i,j) ((7-i)*8+j) + +#define ColorPair(i,j) COLOR_PAIR(ColorIndex(i,j)) #define Black COLOR_BLACK #define Red COLOR_RED @@ -20,6 +22,8 @@ in the source distribution for its full text. #define Cyan COLOR_CYAN #define White COLOR_WHITE +#define ColorPairGrayBlack ColorPair(Magenta,Magenta) + #define KEY_WHEELUP KEY_F(20) #define KEY_WHEELDOWN KEY_F(21) #define KEY_RECLICK KEY_F(22)