Commit 94f2505b authored by Roman Zippel's avatar Roman Zippel Committed by Sam Ravnborg

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: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 59c6a3f4
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment