diff options
author | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-07-28 17:57:48 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@neptun.ravnborg.org> | 2006-09-30 05:19:20 -0400 |
commit | f3cbcdc955d0d2c8b4c52d6b73fc536b01b68c64 (patch) | |
tree | 3619243852b54799123f0fead031b8b45abf7aca /scripts/kconfig/lxdialog/util.c | |
parent | 2982de6993e6d9944f2215d7cb9b558b465a0c99 (diff) |
kconfig/lxdialog: let <ESC><ESC> behave as expected
<ESC><ESC> is used to step one back in the dialogs.
When lxdialog became built-in pressing <ESC> once would cause one step back
and pressing <ESC><ESC> would cause two steps back.
This patch - based on concept from Roman Zippel <zippel@linux-m68k.org> -
makes one <ESC> a noop and pressing <ESC><ESC> will cause one step backward.
In addition the final yes/no dialog now has the option to go back to the
the kernel configuration. So if you get too far out you can now go back
to configuring the kernel without saving and starting all over again.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/lxdialog/util.c')
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 33 |
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 | */ | ||
489 | int 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 | |||
480 | struct dialog_list *item_cur; | 513 | struct dialog_list *item_cur; |
481 | struct dialog_list item_nil; | 514 | struct dialog_list item_nil; |
482 | struct dialog_list *item_head; | 515 | struct dialog_list *item_head; |