aboutsummaryrefslogtreecommitdiffstats
path: root/src/wins.c
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2019-03-16 08:31:12 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-05-22 01:56:59 -0400
commitdf2cb2a9c024b167fdca3b0b91e27fe7bb47b5a8 (patch)
tree872895b566f01a78dc6ab930f7b4c192abf56a44 /src/wins.c
parent576994de00fd61b4ce521360cfdb076e9a051ee2 (diff)
downloadcalcurse-df2cb2a9c024b167fdca3b0b91e27fe7bb47b5a8.tar.gz
calcurse-df2cb2a9c024b167fdca3b0b91e27fe7bb47b5a8.zip
Refactor listbox code
The changes are related to the selected item and the visible lines in the scroll window viewport. In particular, the function listbox_fix_visible_region() has been eliminated, and functions previously only called by it have been removed. It performed several tasks that are now elsewhere. One was removed in an earlier commit (scroll window pad improvement). The task of making a multi-line item visible has been moved to listbox_item_in_view(). The task of making a caption line above a text line visible is listbox specific (for the ap_list) and will be moved to ui_day_sel_move(), where it is needed. Boundary checks for the listbox selection have been moved to listbox_fix_sel(). For future use listbox_sel_move() returns success or failure. The function wins_scrollwin_ensure_visible() has been renamed wins_scrollwin_in_view(). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/wins.c')
-rw-r--r--src/wins.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/wins.c b/src/wins.c
index 0cc7ff7..51d8072 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -415,13 +415,14 @@ void wins_scrollwin_down(struct scrollwin *sw, int amount)
sw->line_off = sw->line_num - inner_h;
}
-void wins_scrollwin_ensure_visible(struct scrollwin *sw, unsigned line)
+/* Keep 'line' in the viewport of a scrollwindow. */
+void wins_scrollwin_in_view(struct scrollwin *sw, unsigned line)
{
int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
if (line < sw->line_off)
sw->line_off = line;
- else if (line >= sw->line_off + inner_h)
+ else if (line > sw->line_off + inner_h - 1)
sw->line_off = line - inner_h + 1;
}