From 2c6222e30a25a833e8554709818e1c378ca46848 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Fri, 12 Feb 2021 18:48:09 +0100 Subject: 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 --- ProcessList.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ProcessList.c') diff --git a/ProcessList.c b/ProcessList.c index 5e6e917b..dcfa05dc 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -494,6 +494,16 @@ void ProcessList_expandTree(ProcessList* this) { } } +void ProcessList_collapseAllBranches(ProcessList* this) { + int size = Vector_size(this->processes); + for (int i = 0; i < size; i++) { + Process* process = (Process*) Vector_get(this->processes, i); + // FreeBSD has pid 0 = kernel and pid 1 = init, so init has tree_depth = 1 + if (process->tree_depth > 0 && process->pid > 1) + process->showChildren = false; + } +} + void ProcessList_rebuildPanel(ProcessList* this) { const char* incFilter = this->incFilter; -- cgit v1.2.3