[PATCH] menu: add vi like key support
DU HUANPENG
do_not_rep1y at 163.com
Mon Apr 18 21:02:53 PDT 2016
From: Du Huanpeng <u74147 at gmail.com>
add vi like key support:
j: down
k: up
<Space>: select
Signed-off-by: Du Huanpeng <u74147 at gmail.com>
---
common/menu.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/common/menu.c b/common/menu.c
index 54f2c71..9819569 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -327,6 +327,7 @@ int menu_show(struct menu *m)
}
break;
}
+ case 'k':
case BB_KEY_UP:
m->selected = list_entry(m->selected->list.prev, struct menu_entry,
list);
@@ -336,6 +337,7 @@ int menu_show(struct menu *m)
}
repaint = 1;
break;
+ case 'j':
case BB_KEY_DOWN:
m->selected = list_entry(m->selected->list.next, struct menu_entry,
list);
@@ -346,13 +348,14 @@ int menu_show(struct menu *m)
repaint = 1;
break;
case ' ':
- if (m->selected->type != MENU_ENTRY_BOX)
+ if (m->selected->type == MENU_ENTRY_BOX) {
+ m->selected->box_state = !m->selected->box_state;
+ if (m->selected->action)
+ m->selected->action(m, m->selected);
+ repaint = 1;
break;
- m->selected->box_state = !m->selected->box_state;
- if (m->selected->action)
- m->selected->action(m, m->selected);
- repaint = 1;
- break;
+ }
+ /* no break */
case BB_KEY_ENTER:
if (ch_previous == BB_KEY_RETURN)
break;
--
1.9.1
More information about the barebox
mailing list