diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-08-21 20:48:45 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-08-22 10:40:59 +0200 |
commit | 68f2bfea619a454b5de1431689eb086cf13f5ceb (patch) | |
tree | 9c75b625e2aac6035aad2cdc9a51be863d26c59e | |
parent | b9e69223d02287f75c24c3f5be869a04979e5b17 (diff) |
Abstract resize handling by adding a new Htop reaction
-rw-r--r-- | Action.c | 5 | ||||
-rw-r--r-- | Action.h | 1 | ||||
-rw-r--r-- | MainPanel.c | 3 | ||||
-rw-r--r-- | Panel.h | 3 | ||||
-rw-r--r-- | ScreenManager.c | 4 |
5 files changed, 11 insertions, 5 deletions
@@ -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) { @@ -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; } @@ -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; |