diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2006-04-09 17:27:14 +0200 |
---|---|---|
committer | Sam Ravnborg <sam@mars.ravnborg.org> | 2006-04-11 13:41:06 +0200 |
commit | 94f2505be3b6afaf50129e949b1840bc4dd0b3e8 (patch) | |
tree | 60e5c1ece1690e999890a08691a46845866e5f79 | |
parent | 59c6a3f4d745584f2f78cdf1f5e221a19518926c (diff) | |
download | linux-94f2505be3b6afaf50129e949b1840bc4dd0b3e8.tar.bz2 |
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>
-rw-r--r-- | scripts/kconfig/lxdialog/menubox.c | 19 |
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 @@ #include "dialog.h" -#define ITEM_IDENT 1 /* Indent of menu entries. Fixed for all menus */ -static int menu_width; +static int menu_width, item_x; /* * Print menu item @@ -70,7 +69,7 @@ static void do_print_item(WINDOW * win, const char *item, int choice, int j; char *menu_item = malloc(menu_width + 1); - strncpy(menu_item, item, menu_width - ITEM_IDENT); + strncpy(menu_item, item, menu_width - item_x); menu_item[menu_width] = 0; j = first_alpha(menu_item, "YyNnMmHh"); @@ -87,13 +86,13 @@ static void do_print_item(WINDOW * win, const char *item, int choice, wclrtoeol(win); #endif wattrset(win, selected ? item_selected_attr : item_attr); - mvwaddstr(win, choice, ITEM_IDENT, menu_item); + mvwaddstr(win, choice, item_x, menu_item); if (hotkey) { wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); - mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); + mvwaddch(win, choice, item_x + j, menu_item[j]); } if (selected) { - wmove(win, choice, ITEM_IDENT + 1); + wmove(win, choice, item_x + 1); } free(menu_item); wrefresh(win); @@ -227,6 +226,8 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, menubox_border_attr, menubox_attr); + item_x = (menu_width - 70) / 2; + /* Set choice to default item */ for (i = 0; i < item_no; i++) if (strcmp(current, items[i * 2]) == 0) @@ -263,10 +264,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, wnoutrefresh(menu); print_arrows(dialog, item_no, scroll, - box_y, box_x + ITEM_IDENT + 1, menu_height); + box_y, box_x + item_x + 1, menu_height); print_buttons(dialog, height, width, 0); - wmove(menu, choice, ITEM_IDENT + 1); + wmove(menu, choice, item_x + 1); wrefresh(menu); while (key != ESC) { @@ -349,7 +350,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, print_item(scroll + choice, choice, TRUE); print_arrows(dialog, item_no, scroll, - box_y, box_x + ITEM_IDENT + 1, menu_height); + box_y, box_x + item_x + 1, menu_height); wnoutrefresh(dialog); wrefresh(menu); |