aboutsummaryrefslogtreecommitdiffstats
path: root/src/day.c
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2019-05-14 07:10:33 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2019-05-26 10:04:28 -0400
commitd15f1e9242f77d9021af8c4b45eec96eb82a8eb6 (patch)
tree82576fecf3b52d08cc6b8d99925ce017c4e1615d /src/day.c
parent4db9677119f412fd38440e5591afbfb631a11b3d (diff)
downloadcalcurse-d15f1e9242f77d9021af8c4b45eec96eb82a8eb6.tar.gz
calcurse-d15f1e9242f77d9021af8c4b45eec96eb82a8eb6.zip
Automate the calculation of number of days to load
Instead of having the user tell how many days to load, calcurse can calculate an overestimation from the running configuration (panel size, appearance of headers and separators etc.) The configuration variable conf.multiple_days is turned into a Boolean that switches the feature on and off. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/day.c')
-rw-r--r--src/day.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/day.c b/src/day.c
index b556481..5bbc0a4 100644
--- a/src/day.c
+++ b/src/day.c
@@ -106,9 +106,22 @@ int day_sel_index(void)
return -1;
}
+/*
+ * Return the number of days to load in the appointments panel.
+ */
int day_get_days(void)
{
- return conf.multiple_days;
+ int panel, day;
+
+ if (!conf.multiple_days)
+ return 1;
+
+ panel = win[APP].h - (conf.compact_panels ? 2 : 4);
+ /* Assume one event per day (no event separator). */
+ day = 2 + conf.header_line + conf.day_separator + conf.empty_appt_line;
+
+ /* Round up. */
+ return panel / day + (panel % day != 0);
}
static void day_free(struct day_item *day)