aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/lxdialog/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/lxdialog/util.c')
-rw-r--r--scripts/kconfig/lxdialog/util.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index 0b3118df50df..cb21dc4dd9fc 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -477,6 +477,39 @@ int first_alpha(const char *string, const char *exempt)
477 return 0; 477 return 0;
478} 478}
479 479
480/*
481 * ncurses uses ESC to detect escaped char sequences. This resutl in
482 * a small timeout before ESC is actually delivered to the application.
483 * lxdialog suggest <ESC> <ESC> which is correctly translated to two
484 * times esc. But then we need to ignore the second esc to avoid stepping
485 * out one menu too much. Filter away all escaped key sequences since
486 * keypad(FALSE) turn off ncurses support for escape sequences - and thats
487 * needed to make notimeout() do as expected.
488 */
489int on_key_esc(WINDOW *win)
490{
491 int key;
492 int key2;
493 int key3;
494
495 nodelay(win, TRUE);
496 keypad(win, FALSE);
497 key = wgetch(win);
498 key2 = wgetch(win);
499 do {
500 key3 = wgetch(win);
501 } while (key3 != ERR);
502 nodelay(win, FALSE);
503 keypad(win, TRUE);
504 if (key == KEY_ESC && key2 == ERR)
505 return KEY_ESC;
506 else if (key != ERR && key != KEY_ESC && key2 == ERR)
507 ungetch(key);
508
509 return -1;
510}
511
512
480struct dialog_list *item_cur; 513struct dialog_list *item_cur;
481struct dialog_list item_nil; 514struct dialog_list item_nil;
482struct dialog_list *item_head; 515struct dialog_list *item_head;