Skip to content

Commit

Permalink
kconfig: recenter menuconfig
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roman Zippel authored and Sam Ravnborg committed Apr 11, 2006
1 parent 59c6a3f commit 94f2505
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions scripts/kconfig/lxdialog/menubox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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");

Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 94f2505

Please sign in to comment.