Last active
January 27, 2021 16:01
-
-
Save bbugyi200/c066a5b56819c629f41f8805804e5204 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Action.c b/Action.c | |
index 9a7c3c5..72229a1 100644 | |
--- a/Action.c | |
+++ b/Action.c | |
@@ -406,7 +406,7 @@ static Htop_Reaction actionRedraw() { | |
} | |
static const struct { const char* key; const char* info; } helpLeft[] = { | |
- { .key = " Arrows: ", .info = "scroll process list" }, | |
+ { .key = " hjkl: ", .info = "scroll process list" }, | |
{ .key = " Digits: ", .info = "incremental PID search" }, | |
{ .key = " F3 /: ", .info = "incremental name search" }, | |
{ .key = " F4 \\: ",.info = "incremental name filtering" }, | |
@@ -427,7 +427,7 @@ static const struct { const char* key; const char* info; } helpRight[] = { | |
{ .key = " Space: ", .info = "tag process" }, | |
{ .key = " c: ", .info = "tag process and its children" }, | |
{ .key = " U: ", .info = "untag all processes" }, | |
- { .key = " F9 k: ", .info = "kill process/tagged processes" }, | |
+ { .key = " F9 x: ", .info = "kill process/tagged processes" }, | |
{ .key = " F7 ]: ", .info = "higher priority (root only)" }, | |
{ .key = " F8 [: ", .info = "lower priority (+ nice)" }, | |
#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY) | |
@@ -435,11 +435,11 @@ static const struct { const char* key; const char* info; } helpRight[] = { | |
#endif | |
{ .key = " e: ", .info = "show process environment" }, | |
{ .key = " i: ", .info = "set IO priority" }, | |
- { .key = " l: ", .info = "list open files with lsof" }, | |
+ { .key = " L: ", .info = "list open files with lsof" }, | |
{ .key = " s: ", .info = "trace syscalls with strace" }, | |
{ .key = " ", .info = "" }, | |
{ .key = " F2 C S: ", .info = "setup" }, | |
- { .key = " F1 h: ", .info = "show this help screen" }, | |
+ { .key = " F1 ?: ", .info = "show this help screen" }, | |
{ .key = " F10 q: ", .info = "quit" }, | |
{ .key = NULL, .info = NULL } | |
}; | |
@@ -567,6 +567,7 @@ void Action_setBindings(Htop_Action* keys) { | |
keys['I'] = actionInvertSortOrder; | |
keys[KEY_F(6)] = actionExpandCollapseOrSortColumn; | |
keys[KEY_F(18)] = actionExpandCollapseOrSortColumn; | |
+ keys['o'] = actionExpandCollapseOrSortColumn; | |
keys['<'] = actionSetSortColumn; | |
keys[','] = actionSetSortColumn; | |
keys['>'] = actionSetSortColumn; | |
@@ -575,7 +576,7 @@ void Action_setBindings(Htop_Action* keys) { | |
keys['q'] = actionQuit; | |
keys['a'] = actionSetAffinity; | |
keys[KEY_F(9)] = actionKill; | |
- keys['k'] = actionKill; | |
+ keys['x'] = actionKill; | |
keys[KEY_RECLICK] = actionExpandOrCollapse; | |
keys['+'] = actionExpandOrCollapse; | |
keys['='] = actionExpandOrCollapse; | |
@@ -586,12 +587,11 @@ void Action_setBindings(Htop_Action* keys) { | |
keys['S'] = actionSetup; | |
keys['C'] = actionSetup; | |
keys[KEY_F(2)] = actionSetup; | |
- keys['l'] = actionLsof; | |
+ keys['L'] = actionLsof; | |
keys['s'] = actionStrace; | |
keys[' '] = actionTag; | |
keys['\014'] = actionRedraw; // Ctrl+L | |
keys[KEY_F(1)] = actionHelp; | |
- keys['h'] = actionHelp; | |
keys['?'] = actionHelp; | |
keys['U'] = actionUntagAll; | |
keys['c'] = actionTagAllChildren; | |
diff --git a/CategoriesPanel.c b/CategoriesPanel.c | |
index 437f1a7..9558a14 100644 | |
--- a/CategoriesPanel.c | |
+++ b/CategoriesPanel.c | |
@@ -76,6 +76,21 @@ static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) { | |
HandlerResult result = IGNORED; | |
+ switch(ch) { | |
+ case 'h': | |
+ ch = KEY_LEFT; | |
+ break; | |
+ case 'j': | |
+ ch = KEY_DOWN; | |
+ break; | |
+ case 'k': | |
+ ch = KEY_UP; | |
+ break; | |
+ case 'l': | |
+ ch = KEY_RIGHT; | |
+ break; | |
+ } | |
+ | |
int selected = Panel_getSelectedIndex(super); | |
switch (ch) { | |
case EVENT_SET_SELECTED: | |
diff --git a/ColumnsPanel.c b/ColumnsPanel.c | |
index 8974ffd..c956f38 100644 | |
--- a/ColumnsPanel.c | |
+++ b/ColumnsPanel.c | |
@@ -60,6 +60,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { | |
} | |
break; | |
} | |
+ case 'k': | |
case KEY_UP: | |
{ | |
if (!this->moving) { | |
@@ -76,6 +77,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { | |
result = HANDLED; | |
break; | |
} | |
+ case 'j': | |
case KEY_DOWN: | |
{ | |
if (!this->moving) { | |
diff --git a/MetersPanel.c b/MetersPanel.c | |
index 3cf3e07..554a1ee 100644 | |
--- a/MetersPanel.c | |
+++ b/MetersPanel.c | |
@@ -41,9 +41,9 @@ static int MetersEvents[] = {' ', 13, ERR, KEY_DC, KEY_F(10)}; | |
// terminals, breaking our aligning. | |
// In <http://unicode.org/reports/tr11/>, arrows (U+2019..U+2199) are | |
// considered "Ambiguous characters". | |
-static const char* const MetersMovingFunctions[] = {"Style ", "Lock ", "Up ", "Down ", "Left ", "Right ", " ", "Delete", "Done ", NULL}; | |
-static const char* const MetersMovingKeys[] = {"Space", "Enter", "Up", "Dn", "<-", "->", " ", "Del", "F10"}; | |
-static int MetersMovingEvents[] = {' ', 13, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, ERR, KEY_DC, KEY_F(10)}; | |
+static const char* const MetersMovingFunctions[] = {"Style ", "Lock ", "Up ", "Up ", "Down ", "Down ", "Left ", "Left ", "Right ", "Right ", " ", "Delete", "Done ", NULL}; | |
+static const char* const MetersMovingKeys[] = {"Space", "Enter", "Up", "k", "Dn", "j", "<-", "h", "->", "l", " ", "Del", "F10"}; | |
+static int MetersMovingEvents[] = {' ', 13, KEY_UP, KEY_UP, KEY_DOWN, KEY_DOWN, KEY_LEFT, KEY_LEFT, KEY_RIGHT, KEY_RIGHT, ERR, KEY_DC, KEY_F(10)}; | |
static FunctionBar* Meters_movingBar = NULL; | |
static void MetersPanel_delete(Object* object) { | |
@@ -156,6 +156,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) { | |
break; | |
} | |
case KEY_RIGHT: | |
+ case 'l': | |
{ | |
sideMove = moveToNeighbor(this, this->rightNeighbor, selected); | |
if (this->moving && !sideMove) { | |
@@ -167,6 +168,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) { | |
break; | |
} | |
case KEY_LEFT: | |
+ case 'h': | |
{ | |
sideMove = moveToNeighbor(this, this->leftNeighbor, selected); | |
if (this->moving && !sideMove) { | |
diff --git a/Panel.c b/Panel.c | |
index 1e53b4a..ba866db 100644 | |
--- a/Panel.c | |
+++ b/Panel.c | |
@@ -376,10 +376,12 @@ bool Panel_onKey(Panel* this, int key) { | |
int size = Vector_size(this->items); | |
switch (key) { | |
case KEY_DOWN: | |
+ case 'j': | |
case KEY_CTRL('N'): | |
this->selected++; | |
break; | |
case KEY_UP: | |
+ case 'k': | |
case KEY_CTRL('P'): | |
this->selected--; | |
break; | |
@@ -394,23 +396,33 @@ bool Panel_onKey(Panel* this, int key) { | |
break; | |
#endif | |
case KEY_LEFT: | |
- case KEY_CTRL('B'): | |
+ case 'h': | |
if (this->scrollH > 0) { | |
this->scrollH -= MAX(CRT_scrollHAmount, 0); | |
this->needsRedraw = true; | |
} | |
break; | |
case KEY_RIGHT: | |
- case KEY_CTRL('F'): | |
+ case 'l': | |
this->scrollH += CRT_scrollHAmount; | |
this->needsRedraw = true; | |
break; | |
+ case KEY_CTRL('U'): | |
+ this->selected -= (this->h - 1) / 2; | |
+ this->needsRedraw = true; | |
+ break; | |
+ case KEY_CTRL('D'): | |
+ this->selected += (this->h - 1) / 2; | |
+ this->needsRedraw = true; | |
+ break; | |
case KEY_PPAGE: | |
+ case KEY_CTRL('B'): | |
this->selected -= (this->h - 1); | |
this->scrollV = MAX(0, this->scrollV - this->h + 1); | |
this->needsRedraw = true; | |
break; | |
case KEY_NPAGE: | |
+ case KEY_CTRL('F'): | |
this->selected += (this->h - 1); | |
this->scrollV = MAX(0, MIN(Vector_size(this->items) - this->h, | |
this->scrollV + this->h - 1)); | |
@@ -432,9 +444,11 @@ bool Panel_onKey(Panel* this, int key) { | |
break; | |
} | |
case KEY_HOME: | |
+ case 'g': | |
this->selected = 0; | |
break; | |
case KEY_END: | |
+ case 'G': | |
this->selected = size - 1; | |
break; | |
case KEY_CTRL('A'): | |
@@ -469,6 +483,17 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) { | |
this->eventHandlerState = xCalloc(100, sizeof(char)); | |
char* buffer = this->eventHandlerState; | |
+ switch(ch) { | |
+ case 'h': | |
+ case 'j': | |
+ case 'k': | |
+ case 'l': | |
+ return (REDRAW | RESCAN); | |
+ case 'q': | |
+ return IGNORED; | |
+ break; | |
+ } | |
+ | |
if (ch > 0 && ch < 255 && isalnum(ch)) { | |
int len = strlen(buffer); | |
if (len < 99) { | |
diff --git a/ScreenManager.c b/ScreenManager.c | |
index 06e9019..37924b0 100644 | |
--- a/ScreenManager.c | |
+++ b/ScreenManager.c | |
@@ -263,6 +263,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { | |
rescan = true; | |
sortTimeout = 0; | |
} | |
+ | |
if (result & HANDLED) { | |
continue; | |
} else if (result & BREAK_LOOP) { | |
@@ -277,7 +278,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { | |
continue; | |
} | |
case KEY_LEFT: | |
- case KEY_CTRL('B'): | |
+ case 'h': | |
if (this->panelCount < 2) { | |
goto defaultHandler; | |
} | |
@@ -291,7 +292,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { | |
goto tryLeft; | |
break; | |
case KEY_RIGHT: | |
- case KEY_CTRL('F'): | |
+ case 'l': | |
case 9: | |
if (this->panelCount < 2) { | |
goto defaultHandler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment