aboutsummaryrefslogtreecommitdiffstats
path: root/ScreenManager.c
diff options
context:
space:
mode:
Diffstat (limited to 'ScreenManager.c')
-rw-r--r--ScreenManager.c58
1 files changed, 38 insertions, 20 deletions
diff --git a/ScreenManager.c b/ScreenManager.c
index 55cacd2..e7e82e1 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -12,19 +12,23 @@ in the source distribution for its full text.
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/time.h>
#include "CRT.h"
#include "FunctionBar.h"
+#include "Machine.h"
#include "Macros.h"
#include "Object.h"
#include "Platform.h"
-#include "ProcessList.h"
+#include "Process.h"
#include "ProvideCurses.h"
+#include "Settings.h"
+#include "Table.h"
#include "XUtils.h"
-ScreenManager* ScreenManager_new(Header* header, const Settings* settings, State* state, bool owner) {
+ScreenManager* ScreenManager_new(Header* header, Machine* host, State* state, bool owner) {
ScreenManager* this;
this = xMalloc(sizeof(ScreenManager));
this->x1 = 0;
@@ -34,7 +38,7 @@ ScreenManager* ScreenManager_new(Header* header, const Settings* settings, State
this->panels = Vector_new(Class(Panel), owner, DEFAULT_SIZE);
this->panelCount = 0;
this->header = header;
- this->settings = settings;
+ this->host = host;
this->state = state;
this->allowFocusChange = true;
return this;
@@ -116,12 +120,12 @@ void ScreenManager_resize(ScreenManager* this) {
}
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut, bool* force_redraw) {
- ProcessList* pl = this->header->pl;
+ Machine* host = this->host;
- Platform_gettime_realtime(&pl->realtime, &pl->realtimeMs);
- double newTime = ((double)pl->realtime.tv_sec * 10) + ((double)pl->realtime.tv_usec / 100000);
+ Platform_gettime_realtime(&host->realtime, &host->realtimeMs);
+ double newTime = ((double)host->realtime.tv_sec * 10) + ((double)host->realtime.tv_usec / 100000);
- *timedOut = (newTime - *oldTime > this->settings->delay);
+ *timedOut = (newTime - *oldTime > host->settings->delay);
*rescan |= *timedOut;
if (newTime < *oldTime) {
@@ -131,12 +135,15 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
if (*rescan) {
*oldTime = newTime;
int oldUidDigits = Process_uidDigits;
- if (!this->state->pauseProcessUpdate && (*sortTimeout == 0 || this->settings->ss->treeView)) {
- pl->needsSort = true;
+ if (!this->state->pauseUpdate && (*sortTimeout == 0 || host->settings->ss->treeView)) {
+ host->activeTable->needsSort = true;
*sortTimeout = 1;
}
- // scan processes first - some header values are calculated there
- ProcessList_scan(pl, this->state->pauseProcessUpdate);
+ // sample current values for system metrics and processes if not paused
+ Machine_scan(host);
+ if (!this->state->pauseUpdate)
+ Machine_scanTables(host);
+
// always update header, especially to avoid gaps in graph meters
Header_updateData(this->header);
// force redraw if the number of UID digits was changed
@@ -146,14 +153,14 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
*redraw = true;
}
if (*redraw) {
- ProcessList_rebuildPanel(pl);
+ Table_rebuildPanel(host->activeTable);
if (!this->state->hideMeters)
Header_draw(this->header);
}
*rescan = false;
}
-static inline bool drawTab(int* y, int* x, int l, const char* name, bool cur) {
+static inline bool drawTab(const int* y, int* x, int l, const char* name, bool cur) {
attrset(CRT_colors[cur ? SCREENS_CUR_BORDER : SCREENS_OTH_BORDER]);
mvaddch(*y, *x, '[');
(*x)++;
@@ -175,8 +182,9 @@ static inline bool drawTab(int* y, int* x, int l, const char* name, bool cur) {
}
static void ScreenManager_drawScreenTabs(ScreenManager* this) {
- ScreenSettings** screens = this->settings->screens;
- int cur = this->settings->ssIndex;
+ Settings* settings = this->host->settings;
+ ScreenSettings** screens = settings->screens;
+ int cur = settings->ssIndex;
int l = COLS;
Panel* panel = (Panel*) Vector_get(this->panels, 0);
int y = panel->y - 1;
@@ -188,7 +196,7 @@ static void ScreenManager_drawScreenTabs(ScreenManager* this) {
}
for (int s = 0; screens[s]; s++) {
- bool ok = drawTab(&y, &x, l, screens[s]->name, s == cur);
+ bool ok = drawTab(&y, &x, l, screens[s]->heading, s == cur);
if (!ok) {
break;
}
@@ -197,7 +205,8 @@ static void ScreenManager_drawScreenTabs(ScreenManager* this) {
}
static void ScreenManager_drawPanels(ScreenManager* this, int focus, bool force_redraw) {
- if (this->settings->screenTabs) {
+ Settings* settings = this->host->settings;
+ if (settings->screenTabs) {
ScreenManager_drawScreenTabs(this);
}
const int nPanels = this->panelCount;
@@ -206,7 +215,7 @@ static void ScreenManager_drawPanels(ScreenManager* this, int focus, bool force_
Panel_draw(panel,
force_redraw,
i == focus,
- panel != (Panel*)this->state->mainPanel || !this->state->hideProcessSelection,
+ panel != (Panel*)this->state->mainPanel || !this->state->hideSelection,
State_hideFunctionBar(this->state));
mvvline(panel->y, panel->x + panel->w, ' ', panel->h + (State_hideFunctionBar(this->state) ? 1 : 0));
}
@@ -217,6 +226,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, con
int focus = 0;
Panel* panelFocus = (Panel*) Vector_get(this->panels, focus);
+ Settings* settings = this->host->settings;
double oldTime = 0.0;
@@ -240,6 +250,12 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, con
if (redraw || force_redraw) {
ScreenManager_drawPanels(this, focus, force_redraw);
force_redraw = false;
+ if (this->host->iterationsRemaining != -1) {
+ if (!--this->host->iterationsRemaining) {
+ quit = true;
+ continue;
+ }
+ }
}
int prevCh = ch;
@@ -247,7 +263,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, con
HandlerResult result = IGNORED;
#ifdef HAVE_GETMOUSE
- if (ch == KEY_MOUSE && this->settings->enableMouse) {
+ if (ch == KEY_MOUSE && settings->enableMouse) {
ch = ERR;
MEVENT mevent;
int ok = getmouse(&mevent);
@@ -262,7 +278,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, con
if (mevent.y == panel->y) {
ch = EVENT_HEADER_CLICK(mevent.x - panel->x);
break;
- } else if (this->settings->screenTabs && mevent.y == panel->y - 1) {
+ } else if (settings->screenTabs && mevent.y == panel->y - 1) {
ch = EVENT_SCREEN_TAB_CLICK(mevent.x);
break;
} else if (mevent.y > panel->y && mevent.y <= panel->y + panel->h) {
@@ -305,12 +321,14 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, con
redraw = false;
continue;
}
+
switch (ch) {
case KEY_ALT('H'): ch = KEY_LEFT; break;
case KEY_ALT('J'): ch = KEY_DOWN; break;
case KEY_ALT('K'): ch = KEY_UP; break;
case KEY_ALT('L'): ch = KEY_RIGHT; break;
}
+
redraw = true;
if (Panel_eventHandlerFn(panelFocus)) {
result = Panel_eventHandler(panelFocus, ch);

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