aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/lxdialog/menubox.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/lxdialog/menubox.c')
-rw-r--r--scripts/kconfig/lxdialog/menubox.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index d3305bad15c7..fcd95a985328 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -179,14 +179,25 @@ static void do_scroll(WINDOW *win, int *scroll, int n)
179/* 179/*
180 * Display a menu for choosing among a number of options 180 * Display a menu for choosing among a number of options
181 */ 181 */
182int dialog_menu(const char *title, const char *prompt, int height, int width, 182int dialog_menu(const char *title, const char *prompt,
183 int menu_height, const void *selected, int *s_scroll) 183 const void *selected, int *s_scroll)
184{ 184{
185 int i, j, x, y, box_x, box_y; 185 int i, j, x, y, box_x, box_y;
186 int height, width, menu_height;
186 int key = 0, button = 0, scroll = 0, choice = 0; 187 int key = 0, button = 0, scroll = 0, choice = 0;
187 int first_item = 0, max_choice; 188 int first_item = 0, max_choice;
188 WINDOW *dialog, *menu; 189 WINDOW *dialog, *menu;
189 190
191do_resize:
192 height = getmaxy(stdscr);
193 width = getmaxx(stdscr);
194 if (height < 15 || width < 65)
195 return -ERRDISPLAYTOOSMALL;
196
197 height -= 4;
198 width -= 5;
199 menu_height = height - 10;
200
190 max_choice = MIN(menu_height, item_count()); 201 max_choice = MIN(menu_height, item_count());
191 202
192 /* center dialog box on screen */ 203 /* center dialog box on screen */
@@ -226,7 +237,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
226 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, 237 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
227 dlg.menubox_border.atr, dlg.menubox.atr); 238 dlg.menubox_border.atr, dlg.menubox.atr);
228 239
229 item_x = (menu_width - 70) / 2; 240 if (menu_width >= 80)
241 item_x = (menu_width - 70) / 2;
242 else
243 item_x = 4;
230 244
231 /* Set choice to default item */ 245 /* Set choice to default item */
232 item_foreach() 246 item_foreach()
@@ -407,6 +421,11 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
407 case KEY_ESC: 421 case KEY_ESC:
408 key = on_key_esc(menu); 422 key = on_key_esc(menu);
409 break; 423 break;
424 case KEY_RESIZE:
425 on_key_resize();
426 delwin(menu);
427 delwin(dialog);
428 goto do_resize;
410 } 429 }
411 } 430 }
412 delwin(menu); 431 delwin(menu);