From f6a0204436d51e2227a1b9c8f0463936a9c03f0a Mon Sep 17 00:00:00 2001 From: nbd Date: Thu, 18 Apr 2013 12:05:16 +0000 Subject: build: add new menuconfig code based on linux 3.9 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36361 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- scripts/config/lxdialog/yesno.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'scripts/config/lxdialog/yesno.c') diff --git a/scripts/config/lxdialog/yesno.c b/scripts/config/lxdialog/yesno.c index cb2568aae..4e6e8090c 100644 --- a/scripts/config/lxdialog/yesno.c +++ b/scripts/config/lxdialog/yesno.c @@ -29,8 +29,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected) int x = width / 2 - 10; int y = height - 2; - print_button(dialog, " Yes ", y, x, selected == 0); - print_button(dialog, " No ", y, x + 13, selected == 1); + print_button(dialog, gettext(" Yes "), y, x, selected == 0); + print_button(dialog, gettext(" No "), y, x + 13, selected == 1); wmove(dialog, y, x + 1 + 13 * selected); wrefresh(dialog); @@ -44,6 +44,12 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) int i, x, y, key = 0, button = 0; WINDOW *dialog; +do_resize: + if (getmaxy(stdscr) < (height + 4)) + return -ERRDISPLAYTOOSMALL; + if (getmaxx(stdscr) < (width + 4)) + return -ERRDISPLAYTOOSMALL; + /* center dialog box on screen */ x = (COLS - width) / 2; y = (LINES - height) / 2; @@ -53,22 +59,23 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) dialog = newwin(height, width, y, x); keypad(dialog, TRUE); - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset(dialog, border_attr); + draw_box(dialog, 0, 0, height, width, + dlg.dialog.atr, dlg.border.atr); + wattrset(dialog, dlg.border.atr); mvwaddch(dialog, height - 3, 0, ACS_LTEE); for (i = 0; i < width - 2; i++) waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); + wattrset(dialog, dlg.dialog.atr); waddch(dialog, ACS_RTEE); print_title(dialog, title, width); - wattrset(dialog, dialog_attr); + wattrset(dialog, dlg.dialog.atr); print_autowrap(dialog, prompt, width - 2, 1, 3); print_buttons(dialog, height, width, 0); - while (key != ESC) { + while (key != KEY_ESC) { key = wgetch(dialog); switch (key) { case 'Y': @@ -92,11 +99,16 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) case '\n': delwin(dialog); return button; - case ESC: + case KEY_ESC: + key = on_key_esc(dialog); break; + case KEY_RESIZE: + delwin(dialog); + on_key_resize(); + goto do_resize; } } delwin(dialog); - return -1; /* ESC pressed */ + return key; /* ESC pressed */ } -- cgit v1.2.3