summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-08-21 20:48:45 +0200
committerBenBE <BenBE@geshi.org>2021-08-22 10:40:59 +0200
commit68f2bfea619a454b5de1431689eb086cf13f5ceb (patch)
tree9c75b625e2aac6035aad2cdc9a51be863d26c59e
parentb9e69223d02287f75c24c3f5be869a04979e5b17 (diff)
Abstract resize handling by adding a new Htop reaction
-rw-r--r--Action.c5
-rw-r--r--Action.h1
-rw-r--r--MainPanel.c3
-rw-r--r--Panel.h3
-rw-r--r--ScreenManager.c4
5 files changed, 11 insertions, 5 deletions
diff --git a/Action.c b/Action.c
index c7f4118b..802d2fc5 100644
--- a/Action.c
+++ b/Action.c
@@ -388,10 +388,7 @@ Htop_Reaction Action_follow(State* st) {
static Htop_Reaction actionSetup(State* st) {
Action_runSetup(st);
- int headerHeight = Header_calculateHeight(st->header);
- Panel_move((Panel*)st->mainPanel, 0, headerHeight);
- Panel_resize((Panel*)st->mainPanel, COLS, LINES - headerHeight - 1);
- return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
+ return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR | HTOP_RESIZE;
}
static Htop_Reaction actionLsof(State* st) {
diff --git a/Action.h b/Action.h
index 4fb800f5..99e82be5 100644
--- a/Action.h
+++ b/Action.h
@@ -30,6 +30,7 @@ typedef enum {
HTOP_QUIT = 0x10,
HTOP_REDRAW_BAR = 0x20,
HTOP_UPDATE_PANELHDR = 0x40 | HTOP_REFRESH,
+ HTOP_RESIZE = 0x80 | HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR,
} Htop_Reaction;
struct MainPanel_;
diff --git a/MainPanel.c b/MainPanel.c
index 5a75af3a..21b5d1a3 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -112,6 +112,9 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
if (reaction & HTOP_REDRAW_BAR) {
MainPanel_updateTreeFunctions(this, this->state->settings->treeView);
}
+ if (reaction & HTOP_RESIZE) {
+ result |= RESIZE;
+ }
if (reaction & HTOP_UPDATE_PANELHDR) {
result |= REDRAW;
}
diff --git a/Panel.h b/Panel.h
index 96c138d1..40080da1 100644
--- a/Panel.h
+++ b/Panel.h
@@ -26,7 +26,8 @@ typedef enum HandlerResult_ {
REFRESH = 0x08,
REDRAW = 0x10,
RESCAN = 0x20,
- SYNTH_KEY = 0x40,
+ RESIZE = 0x40,
+ SYNTH_KEY = 0x80,
} HandlerResult;
#define EVENT_SET_SELECTED (-1)
diff --git a/ScreenManager.c b/ScreenManager.c
index d403e24c..914c510b 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -243,6 +243,10 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if (result & REDRAW) {
force_redraw = true;
}
+ if (result & RESIZE) {
+ ScreenManager_resize(this);
+ force_redraw = true;
+ }
if (result & RESCAN) {
rescan = true;
sortTimeout = 0;

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