Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kconfig: Left aling menu items in menuconfig

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

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

+11 -19
+11 -19
scripts/lxdialog/menubox.c
··· 58 58 59 59 #include "dialog.h" 60 60 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; 62 63 63 64 /* 64 65 * Print menu item ··· 87 86 wclrtoeol(win); 88 87 #endif 89 88 wattrset(win, selected ? item_selected_attr : item_attr); 90 - mvwaddstr(win, choice, item_x, menu_item); 89 + mvwaddstr(win, choice, ITEM_IDENT, menu_item); 91 90 if (hotkey) { 92 91 wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); 93 - mvwaddch(win, choice, item_x + j, menu_item[j]); 92 + mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); 94 93 } 95 94 if (selected) { 96 - wmove(win, choice, item_x + 1); 95 + wmove(win, choice, ITEM_IDENT + 1); 97 96 wrefresh(win); 98 97 } 99 98 free(menu_item); ··· 208 207 draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, 209 208 menubox_border_attr, menubox_attr); 210 209 211 - /* 212 - * Find length of longest item in order to center menu. 213 - * Set 'choice' to default item. 214 - */ 215 - item_x = 0; 216 - for (i = 0; i < item_no; i++) { 217 - item_x = 218 - MAX(item_x, MIN(menu_width, strlen(items[i * 2 + 1]) + 2)); 210 + /* Set choice to default item */ 211 + for (i = 0; i < item_no; i++) 219 212 if (strcmp(current, items[i * 2]) == 0) 220 213 choice = i; 221 - } 222 - 223 - item_x = (menu_width - item_x) / 2; 224 214 225 215 /* get the scroll info from the temp file */ 226 216 if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { ··· 246 254 wnoutrefresh(menu); 247 255 248 256 print_arrows(dialog, item_no, scroll, 249 - box_y, box_x + item_x + 1, menu_height); 257 + box_y, box_x + ITEM_IDENT + 1, menu_height); 250 258 251 259 print_buttons(dialog, height, width, 0); 252 - wmove(menu, choice, item_x + 1); 260 + wmove(menu, choice, ITEM_IDENT + 1); 253 261 wrefresh(menu); 254 262 255 263 while (key != ESC) { ··· 278 286 key == KEY_UP || key == KEY_DOWN || 279 287 key == '-' || key == '+' || 280 288 key == KEY_PPAGE || key == KEY_NPAGE) { 281 - 289 + /* Remove highligt of current item */ 282 290 print_item(menu, items[(scroll + choice) * 2 + 1], 283 291 choice, FALSE, 284 292 (items[(scroll + choice) * 2][0] != ':')); ··· 356 364 choice, TRUE, (items[(scroll + choice) * 2][0] != ':')); 357 365 358 366 print_arrows(dialog, item_no, scroll, 359 - box_y, box_x + item_x + 1, menu_height); 367 + box_y, box_x + ITEM_IDENT + 1, menu_height); 360 368 361 369 wnoutrefresh(dialog); 362 370 wrefresh(menu);