Skip to content

Commit e7401d8

Browse files
Li Zefanmichal42
authored andcommitted
menuconfig: truncate list items
Truncate list items to fit in a single line, otherwise those items which have long prompts will cover some other items. This follows the behavior of menubox. Signed-off-by: Li Zefan <[email protected]> Signed-off-by: Michal Marek <[email protected]>
1 parent 42ef223 commit e7401d8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/kconfig/lxdialog/checklist.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ static int list_width, check_x, item_x;
3131
static void print_item(WINDOW * win, int choice, int selected)
3232
{
3333
int i;
34+
char *list_item = malloc(list_width + 1);
35+
36+
strncpy(list_item, item_str(), list_width - item_x);
37+
list_item[list_width - item_x] = '\0';
3438

3539
/* Clear 'residue' of last item */
3640
wattrset(win, dlg.menubox.atr);
@@ -45,13 +49,14 @@ static void print_item(WINDOW * win, int choice, int selected)
4549
wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
4650

4751
wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
48-
mvwaddch(win, choice, item_x, item_str()[0]);
52+
mvwaddch(win, choice, item_x, list_item[0]);
4953
wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
50-
waddstr(win, (char *)item_str() + 1);
54+
waddstr(win, list_item + 1);
5155
if (selected) {
5256
wmove(win, choice, check_x + 1);
5357
wrefresh(win);
5458
}
59+
free(list_item);
5560
}
5661

5762
/*

0 commit comments

Comments
 (0)