aboutsummaryrefslogtreecommitdiffstats
path: root/Action.c
diff options
context:
space:
mode:
Diffstat (limited to 'Action.c')
-rw-r--r--Action.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/Action.c b/Action.c
index a6394ac..518d103 100644
--- a/Action.c
+++ b/Action.c
@@ -115,7 +115,7 @@ static void Action_runSetup(Settings* settings, const Header* header, ProcessLis
static bool changePriority(MainPanel* panel, int delta) {
bool anyTagged;
- bool ok = MainPanel_foreachProcess(panel, (MainPanel_ForeachProcessFn) Process_changePriorityBy, delta, &anyTagged);
+ bool ok = MainPanel_foreachProcess(panel, (MainPanel_ForeachProcessFn) Process_changePriorityBy, (Arg){ .i = delta }, &anyTagged);
if (!ok)
beep();
return anyTagged;
@@ -155,6 +155,21 @@ static bool expandCollapse(Panel* panel) {
return true;
}
+static bool collapseIntoParent(Panel* panel) {
+ Process* p = (Process*) Panel_getSelected(panel);
+ if (!p) return false;
+ pid_t ppid = Process_getParentPid(p);
+ for (int i = 0; i < Panel_size(panel); i++) {
+ Process* q = (Process*) Panel_get(panel, i);
+ if (q->pid == ppid) {
+ q->showChildren = false;
+ Panel_setSelected(panel, i);
+ return true;
+ }
+ }
+ return false;
+}
+
Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey) {
settings->sortKey = sortKey;
settings->direction = 1;
@@ -185,6 +200,7 @@ static Htop_Reaction sortBy(State* st) {
// ----------------------------------------
static Htop_Reaction actionResize(State* st) {
+ clear();
Panel_resize(st->panel, COLS, LINES-(st->panel->y)-1);
return HTOP_REDRAW_BAR;
}
@@ -260,6 +276,14 @@ static Htop_Reaction actionExpandOrCollapse(State* st) {
return changed ? HTOP_RECALCULATE : HTOP_OK;
}
+static Htop_Reaction actionCollapseIntoParent(State* st) {
+ if (!st->settings->treeView) {
+ return HTOP_OK;
+ }
+ bool changed = collapseIntoParent(st->panel);
+ return changed ? HTOP_RECALCULATE : HTOP_OK;
+}
+
static Htop_Reaction actionExpandCollapseOrSortColumn(State* st) {
return st->settings->treeView ? actionExpandOrCollapse(st) : actionSetSortColumn(st);
}
@@ -284,7 +308,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
void* set = Action_pickFromVector(st, affinityPanel, 15);
if (set) {
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
- bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (size_t) affinity, NULL);
+ bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL);
if (!ok) beep();
Affinity_delete(affinity);
}
@@ -301,7 +325,7 @@ static Htop_Reaction actionKill(State* st) {
Panel_setHeader(st->panel, "Sending...");
Panel_draw(st->panel, true);
refresh();
- MainPanel_foreachProcess((MainPanel*)st->panel, (MainPanel_ForeachProcessFn) Process_sendSignal, (size_t) sgn->key, NULL);
+ MainPanel_foreachProcess((MainPanel*)st->panel, (MainPanel_ForeachProcessFn) Process_sendSignal, (Arg){ .i = sgn->key }, NULL);
napms(500);
}
}
@@ -556,6 +580,7 @@ void Action_setBindings(Htop_Action* keys) {
keys['+'] = actionExpandOrCollapse;
keys['='] = actionExpandOrCollapse;
keys['-'] = actionExpandOrCollapse;
+ keys['\177'] = actionCollapseIntoParent;
keys['u'] = actionFilterByUser;
keys['F'] = Action_follow;
keys['S'] = actionSetup;

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