summaryrefslogtreecommitdiffstats
path: root/htop.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2011-12-01 12:31:57 +0000
committerHisham Muhammad <hisham@gobolinux.org>2011-12-01 12:31:57 +0000
commitbfd86a60cc1e9edd94c219e6e2018e00a672b7ff (patch)
tree649b7f7163e834bf2e7f40a6e0b4f94413408095 /htop.c
parentdfad0afb36df9ac104490454c6472625e3ecbe0c (diff)
Keep panel structure up-to-date as process list changes when headers are updated during the screen manager. Hopefully closes #3444533.
Diffstat (limited to 'htop.c')
-rw-r--r--htop.c67
1 files changed, 28 insertions, 39 deletions
diff --git a/htop.c b/htop.c
index ff58d20d..866b3fa3 100644
--- a/htop.c
+++ b/htop.c
@@ -199,6 +199,7 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha
if (!list->eventHandler)
Panel_setEventHandler(list, Panel_selectByTyping);
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, header, false);
+ scr->allowFocusChange = false;
ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1);
ScreenManager_add(scr, panel, NULL, -1);
Panel* panelFocus;
@@ -331,7 +332,6 @@ int main(int argc, char** argv) {
exit(1);
}
- Panel* panel;
int quit = 0;
int refreshTimeout = 0;
int resetRefreshTimeout = 5;
@@ -384,10 +384,11 @@ int main(int argc, char** argv) {
break;
}
-
CRT_init(settings->delay, settings->colorScheme);
+
+ Panel* panel = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false, NULL);
+ ProcessList_setPanel(pl, panel);
- panel = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false, NULL);
if (sortKey > 0) {
pl->sortKey = sortKey;
pl->treeView = false;
@@ -439,12 +440,6 @@ int main(int argc, char** argv) {
if (recalculate)
oldTime = newTime;
if (doRefresh) {
-
- int currPos = Panel_getSelectedIndex(panel);
- pid_t currPid = 0;
- int currScrollV = panel->scrollV;
- if (follow)
- currPid = ProcessList_get(pl, currPos)->pid;
if (recalculate || doRecalculate) {
ProcessList_scan(pl);
doRecalculate = false;
@@ -453,27 +448,7 @@ int main(int argc, char** argv) {
ProcessList_sort(pl);
refreshTimeout = 1;
}
- Panel_prune(panel);
- int size = ProcessList_size(pl);
- int idx = 0;
- for (int i = 0; i < size; i++) {
- bool hidden = false;
- Process* p = ProcessList_get(pl, i);
-
- if ( (!p->show)
- || (userOnly && (p->st_uid != userId))
- || (filtering && !(String_contains_i(p->comm, incFilter.buffer))) )
- hidden = true;
-
- if (!hidden) {
- Panel_set(panel, idx, (Object*)p);
- if ((!follow && idx == currPos) || (follow && p->pid == currPid)) {
- Panel_setSelected(panel, idx);
- panel->scrollV = currScrollV;
- }
- idx++;
- }
- }
+ ProcessList_rebuildPanel(pl, true, follow, userOnly, userId, filtering, incFilter.buffer);
}
doRefresh = true;
@@ -746,6 +721,19 @@ int main(int argc, char** argv) {
if (!killPanel) {
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
}
+ bool anyTagged = false;
+ pid_t selectedPid;
+ for (int i = 0; i < Panel_size(panel); i++) {
+ Process* p = (Process*) Panel_get(panel, i);
+ if (p->tag) {
+ anyTagged = true;
+ break;
+ }
+ }
+ if (!anyTagged) {
+ Process* p = (Process*) Panel_getSelected(panel);
+ selectedPid = p->pid;
+ }
SignalsPanel_reset((SignalsPanel*) killPanel);
const char* fuFunctions[] = {"Send ", "Cancel ", NULL};
ListItem* sgn = (ListItem*) pickFromVector(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar, header);
@@ -754,17 +742,18 @@ int main(int argc, char** argv) {
Panel_setHeader(panel, "Sending...");
Panel_draw(panel, true);
refresh();
- bool anyTagged = false;
- for (int i = 0; i < Panel_size(panel); i++) {
- Process* p = (Process*) Panel_get(panel, i);
- if (p->tag) {
- Process_sendSignal(p, sgn->key);
- anyTagged = true;
+ if (anyTagged) {
+ for (int i = 0; i < Panel_size(panel); i++) {
+ Process* p = (Process*) Panel_get(panel, i);
+ if (p->tag) {
+ Process_sendSignal(p, sgn->key);
+ anyTagged = true;
+ }
}
- }
- if (!anyTagged) {
+ } else {
Process* p = (Process*) Panel_getSelected(panel);
- Process_sendSignal(p, sgn->key);
+ if (p->pid == selectedPid)
+ Process_sendSignal(p, sgn->key);
}
napms(500);
}

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