Fix calendar (re)draw

Window erasure is moved to the drawing functions.

Adresses GitHub issue #196.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2018-01-25 00:06:20 +01:00 committed by Lukas Fleischer
parent 45fd62cab4
commit 90f96059c5

View File

@ -64,9 +64,6 @@ void ui_calendar_view_next(void)
ui_calendar_view++; ui_calendar_view++;
if (ui_calendar_view == CAL_VIEWS) if (ui_calendar_view == CAL_VIEWS)
ui_calendar_view = 0; ui_calendar_view = 0;
/* The calendar panel needs to be erased when switching views. */
werase(sw_cal.inner);
} }
void ui_calendar_view_prev(void) void ui_calendar_view_prev(void)
@ -74,9 +71,6 @@ void ui_calendar_view_prev(void)
if (ui_calendar_view == 0) if (ui_calendar_view == 0)
ui_calendar_view = CAL_VIEWS; ui_calendar_view = CAL_VIEWS;
ui_calendar_view--; ui_calendar_view--;
/* The calendar panel needs to be erased when switching views. */
werase(sw_cal.inner);
} }
void ui_calendar_set_view(int view) void ui_calendar_set_view(int view)
@ -362,6 +356,8 @@ draw_monthly_view(struct scrollwin *sw, struct date *current_day,
struct tm t; struct tm t;
char *cp; char *cp;
werase(sw->inner);
mo = slctd_day.mm; mo = slctd_day.mm;
yr = slctd_day.yyyy; yr = slctd_day.yyyy;
@ -389,10 +385,6 @@ draw_monthly_view(struct scrollwin *sw, struct date *current_day,
/* Write the current month and year on top of the calendar */ /* Write the current month and year on top of the calendar */
WINS_CALENDAR_LOCK; WINS_CALENDAR_LOCK;
if (yr * YEARINMONTHS + mo != monthly_view_cache_month) {
/* erase the window if a new month is selected */
werase(sw_cal.inner);
}
custom_apply_attr(sw->inner, ATTR_HIGHEST); custom_apply_attr(sw->inner, ATTR_HIGHEST);
cp = nl_langinfo(MON_1 + mo - 1); cp = nl_langinfo(MON_1 + mo - 1);
mvwprintw(sw->inner, ofs_y, (w - (strlen(cp) + 5)) / 2, mvwprintw(sw->inner, ofs_y, (w - (strlen(cp) + 5)) / 2,
@ -475,6 +467,8 @@ draw_weekly_view(struct scrollwin *sw, struct date *current_day,
struct tm t; struct tm t;
int OFFY, OFFX, j; int OFFY, OFFX, j;
werase(sw->inner);
OFFY = 0; OFFY = 0;
OFFX = (wins_sbar_width() - 2 - WCALWIDTH) / 2; OFFX = (wins_sbar_width() - 2 - WCALWIDTH) / 2;