From e193e79a69181488d9d9a5f80e91e64bf7341668 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sun, 16 Sep 2007 15:29:11 +0000 Subject: [PATCH] use wait_char to wait escape sequence --- libui/libui.h | 1 + libui/scrolllist.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libui/libui.h b/libui/libui.h index 63a4082..b49a310 100644 --- a/libui/libui.h +++ b/libui/libui.h @@ -29,6 +29,7 @@ extern void console_select_charset(char c); extern void console_cursor_off(); extern int console_getchar(void); extern int console_keypressed(int timeout); +extern int wait_char; extern void emile_window(emile_window_t *win); extern emile_progressbar_t* emile_progressbar_create(emile_window_t *win, int max); diff --git a/libui/scrolllist.c b/libui/scrolllist.c index 7438775..88175cd 100644 --- a/libui/scrolllist.c +++ b/libui/scrolllist.c @@ -42,6 +42,7 @@ int emile_scrolllist(emile_window_t *win, emile_list_t *list, int timeout) { char c; int base = 0; + int saved_wait = wait_char; console_cursor_off(); emile_window(win); @@ -50,16 +51,23 @@ int emile_scrolllist(emile_window_t *win, emile_list_t *list, int timeout) if (timeout && !console_keypressed(timeout * 60)) return '\r'; + wait_char = 1; while(1) { + console_keypressed(0); c = console_getchar(); if (c == -1) break; + if (c == 0) + continue; if (c == '\033') { c = console_getchar(); if (c != '[') - return '\033'; + { + c = '\033'; + goto out; + } c = console_getchar(); if ( (c == 'B') && (list->current < list->nb - 1) ) { @@ -78,8 +86,9 @@ int emile_scrolllist(emile_window_t *win, emile_list_t *list, int timeout) } else break; - console_keypressed(0); } +out: + wait_char = saved_wait; return c; }