summaryrefslogtreecommitdiff
path: root/sys-process/htop/files/htop-2.1.0-color_issues.patch
blob: 0b4bea8bb956c18548e05b943b1c0808752f4be8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From ac2dff2881a7ab203750e8edf7a46b69ae492ed0 Mon Sep 17 00:00:00 2001
From: Hisham Muhammad <hisham@gobolinux.org>
Date: Mon, 5 Feb 2018 07:01:12 +0100
Subject: [PATCH] Fix color behavior on some terminals.

Fixes #635.
---
 CRT.c         | 32 +++++++++++++++++---------------
 CRT.h         |  1 +
 ColorsPanel.c |  1 +
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/CRT.c b/CRT.c
index 237e30ef..ca9a10dd 100644
--- a/CRT.c
+++ b/CRT.c
@@ -37,6 +37,7 @@ in the source distribution for its full text.
 #define White COLOR_WHITE
 
 #define ColorPairGrayBlack ColorPair(Magenta,Magenta)
+#define ColorIndexGrayBlack ColorIndex(Magenta,Magenta)
 
 #define KEY_WHEELUP KEY_F(20)
 #define KEY_WHEELDOWN KEY_F(21)
@@ -713,22 +714,23 @@ void CRT_enableDelay() {
 
 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++) {
-            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++) {
-            if (ColorIndex(i,j) != ColorIndex(Magenta,Magenta)) {
-               init_pair(ColorIndex(i,j), i, (j==0?-1:j));
-            }
+
+   for (int i = 0; i < 8; i++) {
+      for (int j = 0; j < 8; j++) {
+         if (ColorIndex(i,j) != ColorPairGrayBlack) {
+            int bg = (colorScheme != COLORSCHEME_BLACKNIGHT)
+                     ? (j==0 ? -1 : j)
+                     : j;
+            init_pair(ColorIndex(i,j), i, bg);
          }
-      init_pair(ColorIndex(Magenta,Magenta), 8, -1);
+      }
    }
+
+   int grayBlackFg = COLORS > 8 ? 8 : 0;
+   int grayBlackBg = (colorScheme != COLORSCHEME_BLACKNIGHT)
+                     ? -1
+                     : 0;
+   init_pair(ColorIndexGrayBlack, grayBlackFg, grayBlackBg);
+
    CRT_colors = CRT_colorSchemes[colorScheme];
 }
diff --git a/CRT.h b/CRT.h
index 590fff6e..933fe068 100644
--- a/CRT.h
+++ b/CRT.h
@@ -26,6 +26,7 @@ in the source distribution for its full text.
 #define White COLOR_WHITE
 
 #define ColorPairGrayBlack ColorPair(Magenta,Magenta)
+#define ColorIndexGrayBlack ColorIndex(Magenta,Magenta)
 
 #define KEY_WHEELUP KEY_F(20)
 #define KEY_WHEELDOWN KEY_F(21)
diff --git a/ColorsPanel.c b/ColorsPanel.c
index 627a516a..2028335f 100644
--- a/ColorsPanel.c
+++ b/ColorsPanel.c
@@ -78,6 +78,7 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
       this->settings->changed = true;
       const Header* header = this->scr->header;
       CRT_setColors(mark);
+      clear();
       Panel* menu = (Panel*) Vector_get(this->scr->panels, 0);
       Header_draw(header);
       RichString_setAttr(&(super->header), CRT_colors[PANEL_HEADER_FOCUS]);