This commit is contained in:
isak102 2024-04-30 17:22:11 +02:00 committed by GitHub
commit 7e60777078
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 4 deletions

View file

@ -63,7 +63,7 @@ namespace Config {
"#* Use whitespace \" \" as separator between different presets.\n"
"#* Example: \"cpu:0:default,mem:0:tty,proc:1:default cpu:0:braille,proc:0:tty\""},
{"vim_keys", "#* Set to True to enable \"h,j,k,l,g,G\" keys for directional control in lists.\n"
{"vim_keys", "#* Set to True to enable \"h,j,k,l,g,G,ctrl+u/d/b/f\" keys for directional control in lists.\n"
"#* Conflicting keys for h:\"help\" and k:\"kill\" is accessible while holding shift."},
{"rounded_corners", "#* Rounded corners on boxes, is ignored if TTY mode is ON."},

View file

@ -1505,11 +1505,11 @@ namespace Proc {
}
else selected++;
}
else if (cmd_key == "page_up") {
else if (cmd_key == "page_up" or (vim_keys and cmd_key == "ctrl+b")) {
if (selected > 0 and start == 0) selected = 0;
else start = max(0, start - select_max);
}
else if (cmd_key == "page_down") {
else if (cmd_key == "page_down" or (vim_keys and cmd_key == "ctrl+f")) {
if (selected > 0 and start >= numpids - select_max) selected = select_max;
else start = clamp(start + select_max, 0, max(0, numpids - select_max));
}
@ -1521,6 +1521,21 @@ namespace Proc {
start = max(0, numpids - select_max);
if (selected > 0) selected = select_max;
}
else if (vim_keys and cmd_key == "ctrl+u") {
if (start > 0 and selected <= 10) {
start = max(0, start - 10);
}
else selected = max(0, selected - 10);
if (Config::getI("proc_last_selected") > 0) Config::set("proc_last_selected", 0);
}
else if (vim_keys and cmd_key == "ctrl+d") {
if (start < numpids - select_max and selected == select_max) start += 10;
else if (selected == 0 and last_selected > 0) {
selected = last_selected;
Config::set("proc_last_selected", 0);
}
else selected += 10;
}
else if (cmd_key.starts_with("mousey")) {
int mouse_y = std::stoi(cmd_key.substr(6));
start = clamp((int)round((double)mouse_y * (numpids - select_max - 2) / (select_max - 2)), 0, max(0, numpids - select_max));

View file

@ -66,6 +66,10 @@ namespace Input {
{"[6~", "page_down"},
{"\t", "tab"},
{"[Z", "shift_tab"},
{"\x15", "ctrl+u"},
{"\x04", "ctrl+d"},
{"\x06", "ctrl+f"},
{"\x02", "ctrl+b"},
{"OP", "f1"},
{"OQ", "f2"},
{"OR", "f3"},
@ -410,7 +414,7 @@ namespace Input {
Menu::show(Menu::Menus::SignalChoose);
return;
}
else if (is_in(key, "up", "down", "page_up", "page_down", "home", "end") or (vim_keys and is_in(key, "j", "k", "g", "G"))) {
else if (is_in(key, "up", "down", "page_up", "page_down", "home", "end") or (vim_keys and is_in(key, "j", "k", "g", "G", "ctrl+d", "ctrl+u", "ctrl+f", "ctrl+b"))) {
proc_mouse_scroll:
redraw = false;
auto old_selected = Config::getI("proc_selected");

View file

@ -247,6 +247,8 @@ namespace Menu {
"Enable vim keys.",
"Set to True to enable \"h,j,k,l\" keys for",
"directional control in lists.",
"Also enables ctrl + u/d for quicker scrolling",
"and ctrl + b/f for page up/down.",
"",
"Conflicting keys for",
"h (help) and k (kill)",