From ef7ec99589ac0f498fd472510e8933bd7c68fe73 Mon Sep 17 00:00:00 2001 From: FictitiousExistence <> Date: Wed, 12 Nov 2025 09:11:17 -0500 Subject: [PATCH] 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 <> --- menu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/menu.c b/menu.c index 207d71c..468cf80 100644 --- a/menu.c +++ b/menu.c @@ -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) {