summaryrefslogtreecommitdiff
path: root/src/wins.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/wins.c
parent990897b2f098f3ed898919e3e66c8830c2e3b450 (diff)
downloadcalcurse-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/wins.c')
-rw-r--r--src/wins.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wins.c b/src/wins.c
index 0d8160a..14616aa 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -386,6 +386,12 @@ void wins_scrollwin_down(struct scrollwin *sw, int amount)
sw->line_off = sw->line_num - inner_h;
}
+int wins_scrollwin_is_visible(struct scrollwin *sw, unsigned line)
+{
+ int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
+ return ((line >= sw->line_off) && (line < sw->line_off + inner_h));
+}
+
void wins_scrollwin_ensure_visible(struct scrollwin *sw, unsigned line)
{
int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
@@ -396,6 +402,12 @@ void wins_scrollwin_ensure_visible(struct scrollwin *sw, unsigned line)
sw->line_off = line - inner_h + 1;
}
+void wins_scrollwin_set_lower(struct scrollwin *sw, unsigned line)
+{
+ int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
+ sw->line_off = MAX((int)line - inner_h + 1, 0);
+}
+
void wins_resize_panels(void)
{
wins_get_config();