Set height to item count if less items than lines

This patch sets the height to the count of items if the item count
is less than specified lines.

Ex:
    printf "Item1\nItem2" | wmenu -l 100
    will give wmenu a height of 2 rather than 100 since there is only 2
    items.

closes #64

Signed-off-by: FictitiousExistence <>
This commit is contained in:
FictitiousExistence 2025-11-12 09:11:17 -05:00
parent 0a38d45abb
commit ef7ec99589

5
menu.c
View file

@ -181,6 +181,11 @@ void menu_add_item(struct menu *menu, char *text) {
new->text = text;
menu->item_count++;
if ((size_t)menu->lines > (menu->item_count - 1)){
menu->height = menu->line_height;
menu->height += menu->height * menu->item_count;
}
}
static int compare_items(const void *a, const void *b) {