Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
2d8dd0b2
Commit
2d8dd0b2
authored
May 23, 2017
by
Hisham
Browse files
Work around the strange behavior of gray.
parent
b1028e03
Changes
2
Hide whitespace changes
Inline
Side-by-side
CRT.c
View file @
2d8dd0b2
...
...
@@ -18,7 +18,9 @@ in the source distribution for its full text.
#include <locale.h>
#include <langinfo.h>
#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
|
ColorPair
Gray
Black
,
[
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
|
ColorPair
Gray
Black
,
[
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
|
ColorPair
Gray
Black
,
[
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
]
=
ColorPair
Gray
Black
,
[
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
|
ColorPair
Gray
Black
,
[
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
|
ColorPair
Gray
Black
)
?
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
];
}
CRT.h
View file @
2d8dd0b2
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment