diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-08-05 07:06:00 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-08-09 08:40:02 +0200 |
commit | 0e21e17614135b641228ae482a46c2b944f6b8de (patch) | |
tree | e497f6a1c89c1f90d5476921d5b24d40f02b6d68 /common/menu.c | |
parent | 21ea2ad83046f154cca68a48aaa063911d5641e4 (diff) | |
download | barebox-0e21e17614135b641228ae482a46c2b944f6b8de.tar.gz barebox-0e21e17614135b641228ae482a46c2b944f6b8de.tar.xz |
menu: add number key support
Allow to use the number key to jump to entry.
if already on a entry % number_key jump to the next +10 one if exit
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/menu.c')
-rw-r--r-- | common/menu.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/menu.c b/common/menu.c index 9f536d6aee..97c6b184bd 100644 --- a/common/menu.c +++ b/common/menu.c @@ -314,6 +314,23 @@ int menu_show(struct menu *m) m->auto_select = -1; switch (ch) { + case '0' ... '9': { + struct menu_entry *me; + int num = ch - '0'; + int next_num = m->selected->num + 10; + if (!num) + num = 10; + + if (ch_previous == ch && next_num <= m->nb_entries) + num = next_num; + + me = menu_entry_get_by_num(m, num); + if (me) { + m->selected = me; + repaint = 1; + } + break; + } case KEY_UP: m->selected = list_entry(m->selected->list.prev, struct menu_entry, list); |