kconfig: make use of menu_get_ext_help in menuconfig
[safe/jmp/linux-2.6] / scripts / kconfig / lxdialog / inputbox.c
index f75b51f..616c601 100644 (file)
@@ -31,8 +31,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
        int x = width / 2 - 11;
        int y = height - 2;
 
-       print_button(dialog, "  Ok  ", y, x, selected == 0);
-       print_button(dialog, " Help ", y, x + 14, selected == 1);
+       print_button(dialog, gettext("  Ok  "), y, x, selected == 0);
+       print_button(dialog, gettext(" Help "), y, x + 14, selected == 1);
 
        wmove(dialog, y, x + 1 + 14 * selected);
        wrefresh(dialog);
@@ -49,6 +49,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
        char *instr = dialog_input_result;
        WINDOW *dialog;
 
+       if (!init)
+               instr[0] = '\0';
+       else
+               strcpy(instr, init);
+
+do_resize:
+       if (getmaxy(stdscr) <= (height - 2))
+               return -ERRDISPLAYTOOSMALL;
+       if (getmaxx(stdscr) <= (width - 2))
+               return -ERRDISPLAYTOOSMALL;
+
        /* center dialog box on screen */
        x = (COLS - width) / 2;
        y = (LINES - height) / 2;
@@ -78,7 +89,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
        box_y = y + 2;
        box_x = (width - box_width) / 2;
        draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
-                dlg.border.atr, dlg.dialog.atr);
+                dlg.dialog.atr, dlg.border.atr);
 
        print_buttons(dialog, height, width, 0);
 
@@ -86,11 +97,6 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
        wmove(dialog, box_y, box_x);
        wattrset(dialog, dlg.inputbox.atr);
 
-       if (!init)
-               instr[0] = '\0';
-       else
-               strcpy(instr, init);
-
        input_x = strlen(instr);
 
        if (input_x >= box_width) {
@@ -106,7 +112,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
 
        wrefresh(dialog);
 
-       while (key != ESC) {
+       while (key != KEY_ESC) {
                key = wgetch(dialog);
 
                if (button == -1) {     /* Input box selected */
@@ -215,12 +221,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
                        return (button == -1 ? 0 : button);
                case 'X':
                case 'x':
-                       key = ESC;
-               case ESC:
+                       key = KEY_ESC;
+                       break;
+               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;         /* ESC pressed */
 }