mirror of
https://github.com/aristocratos/btop.git
synced 2024-06-29 11:30:44 +12:00
Add key bindings that maximize a box
This commit is contained in:
parent
1b126f55e3
commit
4576b15315
|
@ -519,6 +519,12 @@ namespace Config {
|
||||||
return true;
|
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) {
|
void toggle_box(const string& box) {
|
||||||
auto old_boxes = current_boxes;
|
auto old_boxes = current_boxes;
|
||||||
auto box_pos = rng::find(current_boxes, box);
|
auto box_pos = rng::find(current_boxes, box);
|
||||||
|
|
|
@ -56,6 +56,9 @@ namespace Config {
|
||||||
//* Toggle box and update config string shown_boxes
|
//* Toggle box and update config string shown_boxes
|
||||||
void toggle_box(const string& box);
|
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
|
//* Parse and setup config value presets
|
||||||
bool presetsValid(const string& presets);
|
bool presetsValid(const string& presets);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ tab-size = 4
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "btop_input.hpp"
|
#include "btop_input.hpp"
|
||||||
#include "btop_tools.hpp"
|
#include "btop_tools.hpp"
|
||||||
|
@ -260,11 +261,21 @@ namespace Input {
|
||||||
Menu::show(Menu::Menus::Options);
|
Menu::show(Menu::Menus::Options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (is_in(key, "1", "2", "3", "4")) {
|
else if (is_in(key, "1", "2", "3", "4", "!", "@", "#", "$")) {
|
||||||
atomic_wait(Runner::active);
|
atomic_wait(Runner::active);
|
||||||
Config::current_preset = -1;
|
Config::current_preset = -1;
|
||||||
static const array<string, 4> boxes = {"cpu", "mem", "net", "proc"};
|
static const array<string, 4> boxes = {"cpu", "mem", "net", "proc"};
|
||||||
|
if (std::isdigit(key[0]))
|
||||||
Config::toggle_box(boxes.at(std::stoi(key) - 1));
|
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();
|
Draw::calcSizes();
|
||||||
Runner::run("all", false, true);
|
Runner::run("all", false, true);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue