diff options
author | Daniel Lange <DLange@git.local> | 2021-02-12 18:48:09 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2021-02-13 16:47:04 +0100 |
commit | 2c6222e30a25a833e8554709818e1c378ca46848 (patch) | |
tree | 676239606f4fbc2fd6c11bf2b675edd9bd1cbdc1 /Action.c | |
parent | c44b2ec795d243126fd5a53169ec533f4a5b3bd0 (diff) |
Option and key ("*") to collapse / expand all branches under PID 1
(and PID 2 if kernel threads are shown)
Based on hishamhm/htop#510 by Krishna Chaitanya, B
Closes #68
Diffstat (limited to 'Action.c')
-rw-r--r-- | Action.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -227,10 +227,19 @@ static Htop_Reaction actionToggleMergedCommand(State* st) { static Htop_Reaction actionToggleTreeView(State* st) { st->settings->treeView = !st->settings->treeView; - ProcessList_expandTree(st->pl); + if (!st->settings->allBranchesCollapsed) ProcessList_expandTree(st->pl); return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR; } +static Htop_Reaction actionExpandOrCollapseAllBranches(State* st) { + st->settings->allBranchesCollapsed = !st->settings->allBranchesCollapsed; + if (st->settings->allBranchesCollapsed) + ProcessList_collapseAllBranches(st->pl); + else + ProcessList_expandTree(st->pl); + return HTOP_REFRESH | HTOP_SAVE_SETTINGS; +} + static Htop_Reaction actionIncFilter(State* st) { IncSet* inc = (st->mainPanel)->inc; IncSet_activate(inc, INC_FILTER, (Panel*)st->mainPanel); @@ -438,7 +447,7 @@ static const struct { { .key = " H: ", .info = "hide/show user process threads" }, { .key = " K: ", .info = "hide/show kernel threads" }, { .key = " F: ", .info = "cursor follows process" }, - { .key = " + -: ", .info = "expand/collapse tree" }, + { .key = " + - *: ", .info = "expand/collapse tree (* = toggle all)" }, { .key = "N P M T: ", .info = "sort by PID, CPU%, MEM% or TIME" }, { .key = " I: ", .info = "invert sort order" }, { .key = " F6 > .: ", .info = "select sort column" }, @@ -621,6 +630,7 @@ static Htop_Reaction actionShowCommandScreen(State* st) { void Action_setBindings(Htop_Action* keys) { keys[' '] = actionTag; + keys['*'] = actionExpandOrCollapseAllBranches; keys['+'] = actionExpandOrCollapse; keys[','] = actionSetSortColumn; keys['-'] = actionExpandOrCollapse; |