diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2019-05-14 07:10:33 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2019-05-26 10:04:28 -0400 |
commit | d15f1e9242f77d9021af8c4b45eec96eb82a8eb6 (patch) | |
tree | 82576fecf3b52d08cc6b8d99925ce017c4e1615d /src/day.c | |
parent | 4db9677119f412fd38440e5591afbfb631a11b3d (diff) | |
download | calcurse-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.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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) |