summaryrefslogtreecommitdiffstats
path: root/Action.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-04-05 19:31:18 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-04-06 11:14:09 -0300
commitb9e0da92007a733357ce7a2893168b31a9665a9f (patch)
treea6d9f7ae81126616ba892411373ae16bdc52212b /Action.c
parent509303323f869c52084a98d1ee24b7344bef8aa7 (diff)
Collapse current subtree pressing Backspace
Diffstat (limited to 'Action.c')
-rw-r--r--Action.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Action.c b/Action.c
index dc830b57..f7d7d4da 100644
--- a/Action.c
+++ b/Action.c
@@ -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) {
ScreenSettings* ss = settings->ss;
ss->sortKey = sortKey;
@@ -264,6 +279,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->ss->treeView ? actionExpandOrCollapse(st) : actionSetSortColumn(st);
}
@@ -570,6 +593,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