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
f5f29cee
Commit
f5f29cee
authored
Feb 03, 2015
by
Hisham Muhammad
Browse files
Make the implementation of color schemes declarative.
parent
c3a7b2f1
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
CRT.c
View file @
f5f29cee
This diff is collapsed.
Click to expand it.
CRT.h
View file @
f5f29cee
...
@@ -11,13 +11,6 @@ in the source distribution for its full text.
...
@@ -11,13 +11,6 @@ in the source distribution for its full text.
#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j)
#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j)
#define COLORSCHEME_DEFAULT 0
#define COLORSCHEME_MONOCHROME 1
#define COLORSCHEME_BLACKONWHITE 2
#define COLORSCHEME_BLACKONWHITE2 3
#define COLORSCHEME_MIDNIGHT 4
#define COLORSCHEME_BLACKNIGHT 5
#define Black COLOR_BLACK
#define Black COLOR_BLACK
#define Red COLOR_RED
#define Red COLOR_RED
#define Green COLOR_GREEN
#define Green COLOR_GREEN
...
@@ -42,6 +35,16 @@ typedef enum TreeStr_ {
...
@@ -42,6 +35,16 @@ typedef enum TreeStr_ {
TREE_STR_COUNT
TREE_STR_COUNT
}
TreeStr
;
}
TreeStr
;
typedef
enum
ColorSchemes_
{
COLORSCHEME_DEFAULT
=
0
,
COLORSCHEME_MONOCHROME
=
1
,
COLORSCHEME_BLACKONWHITE
=
2
,
COLORSCHEME_LIGHTTERMINAL
=
3
,
COLORSCHEME_MIDNIGHT
=
4
,
COLORSCHEME_BLACKNIGHT
=
5
,
LAST_COLORSCHEME
=
6
,
}
ColorSchemes
;
typedef
enum
ColorElements_
{
typedef
enum
ColorElements_
{
RESET_COLOR
,
RESET_COLOR
,
DEFAULT_COLOR
,
DEFAULT_COLOR
,
...
@@ -115,7 +118,9 @@ extern const char **CRT_treeStr;
...
@@ -115,7 +118,9 @@ extern const char **CRT_treeStr;
extern
bool
CRT_utf8
;
extern
bool
CRT_utf8
;
extern
int
CRT_colors
[
LAST_COLORELEMENT
];
int
*
CRT_colors
;
extern
int
CRT_colorSchemes
[
LAST_COLORSCHEME
][
LAST_COLORELEMENT
];
extern
int
CRT_cursorX
;
extern
int
CRT_cursorX
;
...
...
ColorsPanel.c
View file @
f5f29cee
...
@@ -16,7 +16,7 @@ in the source distribution for its full text.
...
@@ -16,7 +16,7 @@ in the source distribution for its full text.
// TO ADD A NEW SCHEME:
// TO ADD A NEW SCHEME:
// * Increment the size of bool check in ColorsPanel.h
// * Increment the size of bool check in ColorsPanel.h
// * Add the entry in the ColorSchemes array below in the file
// * Add the entry in the ColorScheme
Name
s array below in the file
// * Add a define in CRT.h that matches the order of the array
// * Add a define in CRT.h that matches the order of the array
// * Add the colors in CRT_setColors
// * Add the colors in CRT_setColors
...
@@ -34,7 +34,7 @@ typedef struct ColorsPanel_ {
...
@@ -34,7 +34,7 @@ typedef struct ColorsPanel_ {
}*/
}*/
static
const
char
*
ColorSchemes
[]
=
{
static
const
char
*
ColorScheme
Name
s
[]
=
{
"Default"
,
"Default"
,
"Monochromatic"
,
"Monochromatic"
,
"Black on White"
,
"Black on White"
,
...
@@ -63,7 +63,7 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
...
@@ -63,7 +63,7 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
case
KEY_ENTER
:
case
KEY_ENTER
:
case
KEY_MOUSE
:
case
KEY_MOUSE
:
case
' '
:
case
' '
:
for
(
int
i
=
0
;
ColorSchemes
[
i
]
!=
NULL
;
i
++
)
for
(
int
i
=
0
;
ColorScheme
Name
s
[
i
]
!=
NULL
;
i
++
)
CheckItem_set
((
CheckItem
*
)
Panel_get
(
super
,
i
),
false
);
CheckItem_set
((
CheckItem
*
)
Panel_get
(
super
,
i
),
false
);
CheckItem_set
((
CheckItem
*
)
Panel_get
(
super
,
mark
),
true
);
CheckItem_set
((
CheckItem
*
)
Panel_get
(
super
,
mark
),
true
);
this
->
settings
->
colorScheme
=
mark
;
this
->
settings
->
colorScheme
=
mark
;
...
@@ -100,8 +100,8 @@ ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
...
@@ -100,8 +100,8 @@ ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
this
->
scr
=
scr
;
this
->
scr
=
scr
;
Panel_setHeader
(
super
,
"Colors"
);
Panel_setHeader
(
super
,
"Colors"
);
for
(
int
i
=
0
;
ColorSchemes
[
i
]
!=
NULL
;
i
++
)
{
for
(
int
i
=
0
;
ColorScheme
Name
s
[
i
]
!=
NULL
;
i
++
)
{
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
ColorSchemes
[
i
]),
NULL
,
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
ColorScheme
Name
s
[
i
]),
NULL
,
false
));
}
}
CheckItem_set
((
CheckItem
*
)
Panel_get
(
super
,
settings
->
colorScheme
),
true
);
CheckItem_set
((
CheckItem
*
)
Panel_get
(
super
,
settings
->
colorScheme
),
true
);
return
this
;
return
this
;
...
...
ColorsPanel.h
View file @
f5f29cee
...
@@ -11,7 +11,7 @@ in the source distribution for its full text.
...
@@ -11,7 +11,7 @@ in the source distribution for its full text.
// TO ADD A NEW SCHEME:
// TO ADD A NEW SCHEME:
// * Increment the size of bool check in ColorsPanel.h
// * Increment the size of bool check in ColorsPanel.h
// * Add the entry in the ColorSchemes array below in the file
// * Add the entry in the ColorScheme
Name
s array below in the file
// * Add a define in CRT.h that matches the order of the array
// * Add a define in CRT.h that matches the order of the array
// * Add the colors in CRT_setColors
// * Add the colors in CRT_setColors
...
...
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