summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-12-28 23:26:14 +0100
committercgzones <cgzones@googlemail.com>2021-01-04 23:12:43 +0100
commita3cced9fb615a1cfe0b334fc41dc785f1fb9aef5 (patch)
treeb54469629867cbff2a2dd7489a5c1682d5e22440
parent24c5ca9ddfbe088a3d25694cbe170eaf3d7f828f (diff)
Add option to hide the Function Bar
Support three settings: - Always show Function Bar - Always hide the Function Bar, except in Infoscreens (Env/Locks...) and when editing the search and filter mode - Hide the Function Bar on ESC until the next user input Closes: #439
-rw-r--r--Action.c2
-rw-r--r--Action.h4
-rw-r--r--DisplayOptionsPanel.c1
-rw-r--r--InfoScreen.c4
-rw-r--r--MainPanel.c8
-rw-r--r--Panel.c9
-rw-r--r--Panel.h18
-rw-r--r--ScreenManager.c2
-rw-r--r--Settings.c4
-rw-r--r--Settings.h1
10 files changed, 36 insertions, 17 deletions
diff --git a/Action.c b/Action.c
index 32cea103..e6e35e72 100644
--- a/Action.c
+++ b/Action.c
@@ -325,7 +325,7 @@ static Htop_Reaction actionKill(State* st) {
if (sgn) {
if (sgn->key != 0) {
Panel_setHeader(st->panel, "Sending...");
- Panel_draw(st->panel, false, true, true);
+ Panel_draw(st->panel, false, true, true, State_hideFunctionBar(st));
refresh();
MainPanel_foreachProcess((MainPanel*)st->panel, Process_sendSignal, (Arg) { .i = sgn->key }, NULL);
napms(500);
diff --git a/Action.h b/Action.h
index 12519119..02d9030d 100644
--- a/Action.h
+++ b/Action.h
@@ -41,6 +41,10 @@ typedef struct State_ {
bool hideProcessSelection;
} State;
+static inline bool State_hideFunctionBar(const State* st) {
+ return st->settings->hideFunctionBar == 2 || (st->settings->hideFunctionBar == 1 && st->hideProcessSelection);
+}
+
typedef Htop_Reaction (*Htop_Action)(State* st);
Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess);
diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c
index 49beb5a6..4b8793af 100644
--- a/DisplayOptionsPanel.c
+++ b/DisplayOptionsPanel.c
@@ -124,6 +124,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
Panel_add(super, (Object*) NumberItem_newByRef("Update interval (in seconds)", &(settings->delay), -1, 1, 255));
Panel_add(super, (Object*) CheckItem_newByRef("Highlight new and old processes", &(settings->highlightChanges)));
Panel_add(super, (Object*) NumberItem_newByRef("- Highlight time (in seconds)", &(settings->highlightDelaySecs), 0, 1, 24*60*60));
+ Panel_add(super, (Object*) NumberItem_newByRef("Hide Function Bar (0 - off, 1 - on ESC until next input, 2 - permanently)", &(settings->hideFunctionBar), 0, 0, 2));
#ifdef HAVE_LIBHWLOC
Panel_add(super, (Object*) CheckItem_newByRef("Show topology when selecting affinity by default", &(settings->topologyAffinity)));
#endif
diff --git a/InfoScreen.c b/InfoScreen.c
index 79f123e9..51bc1587 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -56,7 +56,7 @@ void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
mvhline(0, 0, ' ', COLS);
mvwprintw(stdscr, 0, 0, title);
attrset(CRT_colors[DEFAULT_COLOR]);
- Panel_draw(this->display, true, true, true);
+ Panel_draw(this->display, true, true, true, false);
IncSet_drawBar(this->inc);
}
@@ -89,7 +89,7 @@ void InfoScreen_run(InfoScreen* this) {
bool looping = true;
while (looping) {
- Panel_draw(panel, false, true, true);
+ Panel_draw(panel, false, true, true, false);
IncSet_drawBar(this->inc);
if (this->inc->active) {
diff --git a/MainPanel.c b/MainPanel.c
index c8a4c059..9fbd69d9 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -51,6 +51,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
Htop_Reaction reaction = HTOP_OK;
+ /* reset on every normal key */
if (ch != ERR && ch != KEY_RESIZE)
this->state->hideProcessSelection = false;
@@ -160,8 +161,13 @@ bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Ar
return ok;
}
-static void MainPanel_drawFunctionBar(Panel* super) {
+static void MainPanel_drawFunctionBar(Panel* super, bool hideFunctionBar) {
MainPanel* this = (MainPanel*) super;
+
+ // Do not hide active search and filter bar.
+ if (hideFunctionBar && !this->inc->active)
+ return;
+
IncSet_drawBar(this->inc);
if (this->state->pauseProcessUpdate) {
FunctionBar_append("PAUSED", CRT_colors[PAUSED]);
diff --git a/Panel.c b/Panel.c
index d59f3d6b..c76909cd 100644
--- a/Panel.c
+++ b/Panel.c
@@ -208,7 +208,7 @@ void Panel_splice(Panel* this, Vector* from) {
this->needsRedraw = true;
}
-void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelected) {
+void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelected, bool hideFunctionBar) {
assert (this != NULL);
int size = Vector_size(this->items);
@@ -217,6 +217,9 @@ void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelect
int x = this->x;
int h = this->h;
+ if (hideFunctionBar)
+ h++;
+
const int header_attr = focus
? CRT_colors[PANEL_HEADER_FOCUS]
: CRT_colors[PANEL_HEADER_UNFOCUS];
@@ -319,8 +322,8 @@ void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelect
if (focus && (this->needsRedraw || force_redraw || !this->wasFocus)) {
if (Panel_drawFunctionBarFn(this))
- Panel_drawFunctionBar(this);
- else
+ Panel_drawFunctionBar(this, hideFunctionBar);
+ else if (!hideFunctionBar)
FunctionBar_draw(this->currentBar);
}
diff --git a/Panel.h b/Panel.h
index 63659e3c..6b442793 100644
--- a/Panel.h
+++ b/Panel.h
@@ -36,7 +36,7 @@ typedef enum HandlerResult_ {
#define EVENT_HEADER_CLICK_GET_X(ev_) ((ev_) + 10000)
typedef HandlerResult (*Panel_EventHandler)(Panel*, int);
-typedef void (*Panel_DrawFunctionBar)(Panel*);
+typedef void (*Panel_DrawFunctionBar)(Panel*, bool);
typedef void (*Panel_PrintHeader)(Panel*);
typedef struct PanelClass_ {
@@ -46,13 +46,13 @@ typedef struct PanelClass_ {
const Panel_PrintHeader printHeader;
} PanelClass;
-#define As_Panel(this_) ((const PanelClass*)((this_)->super.klass))
-#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler
-#define Panel_eventHandler(this_, ev_) (assert(As_Panel(this_)->eventHandler), As_Panel(this_)->eventHandler((Panel*)(this_), ev_))
-#define Panel_drawFunctionBarFn(this_) As_Panel(this_)->drawFunctionBar
-#define Panel_drawFunctionBar(this_) (assert(As_Panel(this_)->drawFunctionBar), As_Panel(this_)->drawFunctionBar((Panel*)(this_)))
-#define Panel_printHeaderFn(this_) As_Panel(this_)->printHeader
-#define Panel_printHeader(this_) (assert(As_Panel(this_)->printHeader), As_Panel(this_)->printHeader((Panel*)(this_)))
+#define As_Panel(this_) ((const PanelClass*)((this_)->super.klass))
+#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler
+#define Panel_eventHandler(this_, ev_) (assert(As_Panel(this_)->eventHandler), As_Panel(this_)->eventHandler((Panel*)(this_), ev_))
+#define Panel_drawFunctionBarFn(this_) As_Panel(this_)->drawFunctionBar
+#define Panel_drawFunctionBar(this_, hideFB_) (assert(As_Panel(this_)->drawFunctionBar), As_Panel(this_)->drawFunctionBar((Panel*)(this_), hideFB_))
+#define Panel_printHeaderFn(this_) As_Panel(this_)->printHeader
+#define Panel_printHeader(this_) (assert(As_Panel(this_)->printHeader), As_Panel(this_)->printHeader((Panel*)(this_)))
struct Panel_ {
Object super;
@@ -118,7 +118,7 @@ int Panel_size(Panel* this);
void Panel_setSelected(Panel* this, int selected);
-void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelected);
+void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelected, bool hideFunctionBar);
void Panel_splice(Panel* this, Vector* from);
diff --git a/ScreenManager.c b/ScreenManager.c
index 6b7ddc9b..51951a84 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -123,7 +123,7 @@ static void ScreenManager_drawPanels(ScreenManager* this, int focus, bool force_
const int nPanels = this->panelCount;
for (int i = 0; i < nPanels; i++) {
Panel* panel = (Panel*) Vector_get(this->panels, i);
- Panel_draw(panel, force_redraw, i == focus, !((panel == this->state->panel) && this->state->hideProcessSelection));
+ Panel_draw(panel, force_redraw, i == focus, !((panel == this->state->panel) && this->state->hideProcessSelection), State_hideFunctionBar(this->state));
mvvline(panel->y, panel->x + panel->w, ' ', panel->h);
}
}
diff --git a/Settings.c b/Settings.c
index a0d42f39..ef607f00 100644
--- a/Settings.c
+++ b/Settings.c
@@ -221,6 +221,8 @@ static bool Settings_read(Settings* this, const char* fileName, int initialCpuCo
} else if (String_eq(option[0], "right_meter_modes")) {
Settings_readMeterModes(this, option[1], 1);
didReadMeters = true;
+ } else if (String_eq(option[0], "hide_function_bar")) {
+ this->hideFunctionBar = atoi(option[1]);
#ifdef HAVE_LIBHWLOC
} else if (String_eq(option[0], "topology_affinity")) {
this->topologyAffinity = !!atoi(option[1]);
@@ -315,6 +317,7 @@ bool Settings_write(Settings* this) {
fprintf(fd, "left_meter_modes="); writeMeterModes(this, fd, 0);
fprintf(fd, "right_meters="); writeMeters(this, fd, 1);
fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1);
+ fprintf(fd, "hide_function_bar=%d\n", (int) this->hideFunctionBar);
#ifdef HAVE_LIBHWLOC
fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity);
#endif
@@ -352,6 +355,7 @@ Settings* Settings_new(int initialCpuCount) {
this->findCommInCmdline = true;
this->stripExeFromCmdline = true;
this->showMergedCommand = false;
+ this->hideFunctionBar = 0;
#ifdef HAVE_LIBHWLOC
this->topologyAffinity = false;
#endif
diff --git a/Settings.h b/Settings.h
index 35520638..fdaf3e37 100644
--- a/Settings.h
+++ b/Settings.h
@@ -64,6 +64,7 @@ typedef struct Settings_ {
bool accountGuestInCPUMeter;
bool headerMargin;
bool enableMouse;
+ int hideFunctionBar; // 0 - off, 1 - on ESC until next input, 2 - permanently
#ifdef HAVE_LIBHWLOC
bool topologyAffinity;
#endif

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