mirror of
https://github.com/aristocratos/btop.git
synced 2026-02-07 12:52:21 -05:00
Merge pull request #1274 from irabrine/tree-children-toggle
This commit is contained in:
@@ -402,11 +402,12 @@ namespace Input {
|
||||
Config::set("show_detailed", false);
|
||||
}
|
||||
}
|
||||
else if (is_in(key, "+", "-", "space") and Config::getB("proc_tree") and Config::getI("proc_selected") > 0) {
|
||||
else if (is_in(key, "+", "-", "space", "u") and Config::getB("proc_tree") and Config::getI("proc_selected") > 0) {
|
||||
atomic_wait(Runner::active);
|
||||
auto& pid = Config::getI("selected_pid");
|
||||
if (key == "+" or key == "space") Proc::expand = pid;
|
||||
if (key == "-" or key == "space") Proc::collapse = pid;
|
||||
if (key == "u") Proc::toggle_children = pid;
|
||||
no_update = false;
|
||||
}
|
||||
else if (is_in(key, "t", kill_key) and (Config::getB("show_detailed") or Config::getI("selected_pid") > 0)) {
|
||||
|
||||
@@ -185,6 +185,7 @@ namespace Menu {
|
||||
{"Up, Down", "Select in process list."},
|
||||
{"Enter", "Show detailed information for selected process."},
|
||||
{"Spacebar", "Expand/collapse the selected process in tree view."},
|
||||
{"u", "Expand/collapse the selected process' children."},
|
||||
{"Pg Up, Pg Down", "Jump 1 page in process list."},
|
||||
{"Home, End", "Jump to first or last page in process list."},
|
||||
{"Left, Right", "Select previous/next sorting column."},
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace Proc {
|
||||
extern bool shown, redraw;
|
||||
extern int select_max;
|
||||
extern atomic<int> detailed_pid;
|
||||
extern int selected_pid, start, selected, collapse, expand, filter_found, selected_depth;
|
||||
extern int selected_pid, start, selected, collapse, expand, filter_found, selected_depth, toggle_children;
|
||||
extern string selected_name;
|
||||
|
||||
//? Contains the valid sorting options for processes
|
||||
|
||||
@@ -1002,7 +1002,7 @@ namespace Proc {
|
||||
fs::file_time_type passwd_time;
|
||||
|
||||
uint64_t cputimes;
|
||||
int collapse = -1, expand = -1;
|
||||
int collapse = -1, expand = -1, toggle_children = -1;
|
||||
uint64_t old_cputimes = 0;
|
||||
atomic<int> numpids = 0;
|
||||
int filter_found = 0;
|
||||
@@ -1229,6 +1229,23 @@ namespace Proc {
|
||||
//* Generate tree view if enabled
|
||||
if (tree and (not no_update or should_filter or sorted_change)) {
|
||||
bool locate_selection = false;
|
||||
|
||||
if (toggle_children != -1) {
|
||||
auto collapser = rng::find(current_procs, toggle_children, &proc_info::pid);
|
||||
if (collapser != current_procs.end()){
|
||||
for (auto& p : current_procs) {
|
||||
if (p.ppid == collapser->pid) {
|
||||
auto child = rng::find(current_procs, p.pid, &proc_info::pid);
|
||||
if (child != current_procs.end()){
|
||||
child->collapsed = not child->collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Config::ints.at("proc_selected") > 0) locate_selection = true;
|
||||
}
|
||||
toggle_children = -1;
|
||||
}
|
||||
|
||||
if (auto find_pid = (collapse != -1 ? collapse : expand); find_pid != -1) {
|
||||
auto collapser = rng::find(current_procs, find_pid, &proc_info::pid);
|
||||
if (collapser != current_procs.end()) {
|
||||
|
||||
@@ -2735,7 +2735,7 @@ namespace Proc {
|
||||
fs::file_time_type passwd_time;
|
||||
|
||||
uint64_t cputimes;
|
||||
int collapse = -1, expand = -1;
|
||||
int collapse = -1, expand = -1, toggle_children = -1;
|
||||
uint64_t old_cputimes{};
|
||||
atomic<int> numpids{};
|
||||
int filter_found{};
|
||||
@@ -3147,6 +3147,23 @@ namespace Proc {
|
||||
//* Generate tree view if enabled
|
||||
if (tree and (not no_update or should_filter or sorted_change)) {
|
||||
bool locate_selection = false;
|
||||
|
||||
if (toggle_children != -1) {
|
||||
auto collapser = rng::find(current_procs, toggle_children, &proc_info::pid);
|
||||
if (collapser != current_procs.end()){
|
||||
for (auto& p : current_procs) {
|
||||
if (p.ppid == collapser->pid) {
|
||||
auto child = rng::find(current_procs, p.pid, &proc_info::pid);
|
||||
if (child != current_procs.end()){
|
||||
child->collapsed = not child->collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Config::ints.at("proc_selected") > 0) locate_selection = true;
|
||||
}
|
||||
toggle_children = -1;
|
||||
}
|
||||
|
||||
if (auto find_pid = (collapse != -1 ? collapse : expand); find_pid != -1) {
|
||||
auto collapser = rng::find(current_procs, find_pid, &proc_info::pid);
|
||||
if (collapser != current_procs.end()) {
|
||||
|
||||
@@ -1097,7 +1097,7 @@ namespace Proc {
|
||||
fs::file_time_type passwd_time;
|
||||
|
||||
uint64_t cputimes;
|
||||
int collapse = -1, expand = -1;
|
||||
int collapse = -1, expand = -1, toggle_children = -1;
|
||||
uint64_t old_cputimes = 0;
|
||||
atomic<int> numpids = 0;
|
||||
int filter_found = 0;
|
||||
|
||||
@@ -960,7 +960,7 @@ namespace Proc {
|
||||
fs::file_time_type passwd_time;
|
||||
|
||||
uint64_t cputimes;
|
||||
int collapse = -1, expand = -1;
|
||||
int collapse = -1, expand = -1, toggle_children = -1;
|
||||
uint64_t old_cputimes = 0;
|
||||
atomic<int> numpids = 0;
|
||||
int filter_found = 0;
|
||||
@@ -1167,6 +1167,23 @@ namespace Proc {
|
||||
//* Generate tree view if enabled
|
||||
if (tree and (not no_update or should_filter or sorted_change)) {
|
||||
bool locate_selection = false;
|
||||
|
||||
if (toggle_children != -1) {
|
||||
auto collapser = rng::find(current_procs, toggle_children, &proc_info::pid);
|
||||
if (collapser != current_procs.end()){
|
||||
for (auto& p : current_procs) {
|
||||
if (p.ppid == collapser->pid) {
|
||||
auto child = rng::find(current_procs, p.pid, &proc_info::pid);
|
||||
if (child != current_procs.end()){
|
||||
child->collapsed = not child->collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Config::ints.at("proc_selected") > 0) locate_selection = true;
|
||||
}
|
||||
toggle_children = -1;
|
||||
}
|
||||
|
||||
if (auto find_pid = (collapse != -1 ? collapse : expand); find_pid != -1) {
|
||||
auto collapser = rng::find(current_procs, find_pid, &proc_info::pid);
|
||||
if (collapser != current_procs.end()) {
|
||||
|
||||
@@ -1038,7 +1038,7 @@ namespace Proc {
|
||||
fs::file_time_type passwd_time;
|
||||
|
||||
uint64_t cputimes;
|
||||
int collapse = -1, expand = -1;
|
||||
int collapse = -1, expand = -1, toggle_children = -1;
|
||||
uint64_t old_cputimes = 0;
|
||||
atomic<int> numpids = 0;
|
||||
int filter_found = 0;
|
||||
@@ -1303,6 +1303,23 @@ namespace Proc {
|
||||
//* Generate tree view if enabled
|
||||
if (tree and (not no_update or should_filter or sorted_change)) {
|
||||
bool locate_selection = false;
|
||||
|
||||
if (toggle_children != -1) {
|
||||
auto collapser = rng::find(current_procs, toggle_children, &proc_info::pid);
|
||||
if (collapser != current_procs.end()){
|
||||
for (auto& p : current_procs) {
|
||||
if (p.ppid == collapser->pid) {
|
||||
auto child = rng::find(current_procs, p.pid, &proc_info::pid);
|
||||
if (child != current_procs.end()){
|
||||
child->collapsed = not child->collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Config::ints.at("proc_selected") > 0) locate_selection = true;
|
||||
}
|
||||
toggle_children = -1;
|
||||
}
|
||||
|
||||
if (auto find_pid = (collapse != -1 ? collapse : expand); find_pid != -1) {
|
||||
auto collapser = rng::find(current_procs, find_pid, &proc_info::pid);
|
||||
if (collapser != current_procs.end()) {
|
||||
|
||||
Reference in New Issue
Block a user