mirror of
https://github.com/aristocratos/btop.git
synced 2024-05-18 11:22:46 +12:00
Add ctrl+u/d/b/f vim keys (#582)
Ctrl+u/d = fast scroll up/down Ctrl+b/f = page up/down
This commit is contained in:
parent
b2df50396b
commit
ec641d4de2
|
@ -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."},
|
||||
|
|
|
@ -1501,11 +1501,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));
|
||||
}
|
||||
|
@ -1517,6 +1517,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));
|
||||
|
|
|
@ -65,6 +65,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"},
|
||||
|
@ -407,7 +411,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");
|
||||
|
|
|
@ -246,6 +246,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)",
|
||||
|
|
Loading…
Reference in a new issue