mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-28 06:11:28 +02:00
Improve 0-10 key input
This commit is contained in:
parent
972b2b6a01
commit
3a5e5fd5d3
@ -187,7 +187,7 @@ void term_resize(bool force) {
|
|||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
static const array<string, 5> all_boxes = {"cpu", "mem", "net", "proc", "gpu"};
|
static const array<string, 10> all_boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
|
||||||
Global::resized = true;
|
Global::resized = true;
|
||||||
if (Runner::active) Runner::stop();
|
if (Runner::active) Runner::stop();
|
||||||
Term::refresh();
|
Term::refresh();
|
||||||
@ -225,9 +225,11 @@ void term_resize(bool force) {
|
|||||||
auto key = Input::get();
|
auto key = Input::get();
|
||||||
if (key == "q")
|
if (key == "q")
|
||||||
clean_quit(0);
|
clean_quit(0);
|
||||||
else if (is_in(key, "1", "2", "3", "4")) {
|
else if (std::isdigit(*key.c_str())) {
|
||||||
Config::current_preset = -1;
|
Config::current_preset = -1;
|
||||||
Config::toggle_box(all_boxes.at(std::stoi(key) - 1));
|
auto box = all_boxes.at(*key.c_str() - '0');
|
||||||
|
if (box.rfind("gpu", 0) == 0 && (box[3] - '0' + 2) > (int)Gpu::gpu_names.size()) return;
|
||||||
|
Config::toggle_box(box);
|
||||||
boxes = Config::getS("shown_boxes");
|
boxes = Config::getS("shown_boxes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,21 +260,13 @@ 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 (std::isdigit(*key.c_str())) {
|
||||||
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, 10> boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
|
||||||
Config::toggle_box(boxes.at(std::stoi(key) - 1));
|
auto box = boxes.at(*key.c_str() - '0');
|
||||||
Draw::calcSizes();
|
if (box.rfind("gpu", 0) == 0 && (box[3] - '0' + 2) > (int)Gpu::gpu_names.size()) return;
|
||||||
Runner::run("all", false, true);
|
Config::toggle_box(box);
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (is_in(key, "5", "6", "7", "8", "9", "0")) {
|
|
||||||
atomic_wait(Runner::active);
|
|
||||||
Config::current_preset = -1;
|
|
||||||
auto key_i = key == "0" ? 10 : std::stoi(key);
|
|
||||||
if (std::cmp_greater(key_i-3, Gpu::gpu_names.size())) return;
|
|
||||||
Config::toggle_box(std::string("gpu") + (char)(key_i-5 + '0'));
|
|
||||||
Draw::calcSizes();
|
Draw::calcSizes();
|
||||||
Runner::run("all", false, true);
|
Runner::run("all", false, true);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user