[htop-general] Bash/Emacs-compatible Navigation Keys
Brought to you by:
loderunner
From: Daniel S. <dbs...@gm...> - 2009-10-21 04:18:32
|
Hello, I found it useful to add Ctrl-[NPFB] keys like Bash or Emacs use for navigation. What do you think? Daniel Schuler Index: CategoriesPanel.c =================================================================== --- CategoriesPanel.c (revision 167) +++ CategoriesPanel.c (working copy) @@ -79,7 +79,9 @@ result = HANDLED; break; case KEY_UP: + case KEY_CTRLP: case KEY_DOWN: + case KEY_CTRLN: case KEY_NPAGE: case KEY_PPAGE: case KEY_HOME: Index: Panel.c =================================================================== --- Panel.c (revision 167) +++ Panel.c (working copy) @@ -64,6 +64,10 @@ #define PANEL_CLASS NULL #endif +#define KEY_CTRLN 0016 /* control-n key */ +#define KEY_CTRLP 0020 /* control-p key */ +#define KEY_CTRLF 0006 /* control-f key */ +#define KEY_CTRLB 0002 /* control-b key */ Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner, Object_Compare compare) { Panel* this; @@ -330,10 +334,12 @@ assert (this != NULL); switch (key) { case KEY_DOWN: + case KEY_CTRLN: if (this->selected + 1 < Vector_size(this->items)) this->selected++; return true; case KEY_UP: + case KEY_CTRLP: if (this->selected > 0) this->selected--; return true; @@ -360,12 +366,14 @@ return true; #endif case KEY_LEFT: + case KEY_CTRLB: if (this->scrollH > 0) { this->scrollH -= 5; this->needsRedraw = true; } return true; case KEY_RIGHT: + case KEY_CTRLF: this->scrollH += 5; this->needsRedraw = true; return true; Index: ScreenManager.c =================================================================== --- ScreenManager.c (revision 167) +++ ScreenManager.c (working copy) @@ -184,6 +184,7 @@ continue; } case KEY_LEFT: + case KEY_CTRLB: tryLeft: if (focus > 0) focus--; @@ -192,6 +193,7 @@ goto tryLeft; break; case KEY_RIGHT: + case KEY_CTRLF: case 9: tryRight: if (focus < this->itemCount - 1) |