summaryrefslogtreecommitdiffstats
path: root/ScreenManager.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2022-10-20 15:03:17 +0200
committerBenBE <BenBE@geshi.org>2022-10-22 17:42:19 +0200
commit15fe50d272a5f548c7b9a0b8e79794fe1caf31bc (patch)
treea27749d593aacd3d75a22c1154c354cc8958d2a9 /ScreenManager.c
parentd83948ed09039864cdaf6066a1bd64476211ecaa (diff)
Toggle the header meters with pound key
Show/hide the header meters with the pound ('#') key. Useful in cases where the header is too large and occupies essential parts of the screen, especially in settings (see #1108). It is only stored as a runtime state, not a persistent setting; to remove the header permanently one can delete all active meters.
Diffstat (limited to 'ScreenManager.c')
-rw-r--r--ScreenManager.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/ScreenManager.c b/ScreenManager.c
index e4b04bd3..b2cbf8c8 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -24,7 +24,7 @@ in the source distribution for its full text.
#include "XUtils.h"
-ScreenManager* ScreenManager_new(Header* header, const Settings* settings, const State* state, bool owner) {
+ScreenManager* ScreenManager_new(Header* header, const Settings* settings, State* state, bool owner) {
ScreenManager* this;
this = xMalloc(sizeof(ScreenManager));
this->x1 = 0;
@@ -53,18 +53,28 @@ void ScreenManager_add(ScreenManager* this, Panel* item, int size) {
ScreenManager_insert(this, item, size, Vector_size(this->panels));
}
+static int header_height(const ScreenManager* this) {
+ if (this->state->hideMeters)
+ return 0;
+
+ if (this->header)
+ return this->header->height;
+
+ return 0;
+}
+
void ScreenManager_insert(ScreenManager* this, Panel* item, int size, int idx) {
int lastX = 0;
if (idx > 0) {
const Panel* last = (const Panel*) Vector_get(this->panels, idx - 1);
lastX = last->x + last->w + 1;
}
- int height = LINES - this->y1 - (this->header ? this->header->height : 0) + this->y2;
+ int height = LINES - this->y1 - header_height(this) + this->y2;
if (size <= 0) {
size = COLS - this->x1 + this->x2 - lastX;
}
Panel_resize(item, size, height);
- Panel_move(item, lastX, this->y1 + (this->header ? this->header->height : 0));
+ Panel_move(item, lastX, this->y1 + header_height(this));
if (idx < this->panelCount) {
for (int i = idx + 1; i <= this->panelCount; i++) {
Panel* p = (Panel*) Vector_get(this->panels, i);
@@ -91,7 +101,7 @@ Panel* ScreenManager_remove(ScreenManager* this, int idx) {
}
void ScreenManager_resize(ScreenManager* this) {
- int y1_header = this->y1 + (this->header ? this->header->height : 0);
+ int y1_header = this->y1 + header_height(this);
int panels = this->panelCount;
int lastX = 0;
for (int i = 0; i < panels - 1; i++) {
@@ -137,7 +147,8 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
}
if (*redraw) {
ProcessList_rebuildPanel(pl);
- Header_draw(this->header);
+ if (!this->state->hideMeters)
+ Header_draw(this->header);
}
*rescan = false;
}
@@ -376,6 +387,11 @@ tryRight:
}
break;
+ case '#':
+ this->state->hideMeters = !this->state->hideMeters;
+ ScreenManager_resize(this);
+ force_redraw = true;
+ break;
case 27:
case 'q':
case KEY_F(10):

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