From 0b46ad4faaee1ce982a64413b57406e43cb83e88 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 19 May 2014 11:07:52 +0200 Subject: Avoid blank space after the last list box item Automatically scroll down the list box when resizing creates some blank space below the list of items. Signed-off-by: Lukas Fleischer --- src/listbox.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/listbox.c') diff --git a/src/listbox.c b/src/listbox.c index 7f67fe4..5cdc9a1 100644 --- a/src/listbox.c +++ b/src/listbox.c @@ -68,6 +68,11 @@ void listbox_resize(struct listbox *lb, int y, int x, int h, int w) if (lb->item_sel < 0) return; + unsigned last_line = lb->ch[lb->item_count] - 1; + + if (wins_scrollwin_is_visible(&(lb->sw), last_line)) + wins_scrollwin_set_lower(&(lb->sw), last_line); + wins_scrollwin_ensure_visible(&(lb->sw), lb->ch[lb->item_sel]); wins_scrollwin_ensure_visible(&(lb->sw), lb->ch[lb->item_sel + 1] - 1); } -- cgit v1.2.3-54-g00ecf