summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-06-24 14:45:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-06-30 20:23:26 +0200
commitfa37257ce072c7faac7d0fedbd37a99774cb9267 (patch)
treea0bedc7d3b7f8b3427d121866628aa8efc16a69c
parent4d5a9be0dcdffa64faf8020185c600890f2391b4 (diff)
downloadbarebox-fa37257ce072c7faac7d0fedbd37a99774cb9267.tar.gz
barebox-fa37257ce072c7faac7d0fedbd37a99774cb9267.tar.xz
menu: use read_key
We have the read_key function which reads a key and parses escape sequences. Use it in the menu instead of reimplementing this manually. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/menu.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/common/menu.c b/common/menu.c
index 6c530b6f86..cb2a6fe163 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -297,7 +297,6 @@ static int menu_alloc_display_buffer(struct menu *m)
int menu_show(struct menu *m)
{
int ch, ch_previous = 0;
- int escape = 0;
int countdown;
int auto_display_len = 16;
uint64_t start, second;
@@ -347,19 +346,12 @@ int menu_show(struct menu *m)
if (m->auto_select >= 0)
ch = KEY_RETURN;
else
- ch = getc();
+ ch = read_key();
m->auto_select = -1;
- switch(ch) {
- case 0x1b:
- escape = 1;
- break;
- case '[':
- if (escape)
- break;
- case 'A': /* up */
- escape = 0;
+ switch (ch) {
+ case KEY_UP:
print_menu_entry(m, m->selected, 0);
m->selected = list_entry(m->selected->list.prev, struct menu_entry,
list);
@@ -369,8 +361,7 @@ int menu_show(struct menu *m)
}
print_menu_entry(m, m->selected, 1);
break;
- case 'B': /* down */
- escape = 0;
+ case KEY_DOWN:
print_menu_entry(m, m->selected, 0);
m->selected = list_entry(m->selected->list.next, struct menu_entry,
list);