mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Visual tweaks: change color when following, add Broken Gray theme.
This commit is contained in:
parent
01a29f0267
commit
b1f934c5d5
3
Action.c
3
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;
|
||||
}
|
||||
|
||||
|
47
CRT.c
47
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);
|
||||
|
8
CRT.h
8
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,
|
||||
|
@ -43,6 +43,7 @@ static const char* ColorSchemeNames[] = {
|
||||
"Light Terminal",
|
||||
"MC",
|
||||
"Black Night",
|
||||
"Broken Gray",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
20
Panel.c
20
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));
|
||||
|
3
Panel.h
3
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user