* Add Bash/emacs style navigation keys

(thanks to Daniel Schuler)
This commit is contained in:
Hisham Muhammad 2010-03-03 21:13:33 +00:00
parent 282f16c4b8
commit b4a63409f5
5 changed files with 20 additions and 0 deletions

View File

@ -79,7 +79,9 @@ static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
result = HANDLED; result = HANDLED;
break; break;
case KEY_UP: case KEY_UP:
case KEY_CTRLP:
case KEY_DOWN: case KEY_DOWN:
case KEY_CTRLN:
case KEY_NPAGE: case KEY_NPAGE:
case KEY_PPAGE: case KEY_PPAGE:
case KEY_HOME: case KEY_HOME:

View File

@ -7,6 +7,10 @@ What's new in version 0.8.4
(thanks to Tom Callaway) (thanks to Tom Callaway)
* getopt-based long options and --no-color * getopt-based long options and --no-color
(thanks to Vincent Launchbury) (thanks to Vincent Launchbury)
* BUGFIX: Fix memory leak
(thanks to Pavol Rusnak)
* Add Bash/emacs style navigation keys
(thanks to Daniel Schuler)
What's new in version 0.8.3 What's new in version 0.8.3

View File

@ -64,6 +64,10 @@ char* PANEL_CLASS = "Panel";
#define PANEL_CLASS NULL #define PANEL_CLASS NULL
#endif #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* Panel_new(int x, int y, int w, int h, char* type, bool owner, Object_Compare compare) {
Panel* this; Panel* this;
@ -330,10 +334,12 @@ bool Panel_onKey(Panel* this, int key) {
assert (this != NULL); assert (this != NULL);
switch (key) { switch (key) {
case KEY_DOWN: case KEY_DOWN:
case KEY_CTRLN:
if (this->selected + 1 < Vector_size(this->items)) if (this->selected + 1 < Vector_size(this->items))
this->selected++; this->selected++;
return true; return true;
case KEY_UP: case KEY_UP:
case KEY_CTRLP:
if (this->selected > 0) if (this->selected > 0)
this->selected--; this->selected--;
return true; return true;
@ -360,12 +366,14 @@ bool Panel_onKey(Panel* this, int key) {
return true; return true;
#endif #endif
case KEY_LEFT: case KEY_LEFT:
case KEY_CTRLB:
if (this->scrollH > 0) { if (this->scrollH > 0) {
this->scrollH -= 5; this->scrollH -= 5;
this->needsRedraw = true; this->needsRedraw = true;
} }
return true; return true;
case KEY_RIGHT: case KEY_RIGHT:
case KEY_CTRLF:
this->scrollH += 5; this->scrollH += 5;
this->needsRedraw = true; this->needsRedraw = true;
return true; return true;

View File

@ -65,6 +65,10 @@ extern char* PANEL_CLASS;
#define PANEL_CLASS NULL #define PANEL_CLASS NULL
#endif #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* Panel_new(int x, int y, int w, int h, char* type, bool owner, Object_Compare compare);

View File

@ -184,6 +184,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
continue; continue;
} }
case KEY_LEFT: case KEY_LEFT:
case KEY_CTRLB:
tryLeft: tryLeft:
if (focus > 0) if (focus > 0)
focus--; focus--;
@ -192,6 +193,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
goto tryLeft; goto tryLeft;
break; break;
case KEY_RIGHT: case KEY_RIGHT:
case KEY_CTRLF:
case 9: case 9:
tryRight: tryRight:
if (focus < this->itemCount - 1) if (focus < this->itemCount - 1)