History

kconfig: Left aling menu items in menuconfig

Keeping menu lines on a fixed position creates less visual noise when navigating the menus.

Sam Ravnborg committed 20 years ago

Commit 0e175d01 parent fa7009d1 file · +11 −19Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/lxdialog/menubox.c+11−19
@@ -58,7 +58,8 @@ · 57 unmodified lines
5858
5959 #include "dialog.h"
6060
61−static int menu_width, item_x;
61+#define ITEM_IDENT 4 /* Indent of menu entries. Fixed for all menus */
62+static int menu_width;
6263
6364 /*
6465 * Print menu item
@@ -86,13 +87,13 @@ static void print_item(WINDOW * win, const char *item, int choice, · 21 unmodified lines
8687 wclrtoeol(win);
8788 #endif
8889 wattrset(win, selected ? item_selected_attr : item_attr);
89− mvwaddstr(win, choice, item_x, menu_item);
90+ mvwaddstr(win, choice, ITEM_IDENT, menu_item);
9091 if (hotkey) {
9192 wattrset(win, selected ? tag_key_selected_attr : tag_key_attr);
92− mvwaddch(win, choice, item_x + j, menu_item[j]);
93+ mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]);
9394 }
9495 if (selected) {
95− wmove(win, choice, item_x + 1);
96+ wmove(win, choice, ITEM_IDENT + 1);
9697 wrefresh(win);
9798 }
9899 free(menu_item);
@@ -207,19 +208,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, · 108 unmodified lines
207208 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
208209 menubox_border_attr, menubox_attr);
209210
210− /*
211− * Find length of longest item in order to center menu.
212− * Set 'choice' to default item.
213− */
214− item_x = 0;
215− for (i = 0; i < item_no; i++) {
216− item_x =
217− MAX(item_x, MIN(menu_width, strlen(items[i * 2 + 1]) + 2));
211+ /* Set choice to default item */
212+ for (i = 0; i < item_no; i++)
218213 if (strcmp(current, items[i * 2]) == 0)
219214 choice = i;
220− }
221−
222− item_x = (menu_width - item_x) / 2;
223215
224216 /* get the scroll info from the temp file */
225217 if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) {
@@ -254,10 +246,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, · 28 unmodified lines
254246 wnoutrefresh(menu);
255247
256248 print_arrows(dialog, item_no, scroll,
257− box_y, box_x + item_x + 1, menu_height);
249+ box_y, box_x + ITEM_IDENT + 1, menu_height);
258250
259251 print_buttons(dialog, height, width, 0);
260− wmove(menu, choice, item_x + 1);
252+ wmove(menu, choice, ITEM_IDENT + 1);
261253 wrefresh(menu);
262254
263255 while (key != ESC) {
@@ -286,7 +278,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, · 22 unmodified lines
286278 key == KEY_UP || key == KEY_DOWN ||
287279 key == '-' || key == '+' ||
288280 key == KEY_PPAGE || key == KEY_NPAGE) {
289−
281+ /* Remove highligt of current item */
290282 print_item(menu, items[(scroll + choice) * 2 + 1],
291283 choice, FALSE,
292284 (items[(scroll + choice) * 2][0] != ':'));
@@ -364,7 +356,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, · 71 unmodified lines
364356 choice, TRUE, (items[(scroll + choice) * 2][0] != ':'));
365357
366358 print_arrows(dialog, item_no, scroll,
367− box_y, box_x + item_x + 1, menu_height);
359+ box_y, box_x + ITEM_IDENT + 1, menu_height);
368360
369361 wnoutrefresh(dialog);
370362 wrefresh(menu);