diff options
-rw-r--r-- | scripts/kconfig/lxdialog/checklist.c | 10 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 4 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/inputbox.c | 10 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/menubox.c | 10 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 7 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 33 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/yesno.c | 7 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 25 |
8 files changed, 76 insertions, 30 deletions
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index 282511020bcb..39becb72444a 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c | |||
@@ -192,7 +192,7 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
192 | wnoutrefresh(list); | 192 | wnoutrefresh(list); |
193 | doupdate(); | 193 | doupdate(); |
194 | 194 | ||
195 | while (key != ESC) { | 195 | while (key != KEY_ESC) { |
196 | key = wgetch(dialog); | 196 | key = wgetch(dialog); |
197 | 197 | ||
198 | for (i = 0; i < max_choice; i++) { | 198 | for (i = 0; i < max_choice; i++) { |
@@ -298,8 +298,10 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
298 | break; | 298 | break; |
299 | case 'X': | 299 | case 'X': |
300 | case 'x': | 300 | case 'x': |
301 | key = ESC; | 301 | key = KEY_ESC; |
302 | case ESC: | 302 | break; |
303 | case KEY_ESC: | ||
304 | key = on_key_esc(dialog); | ||
303 | break; | 305 | break; |
304 | } | 306 | } |
305 | 307 | ||
@@ -308,5 +310,5 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
308 | } | 310 | } |
309 | delwin(list); | 311 | delwin(list); |
310 | delwin(dialog); | 312 | delwin(dialog); |
311 | return 255; /* ESC pressed */ | 313 | return key; /* ESC pressed */ |
312 | } | 314 | } |
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 065ded0a449f..a7cfdecc2409 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -48,7 +48,7 @@ | |||
48 | 48 | ||
49 | #define TR(params) _tracef params | 49 | #define TR(params) _tracef params |
50 | 50 | ||
51 | #define ESC 27 | 51 | #define KEY_ESC 27 |
52 | #define TAB 9 | 52 | #define TAB 9 |
53 | #define MAX_LEN 2048 | 53 | #define MAX_LEN 2048 |
54 | #define BUF_SIZE (10*1024) | 54 | #define BUF_SIZE (10*1024) |
@@ -179,6 +179,8 @@ int item_is_tag(char tag); | |||
179 | for (item_cur = item_head ? item_head: item_cur; \ | 179 | for (item_cur = item_head ? item_head: item_cur; \ |
180 | item_cur && (item_cur != &item_nil); item_cur = item_cur->next) | 180 | item_cur && (item_cur != &item_nil); item_cur = item_cur->next) |
181 | 181 | ||
182 | /* generic key handlers */ | ||
183 | int on_key_esc(WINDOW *win); | ||
182 | 184 | ||
183 | void init_dialog(const char *backtitle); | 185 | void init_dialog(const char *backtitle); |
184 | void reset_dialog(void); | 186 | void reset_dialog(void); |
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 9c53098d6b74..edb7975dbaa2 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c | |||
@@ -106,7 +106,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
106 | 106 | ||
107 | wrefresh(dialog); | 107 | wrefresh(dialog); |
108 | 108 | ||
109 | while (key != ESC) { | 109 | while (key != KEY_ESC) { |
110 | key = wgetch(dialog); | 110 | key = wgetch(dialog); |
111 | 111 | ||
112 | if (button == -1) { /* Input box selected */ | 112 | if (button == -1) { /* Input box selected */ |
@@ -215,12 +215,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width | |||
215 | return (button == -1 ? 0 : button); | 215 | return (button == -1 ? 0 : button); |
216 | case 'X': | 216 | case 'X': |
217 | case 'x': | 217 | case 'x': |
218 | key = ESC; | 218 | key = KEY_ESC; |
219 | case ESC: | 219 | break; |
220 | case KEY_ESC: | ||
221 | key = on_key_esc(dialog); | ||
220 | break; | 222 | break; |
221 | } | 223 | } |
222 | } | 224 | } |
223 | 225 | ||
224 | delwin(dialog); | 226 | delwin(dialog); |
225 | return 255; /* ESC pressed */ | 227 | return KEY_ESC; /* ESC pressed */ |
226 | } | 228 | } |
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index f39ae29f4fcc..d3305bad15c7 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c | |||
@@ -263,7 +263,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
263 | wmove(menu, choice, item_x + 1); | 263 | wmove(menu, choice, item_x + 1); |
264 | wrefresh(menu); | 264 | wrefresh(menu); |
265 | 265 | ||
266 | while (key != ESC) { | 266 | while (key != KEY_ESC) { |
267 | key = wgetch(menu); | 267 | key = wgetch(menu); |
268 | 268 | ||
269 | if (key < 256 && isalpha(key)) | 269 | if (key < 256 && isalpha(key)) |
@@ -402,12 +402,14 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, | |||
402 | return button; | 402 | return button; |
403 | case 'e': | 403 | case 'e': |
404 | case 'x': | 404 | case 'x': |
405 | key = ESC; | 405 | key = KEY_ESC; |
406 | case ESC: | 406 | break; |
407 | case KEY_ESC: | ||
408 | key = on_key_esc(menu); | ||
407 | break; | 409 | break; |
408 | } | 410 | } |
409 | } | 411 | } |
410 | delwin(menu); | 412 | delwin(menu); |
411 | delwin(dialog); | 413 | delwin(dialog); |
412 | return 255; /* ESC pressed */ | 414 | return key; /* ESC pressed */ |
413 | } | 415 | } |
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index 86b0770b0387..a99e1f497d67 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c | |||
@@ -92,7 +92,7 @@ int dialog_textbox(const char *title, const char *tbuf, int height, int width) | |||
92 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 92 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
93 | wrefresh(dialog); | 93 | wrefresh(dialog); |
94 | 94 | ||
95 | while ((key != ESC) && (key != '\n')) { | 95 | while ((key != KEY_ESC) && (key != '\n')) { |
96 | key = wgetch(dialog); | 96 | key = wgetch(dialog); |
97 | switch (key) { | 97 | switch (key) { |
98 | case 'E': /* Exit */ | 98 | case 'E': /* Exit */ |
@@ -228,13 +228,14 @@ int dialog_textbox(const char *title, const char *tbuf, int height, int width) | |||
228 | wmove(dialog, cur_y, cur_x); | 228 | wmove(dialog, cur_y, cur_x); |
229 | wrefresh(dialog); | 229 | wrefresh(dialog); |
230 | break; | 230 | break; |
231 | case ESC: | 231 | case KEY_ESC: |
232 | key = on_key_esc(dialog); | ||
232 | break; | 233 | break; |
233 | } | 234 | } |
234 | } | 235 | } |
235 | delwin(text); | 236 | delwin(text); |
236 | delwin(dialog); | 237 | delwin(dialog); |
237 | return 255; /* ESC pressed */ | 238 | return key; /* ESC pressed */ |
238 | } | 239 | } |
239 | 240 | ||
240 | /* | 241 | /* |
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; |
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c index 9fc24492c52f..8364f9dd01c3 100644 --- a/scripts/kconfig/lxdialog/yesno.c +++ b/scripts/kconfig/lxdialog/yesno.c | |||
@@ -69,7 +69,7 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) | |||
69 | 69 | ||
70 | print_buttons(dialog, height, width, 0); | 70 | print_buttons(dialog, height, width, 0); |
71 | 71 | ||
72 | while (key != ESC) { | 72 | while (key != KEY_ESC) { |
73 | key = wgetch(dialog); | 73 | key = wgetch(dialog); |
74 | switch (key) { | 74 | switch (key) { |
75 | case 'Y': | 75 | case 'Y': |
@@ -93,11 +93,12 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) | |||
93 | case '\n': | 93 | case '\n': |
94 | delwin(dialog); | 94 | delwin(dialog); |
95 | return button; | 95 | return button; |
96 | case ESC: | 96 | case KEY_ESC: |
97 | key = on_key_esc(dialog); | ||
97 | break; | 98 | break; |
98 | } | 99 | } |
99 | } | 100 | } |
100 | 101 | ||
101 | delwin(dialog); | 102 | delwin(dialog); |
102 | return 255; /* ESC pressed */ | 103 | return key; /* ESC pressed */ |
103 | } | 104 | } |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index b1ad9a00ab19..ef75d6c3d3e5 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -608,7 +608,7 @@ static void conf(struct menu *menu) | |||
608 | _(menu_instructions), | 608 | _(menu_instructions), |
609 | rows, cols, rows - 10, | 609 | rows, cols, rows - 10, |
610 | active_menu, &s_scroll); | 610 | active_menu, &s_scroll); |
611 | if (res == 1 || res == 255) | 611 | if (res == 1 || res == KEY_ESC) |
612 | break; | 612 | break; |
613 | if (!item_activate_selected()) | 613 | if (!item_activate_selected()) |
614 | continue; | 614 | continue; |
@@ -754,7 +754,7 @@ static void conf_choice(struct menu *menu) | |||
754 | } else | 754 | } else |
755 | show_help(menu); | 755 | show_help(menu); |
756 | break; | 756 | break; |
757 | case 255: | 757 | case KEY_ESC: |
758 | return; | 758 | return; |
759 | } | 759 | } |
760 | } | 760 | } |
@@ -794,7 +794,7 @@ static void conf_string(struct menu *menu) | |||
794 | case 1: | 794 | case 1: |
795 | show_help(menu); | 795 | show_help(menu); |
796 | break; | 796 | break; |
797 | case 255: | 797 | case KEY_ESC: |
798 | return; | 798 | return; |
799 | } | 799 | } |
800 | } | 800 | } |
@@ -819,7 +819,7 @@ static void conf_load(void) | |||
819 | case 1: | 819 | case 1: |
820 | show_helptext(_("Load Alternate Configuration"), load_config_help); | 820 | show_helptext(_("Load Alternate Configuration"), load_config_help); |
821 | break; | 821 | break; |
822 | case 255: | 822 | case KEY_ESC: |
823 | return; | 823 | return; |
824 | } | 824 | } |
825 | } | 825 | } |
@@ -843,7 +843,7 @@ static void conf_save(void) | |||
843 | case 1: | 843 | case 1: |
844 | show_helptext(_("Save Alternate Configuration"), save_config_help); | 844 | show_helptext(_("Save Alternate Configuration"), save_config_help); |
845 | break; | 845 | break; |
846 | case 255: | 846 | case KEY_ESC: |
847 | return; | 847 | return; |
848 | } | 848 | } |
849 | } | 849 | } |
@@ -883,12 +883,15 @@ int main(int ac, char **av) | |||
883 | init_wsize(); | 883 | init_wsize(); |
884 | reset_dialog(); | 884 | reset_dialog(); |
885 | init_dialog(menu_backtitle); | 885 | init_dialog(menu_backtitle); |
886 | conf(&rootmenu); | 886 | do { |
887 | reset_dialog(); | 887 | conf(&rootmenu); |
888 | res = dialog_yesno(NULL, | 888 | reset_dialog(); |
889 | _("Do you wish to save your " | 889 | res = dialog_yesno(NULL, |
890 | "new kernel configuration?"), | 890 | _("Do you wish to save your " |
891 | 5, 60); | 891 | "new kernel configuration?\n" |
892 | "<ESC><ESC> to continue."), | ||
893 | 6, 60); | ||
894 | } while (res == KEY_ESC); | ||
892 | end_dialog(); | 895 | end_dialog(); |
893 | if (res == 0) { | 896 | if (res == 0) { |
894 | if (conf_write(NULL)) { | 897 | if (conf_write(NULL)) { |