This commit is contained in:
Miguel Diaz 2023-11-19 11:55:42 -07:00 committed by GitHub
commit eda69bd60e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View file

@ -524,6 +524,12 @@ namespace Config {
return true;
}
void maximize_box(const string& box) {
current_boxes.clear();
current_boxes.push_back(box);
Config::set("shown_boxes", box);
}
void toggle_box(const string& box) {
auto old_boxes = current_boxes;
auto box_pos = rng::find(current_boxes, box);

View file

@ -57,6 +57,9 @@ namespace Config {
//* Toggle box and update config string shown_boxes
void toggle_box(const string& box);
//* Maximize box and update config string shown_boxes
void maximize_box(const string& box);
//* Parse and setup config value presets
bool presetsValid(const string& presets);

View file

@ -22,6 +22,7 @@ tab-size = 4
#include <thread>
#include <mutex>
#include <signal.h>
#include <ctype.h>
#include "btop_input.hpp"
#include "btop_tools.hpp"
@ -264,11 +265,21 @@ namespace Input {
Menu::show(Menu::Menus::Options);
return;
}
else if (is_in(key, "1", "2", "3", "4")) {
else if (is_in(key, "1", "2", "3", "4", "!", "@", "#", "$")) {
atomic_wait(Runner::active);
Config::current_preset = -1;
static const array<string, 4> boxes = {"cpu", "mem", "net", "proc"};
Config::toggle_box(boxes.at(std::stoi(key) - 1));
if (std::isdigit(key[0]))
Config::toggle_box(boxes.at(std::stoi(key) - 1));
else {
static const unordered_flat_map<string, string> binding = {
{"!", boxes.at(0)},
{"@", boxes.at(1)},
{"#", boxes.at(2)},
{"$", boxes.at(3)},
};
Config::maximize_box(binding.at(key));
}
Draw::calcSizes();
Runner::run("all", false, true);
return;