mirror of https://github.com/xzeldon/htop.git
Abstract resize handling by adding a new Htop reaction
This commit is contained in:
parent
b9e69223d0
commit
68f2bfea61
5
Action.c
5
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) {
|
||||
|
|
1
Action.h
1
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_;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
3
Panel.h
3
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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue