aboutsummaryrefslogtreecommitdiffstats
path: root/src/listbox.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-05-19 11:07:52 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-05-19 21:43:27 +0200
commit0b46ad4faaee1ce982a64413b57406e43cb83e88 (patch)
tree4ee402f445b0d4b22cf8c0e4d6af55672fdb40e3 /src/listbox.c
parent990897b2f098f3ed898919e3e66c8830c2e3b450 (diff)
downloadcalcurse-0b46ad4faaee1ce982a64413b57406e43cb83e88.tar.gz
calcurse-0b46ad4faaee1ce982a64413b57406e43cb83e88.zip
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 <calcurse@cryptocrack.de>
Diffstat (limited to 'src/listbox.c')
-rw-r--r--src/listbox.c5
1 files changed, 5 insertions, 0 deletions
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);
}