summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDu Huanpeng <u74147@gmail.com>2016-04-19 12:02:53 +0800
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-19 08:12:46 +0200
commit484a088f78a57b7341c190c78ef62df6a632754d (patch)
tree0e70eb705f66124040313ea7eb5358019abd1724
parent556459f022d68ddd6ad87e68aef63c2dc52a8a43 (diff)
downloadbarebox-484a088f78a57b7341c190c78ef62df6a632754d.tar.gz
menu: add vi like key support
add vi like key support: j: down k: up <Space>: select Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/menu.c15
1 files 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;