summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-04-09 15:17:20 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-04-09 15:17:20 -0300
commitb1f934c5d51532c334bd2fbe513c8e9d10cd8208 (patch)
tree94ca9aad126276fd7e12bf7cb416742bb6996805
parent01a29f02674af95e6967cec8c5d1659886931f77 (diff)
Visual tweaks: change color when following, add Broken Gray theme.
-rw-r--r--Action.c3
-rw-r--r--CRT.c47
-rw-r--r--CRT.h8
-rw-r--r--ColorsPanel.c1
-rw-r--r--MainPanel.c1
-rw-r--r--Panel.c20
-rw-r--r--Panel.h3
-rw-r--r--ProcessList.c2
8 files changed, 57 insertions, 28 deletions
diff --git a/Action.c b/Action.c
index 67231f1f..af6f2be9 100644
--- a/Action.c
+++ b/Action.c
@@ -158,7 +158,7 @@ Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey) {
settings->sortKey = sortKey;
settings->direction = 1;
settings->treeView = false;
- return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_UPDATE_PANELHDR;
+ return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_UPDATE_PANELHDR | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction sortBy(State* st) {
@@ -324,6 +324,7 @@ static Htop_Reaction actionFilterByUser(State* st) {
static Htop_Reaction actionFollow(State* st) {
st->pl->following = MainPanel_selectedPid((MainPanel*)st->panel);
+ Panel_setSelectionColor(st->panel, CRT_colors[PANEL_SELECTION_FOLLOW]);
return HTOP_KEEP_FOLLOWING;
}
diff --git a/CRT.c b/CRT.c
index 87369d35..031d76a4 100644
--- a/CRT.c
+++ b/CRT.c
@@ -51,7 +51,8 @@ typedef enum ColorSchemes_ {
COLORSCHEME_LIGHTTERMINAL = 3,
COLORSCHEME_MIDNIGHT = 4,
COLORSCHEME_BLACKNIGHT = 5,
- LAST_COLORSCHEME = 6,
+ COLORSCHEME_BROKENGRAY = 6,
+ LAST_COLORSCHEME = 7,
} ColorSchemes;
typedef enum ColorElements_ {
@@ -62,8 +63,9 @@ typedef enum ColorElements_ {
FAILED_SEARCH,
PANEL_HEADER_FOCUS,
PANEL_HEADER_UNFOCUS,
- PANEL_HIGHLIGHT_FOCUS,
- PANEL_HIGHLIGHT_UNFOCUS,
+ PANEL_SELECTION_FOCUS,
+ PANEL_SELECTION_FOLLOW,
+ PANEL_SELECTION_UNFOCUS,
LARGE_NUMBER,
METER_TEXT,
METER_VALUE,
@@ -158,8 +160,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[FUNCTION_KEY] = ColorPair(White,Black),
[PANEL_HEADER_FOCUS] = ColorPair(Black,Green),
[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green),
- [PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan),
- [PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Black,White),
+ [PANEL_SELECTION_FOCUS] = ColorPair(Black,Cyan),
+ [PANEL_SELECTION_FOLLOW] = ColorPair(Black,Yellow),
+ [PANEL_SELECTION_UNFOCUS] = ColorPair(Black,White),
[FAILED_SEARCH] = ColorPair(Red,Cyan),
[UPTIME] = A_BOLD | ColorPair(Cyan,Black),
[BATTERY] = A_BOLD | ColorPair(Cyan,Black),
@@ -216,8 +219,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[FUNCTION_KEY] = A_NORMAL,
[PANEL_HEADER_FOCUS] = A_REVERSE,
[PANEL_HEADER_UNFOCUS] = A_REVERSE,
- [PANEL_HIGHLIGHT_FOCUS] = A_REVERSE,
- [PANEL_HIGHLIGHT_UNFOCUS] = A_BOLD,
+ [PANEL_SELECTION_FOCUS] = A_REVERSE,
+ [PANEL_SELECTION_FOLLOW] = A_REVERSE,
+ [PANEL_SELECTION_UNFOCUS] = A_BOLD,
[FAILED_SEARCH] = A_REVERSE | A_BOLD,
[UPTIME] = A_BOLD,
[BATTERY] = A_BOLD,
@@ -274,8 +278,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[FUNCTION_KEY] = ColorPair(Black,White),
[PANEL_HEADER_FOCUS] = ColorPair(Black,Green),
[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green),
- [PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan),
- [PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Blue,White),
+ [PANEL_SELECTION_FOCUS] = ColorPair(Black,Cyan),
+ [PANEL_SELECTION_FOLLOW] = ColorPair(Black,Yellow),
+ [PANEL_SELECTION_UNFOCUS] = ColorPair(Blue,White),
[FAILED_SEARCH] = ColorPair(Red,Cyan),
[UPTIME] = ColorPair(Yellow,White),
[BATTERY] = ColorPair(Yellow,White),
@@ -332,8 +337,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[FUNCTION_KEY] = ColorPair(Black,Black),
[PANEL_HEADER_FOCUS] = ColorPair(Black,Green),
[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green),
- [PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan),
- [PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Blue,Black),
+ [PANEL_SELECTION_FOCUS] = ColorPair(Black,Cyan),
+ [PANEL_SELECTION_FOLLOW] = ColorPair(Black,Yellow),
+ [PANEL_SELECTION_UNFOCUS] = ColorPair(Blue,Black),
[FAILED_SEARCH] = ColorPair(Red,Cyan),
[UPTIME] = ColorPair(Yellow,Black),
[BATTERY] = ColorPair(Yellow,Black),
@@ -390,8 +396,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[FUNCTION_KEY] = A_NORMAL,
[PANEL_HEADER_FOCUS] = ColorPair(Black,Cyan),
[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Cyan),
- [PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,White),
- [PANEL_HIGHLIGHT_UNFOCUS] = A_BOLD | ColorPair(Yellow,Blue),
+ [PANEL_SELECTION_FOCUS] = ColorPair(Black,White),
+ [PANEL_SELECTION_FOLLOW] = ColorPair(Black,Yellow),
+ [PANEL_SELECTION_UNFOCUS] = A_BOLD | ColorPair(Yellow,Blue),
[FAILED_SEARCH] = ColorPair(Red,Cyan),
[UPTIME] = A_BOLD | ColorPair(Yellow,Blue),
[BATTERY] = A_BOLD | ColorPair(Yellow,Blue),
@@ -448,8 +455,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[FUNCTION_KEY] = ColorPair(Cyan,Black),
[PANEL_HEADER_FOCUS] = ColorPair(Black,Green),
[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green),
- [PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan),
- [PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Black,White),
+ [PANEL_SELECTION_FOCUS] = ColorPair(Black,Cyan),
+ [PANEL_SELECTION_FOLLOW] = ColorPair(Black,Yellow),
+ [PANEL_SELECTION_UNFOCUS] = ColorPair(Black,White),
[FAILED_SEARCH] = ColorPair(Red,Cyan),
[UPTIME] = ColorPair(Green,Black),
[BATTERY] = ColorPair(Green,Black),
@@ -498,7 +506,8 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[CPU_SOFTIRQ] = ColorPair(Blue,Black),
[CPU_STEAL] = ColorPair(Cyan,Black),
[CPU_GUEST] = ColorPair(Cyan,Black),
- }
+ },
+ [COLORSCHEME_BROKENGRAY] = { 0 } // dynamically generated.
};
int CRT_cursorX = 0;
@@ -530,6 +539,12 @@ void CRT_init(int delay, int colorScheme) {
}
CRT_colors = CRT_colorSchemes[colorScheme];
CRT_colorScheme = colorScheme;
+
+ for (int i = 0; i < LAST_COLORELEMENT; i++) {
+ int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i];
+ CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPair(Black,Black)) ? ColorPair(White,Black) : color;
+ }
+
halfdelay(CRT_delay);
nonl();
intrflush(stdscr, false);
diff --git a/CRT.h b/CRT.h
index 73aed438..3e8babe7 100644
--- a/CRT.h
+++ b/CRT.h
@@ -42,7 +42,8 @@ typedef enum ColorSchemes_ {
COLORSCHEME_LIGHTTERMINAL = 3,
COLORSCHEME_MIDNIGHT = 4,
COLORSCHEME_BLACKNIGHT = 5,
- LAST_COLORSCHEME = 6,
+ COLORSCHEME_BROKENGRAY = 6,
+ LAST_COLORSCHEME = 7,
} ColorSchemes;
typedef enum ColorElements_ {
@@ -53,8 +54,9 @@ typedef enum ColorElements_ {
FAILED_SEARCH,
PANEL_HEADER_FOCUS,
PANEL_HEADER_UNFOCUS,
- PANEL_HIGHLIGHT_FOCUS,
- PANEL_HIGHLIGHT_UNFOCUS,
+ PANEL_SELECTION_FOCUS,
+ PANEL_SELECTION_FOLLOW,
+ PANEL_SELECTION_UNFOCUS,
LARGE_NUMBER,
METER_TEXT,
METER_VALUE,
diff --git a/ColorsPanel.c b/ColorsPanel.c
index 3c643fa6..40aa837a 100644
--- a/ColorsPanel.c
+++ b/ColorsPanel.c
@@ -43,6 +43,7 @@ static const char* ColorSchemeNames[] = {
"Light Terminal",
"MC",
"Black Night",
+ "Broken Gray",
NULL
};
diff --git a/MainPanel.c b/MainPanel.c
index 6f34b9a4..49df8273 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -139,6 +139,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
}
if (!(reaction & HTOP_KEEP_FOLLOWING)) {
this->state->pl->following = -1;
+ Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]);
}
return result;
}
diff --git a/Panel.c b/Panel.c
index 7428dda6..c4265266 100644
--- a/Panel.c
+++ b/Panel.c
@@ -68,6 +68,7 @@ struct Panel_ {
FunctionBar* currentBar;
FunctionBar* defaultBar;
RichString header;
+ int selectionColor;
};
#define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0)
@@ -123,6 +124,7 @@ void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool
RichString_beginAllocated(this->header);
this->defaultBar = fuBar;
this->currentBar = fuBar;
+ this->selectionColor = CRT_colors[PANEL_SELECTION_FOCUS];
}
void Panel_done(Panel* this) {
@@ -133,6 +135,10 @@ void Panel_done(Panel* this) {
RichString_end(this->header);
}
+void Panel_setSelectionColor(Panel* this, int color) {
+ this->selectionColor = color;
+}
+
RichString* Panel_getHeader(Panel* this) {
assert (this != NULL);
@@ -301,9 +307,9 @@ void Panel_draw(Panel* this, bool focus) {
int first = this->scrollV;
int upTo = MIN(first + h, size);
- int highlight = focus
- ? CRT_colors[PANEL_HIGHLIGHT_FOCUS]
- : CRT_colors[PANEL_HIGHLIGHT_UNFOCUS];
+ int selectionColor = focus
+ ? this->selectionColor
+ : CRT_colors[PANEL_SELECTION_UNFOCUS];
if (this->needsRedraw) {
int line = 0;
@@ -316,8 +322,8 @@ void Panel_draw(Panel* this, bool focus) {
int amt = MIN(itemLen - scrollH, this->w);
bool selected = (i == this->selected);
if (selected) {
- attrset(highlight);
- RichString_setAttr(&item, highlight);
+ attrset(selectionColor);
+ RichString_setAttr(&item, selectionColor);
}
mvhline(y + line, x, ' ', this->w);
if (amt > 0)
@@ -347,9 +353,9 @@ void Panel_draw(Panel* this, bool focus) {
if (scrollH < oldLen)
RichString_printoffnVal(old, y+this->oldSelected - first, x,
scrollH, MIN(oldLen - scrollH, this->w));
- attrset(highlight);
+ attrset(selectionColor);
mvhline(y+this->selected - first, x+0, ' ', this->w);
- RichString_setAttr(&new, highlight);
+ RichString_setAttr(&new, selectionColor);
if (scrollH < newLen)
RichString_printoffnVal(new, y+this->selected - first, x,
scrollH, MIN(newLen - scrollH, this->w));
diff --git a/Panel.h b/Panel.h
index 2e9c5ad3..67897706 100644
--- a/Panel.h
+++ b/Panel.h
@@ -57,6 +57,7 @@ struct Panel_ {
FunctionBar* currentBar;
FunctionBar* defaultBar;
RichString header;
+ int selectionColor;
};
#define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0)
@@ -84,6 +85,8 @@ void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool
void Panel_done(Panel* this);
+void Panel_setSelectionColor(Panel* this, int color);
+
RichString* Panel_getHeader(Panel* this);
extern void Panel_setHeader(Panel* this, const char* header);
diff --git a/ProcessList.c b/ProcessList.c
index 7fbe6c3a..0e7d5262 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -120,7 +120,7 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) {
const char* field = Process_fields[fields[i]].title;
if (!field) field = "- ";
if (!this->settings->treeView && this->settings->sortKey == fields[i])
- RichString_append(header, CRT_colors[PANEL_HIGHLIGHT_FOCUS], field);
+ RichString_append(header, CRT_colors[PANEL_SELECTION_FOCUS], field);
else
RichString_append(header, CRT_colors[PANEL_HEADER_FOCUS], field);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy