summaryrefslogtreecommitdiffstats
path: root/src/btop_input.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/btop_input.cpp')
-rw-r--r--src/btop_input.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/btop_input.cpp b/src/btop_input.cpp
index 21aff58..fb9e46d 100644
--- a/src/btop_input.cpp
+++ b/src/btop_input.cpp
@@ -22,6 +22,15 @@ tab-size = 4
#include <thread>
#include <mutex>
#include <signal.h>
+#include <utility>
+
+#include "btop_input.hpp"
+#include "btop_tools.hpp"
+#include "btop_config.hpp"
+#include "btop_shared.hpp"
+#include "btop_menu.hpp"
+#include "btop_draw.hpp"
+
#include "btop_input.hpp"
#include "btop_tools.hpp"
@@ -40,7 +49,7 @@ namespace rng = std::ranges;
namespace Input {
//* Map for translating key codes to readable values
- const unordered_flat_map<string, string> Key_escapes = {
+ const std::unordered_map<string, string> Key_escapes = {
{"\033", "escape"},
{"\n", "enter"},
{" ", "space"},
@@ -55,9 +64,13 @@ namespace Input {
{"[C", "right"},
{"OC", "right"},
{"[2~", "insert"},
+ {"[4h", "insert"},
{"[3~", "delete"},
+ {"[P", "delete"},
{"[H", "home"},
+ {"[1~", "home"},
{"[F", "end"},
+ {"[4~", "end"},
{"[5~", "page_up"},
{"[6~", "page_down"},
{"\t", "tab"},
@@ -79,7 +92,7 @@ namespace Input {
std::atomic<bool> interrupt (false);
std::atomic<bool> polling (false);
array<int, 2> mouse_pos;
- unordered_flat_map<string, Mouse_loc> mouse_mappings;
+ std::unordered_map<string, Mouse_loc> mouse_mappings;
deque<string> history(50, "");
string old_filter;
@@ -260,11 +273,21 @@ namespace Input {
Menu::show(Menu::Menus::Options);
return;
}
- else if (is_in(key, "1", "2", "3", "4")) {
+ else if (key.size() == 1 and isint(key)) {
+ auto intKey = stoi(key);
+ #ifdef GPU_SUPPORT
+ static const array<string, 10> boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
+ if ((intKey == 0 and Gpu::gpu_names.size() < 5) or (intKey >= 5 and std::cmp_less(Gpu::gpu_names.size(), intKey - 4)))
+ return;
+ #else
+ static const array<string, 10> boxes = {"", "cpu", "mem", "net", "proc"};
+ if (intKey == 0 or intKey > 4)
+ return;
+ #endif
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));
+
+ Config::toggle_box(boxes.at(intKey));
Draw::calcSizes();
Runner::run("all", false, true);
return;