aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/lxdialog/menubox.c
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2006-04-09 11:27:14 -0400
committerSam Ravnborg <sam@mars.ravnborg.org>2006-04-11 07:41:06 -0400
commit94f2505be3b6afaf50129e949b1840bc4dd0b3e8 (patch)
tree60e5c1ece1690e999890a08691a46845866e5f79 /scripts/kconfig/lxdialog/menubox.c
parent59c6a3f4d745584f2f78cdf1f5e221a19518926c (diff)
kconfig: recenter menuconfig
Move the menuconfig output more into the centre again, it's using a fixed position depending on the window width using the fact that the menu output has to work in a 80 chars terminal. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/kconfig/lxdialog/menubox.c')
-rw-r--r--scripts/kconfig/lxdialog/menubox.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 09512b544375..bf8052f4fd4a 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -58,8 +58,7 @@
58 58
59#include "dialog.h" 59#include "dialog.h"
60 60
61#define ITEM_IDENT 1 /* Indent of menu entries. Fixed for all menus */ 61static int menu_width, item_x;
62static int menu_width;
63 62
64/* 63/*
65 * Print menu item 64 * Print menu item
@@ -70,7 +69,7 @@ static void do_print_item(WINDOW * win, const char *item, int choice,
70 int j; 69 int j;
71 char *menu_item = malloc(menu_width + 1); 70 char *menu_item = malloc(menu_width + 1);
72 71
73 strncpy(menu_item, item, menu_width - ITEM_IDENT); 72 strncpy(menu_item, item, menu_width - item_x);
74 menu_item[menu_width] = 0; 73 menu_item[menu_width] = 0;
75 j = first_alpha(menu_item, "YyNnMmHh"); 74 j = first_alpha(menu_item, "YyNnMmHh");
76 75
@@ -87,13 +86,13 @@ static void do_print_item(WINDOW * win, const char *item, int choice,
87 wclrtoeol(win); 86 wclrtoeol(win);
88#endif 87#endif
89 wattrset(win, selected ? item_selected_attr : item_attr); 88 wattrset(win, selected ? item_selected_attr : item_attr);
90 mvwaddstr(win, choice, ITEM_IDENT, menu_item); 89 mvwaddstr(win, choice, item_x, menu_item);
91 if (hotkey) { 90 if (hotkey) {
92 wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); 91 wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
93 mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); 92 mvwaddch(win, choice, item_x + j, menu_item[j]);
94 } 93 }
95 if (selected) { 94 if (selected) {
96 wmove(win, choice, ITEM_IDENT + 1); 95 wmove(win, choice, item_x + 1);
97 } 96 }
98 free(menu_item); 97 free(menu_item);
99 wrefresh(win); 98 wrefresh(win);
@@ -227,6 +226,8 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
227 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, 226 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
228 menubox_border_attr, menubox_attr); 227 menubox_border_attr, menubox_attr);
229 228
229 item_x = (menu_width - 70) / 2;
230
230 /* Set choice to default item */ 231 /* Set choice to default item */
231 for (i = 0; i < item_no; i++) 232 for (i = 0; i < item_no; i++)
232 if (strcmp(current, items[i * 2]) == 0) 233 if (strcmp(current, items[i * 2]) == 0)
@@ -263,10 +264,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
263 wnoutrefresh(menu); 264 wnoutrefresh(menu);
264 265
265 print_arrows(dialog, item_no, scroll, 266 print_arrows(dialog, item_no, scroll,
266 box_y, box_x + ITEM_IDENT + 1, menu_height); 267 box_y, box_x + item_x + 1, menu_height);
267 268
268 print_buttons(dialog, height, width, 0); 269 print_buttons(dialog, height, width, 0);
269 wmove(menu, choice, ITEM_IDENT + 1); 270 wmove(menu, choice, item_x + 1);
270 wrefresh(menu); 271 wrefresh(menu);
271 272
272 while (key != ESC) { 273 while (key != ESC) {
@@ -349,7 +350,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width,
349 print_item(scroll + choice, choice, TRUE); 350 print_item(scroll + choice, choice, TRUE);
350 351
351 print_arrows(dialog, item_no, scroll, 352 print_arrows(dialog, item_no, scroll,
352 box_y, box_x + ITEM_IDENT + 1, menu_height); 353 box_y, box_x + item_x + 1, menu_height);
353 354
354 wnoutrefresh(dialog); 355 wnoutrefresh(dialog);
355 wrefresh(menu); 356 wrefresh(menu);