mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-02 02:24:54 +12:00
Restore box layout from a maximized box
This commit is contained in:
parent
4576b15315
commit
e823ff0e2b
|
@ -266,6 +266,7 @@ namespace Config {
|
|||
{"lowcolor", false},
|
||||
{"show_detailed", false},
|
||||
{"proc_filtering", false},
|
||||
{"is_maximized", false},
|
||||
};
|
||||
unordered_flat_map<string, bool> boolsTmp;
|
||||
|
||||
|
@ -519,10 +520,18 @@ namespace Config {
|
|||
return true;
|
||||
}
|
||||
|
||||
void restore(const string& boxes) {
|
||||
current_boxes.clear();
|
||||
current_boxes = ssplit(boxes);
|
||||
Config::set("shown_boxes", boxes);
|
||||
Config::set("is_maximized", false);
|
||||
}
|
||||
|
||||
void maximize_box(const string& box) {
|
||||
current_boxes.clear();
|
||||
current_boxes.push_back(box);
|
||||
Config::set("shown_boxes", box);
|
||||
Config::set("is_maximized", true);
|
||||
}
|
||||
|
||||
void toggle_box(const string& box) {
|
||||
|
@ -547,6 +556,7 @@ namespace Config {
|
|||
}
|
||||
|
||||
Config::set("shown_boxes", new_boxes);
|
||||
ssplit(new_boxes).size() == 1 ? Config::set("is_maximized", true) : Config::set("is_maximized", false);
|
||||
}
|
||||
|
||||
void load(const fs::path& conf_file, vector<string>& load_warnings) {
|
||||
|
|
|
@ -59,6 +59,9 @@ namespace Config {
|
|||
//* Maximize box and update config string shown_boxes
|
||||
void maximize_box(const string& box);
|
||||
|
||||
//* Restore boxes and update config string shown_boxes
|
||||
void restore(const string& boxes);
|
||||
|
||||
//* Parse and setup config value presets
|
||||
bool presetsValid(const string& presets);
|
||||
|
||||
|
|
|
@ -274,7 +274,15 @@ namespace Input {
|
|||
{"#", boxes.at(2)},
|
||||
{"$", boxes.at(3)},
|
||||
};
|
||||
Config::maximize_box(binding.at(key));
|
||||
if (Config::getB("is_maximized") && Config::getS("shown_boxes") == binding.at(key)) {
|
||||
string str_boxes;
|
||||
for (const auto& b : boxes) str_boxes += b + ' ';
|
||||
str_boxes.pop_back();
|
||||
|
||||
Config::restore(str_boxes);
|
||||
}
|
||||
else
|
||||
Config::maximize_box(binding.at(key));
|
||||
}
|
||||
Draw::calcSizes();
|
||||
Runner::run("all", false, true);
|
||||
|
|
Loading…
Reference in a new issue