diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2017-08-19 10:23:52 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2017-08-28 07:30:38 +0200 |
commit | d56cc7acfe85119b70f7aac8dfd13ba41ec119e3 (patch) | |
tree | 69ea8c6e3e5d67d09bf129f3e50c3f54cb01ce58 /src/ui-day.c | |
parent | 550a2e937906d7e3c821d7508901eea2dafd9344 (diff) | |
download | calcurse-d56cc7acfe85119b70f7aac8dfd13ba41ec119e3.tar.gz calcurse-d56cc7acfe85119b70f7aac8dfd13ba41ec119e3.zip |
Make heading in appointments panel configurable
Add a new configuration variable format.dayheading to set the format of
the date displayed at the top of the event and appointment list.
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/ui-day.c')
-rw-r--r-- | src/ui-day.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ui-day.c b/src/ui-day.c index 24717dc..ab588fd 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -909,6 +909,17 @@ void ui_day_sel_move(int delta) listbox_sel_move(&lb_apt, delta); } +static char *fmt_day_heading(time_t date) +{ + struct tm tm; + struct string s; + + localtime_r(&date, &tm); + string_printf(&s, "%s ", ui_calendar_get_pom(date)); + string_catftime(&s, conf.day_heading, &tm); + return string_buf(&s); +} + /* Display appointments in the corresponding panel. */ void ui_day_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) { @@ -918,20 +929,18 @@ void ui_day_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) int width = lb_apt.sw.w - 2; hilt = hilt && (wins_slctd() == APP); - if (item->type == EVNT || item->type == RECUR_EVNT) { day_display_item(item, win, !hilt, width - 1, y, 1); } else if (item->type == APPT || item->type == RECUR_APPT) { day_display_item_date(item, win, !hilt, date, y, 1); day_display_item(item, win, !hilt, width - 1, y + 1, 1); } else if (item->type == DAY_HEADING) { - unsigned x = width - (strlen(_(monthnames[slctd_date.mm - 1])) + 15); + char *buf = fmt_day_heading(date); + utf8_chop(buf, width); custom_apply_attr(win, ATTR_HIGHEST); - mvwprintw(win, y, x, "%s %s %02d, %04d", - ui_calendar_get_pom(date), - _(monthnames[slctd_date.mm - 1]), slctd_date.dd, - slctd_date.yyyy); + mvwprintw(win, y, width - utf8_strwidth(buf) - 1, "%s", buf); custom_remove_attr(win, ATTR_HIGHEST); + mem_free(buf); } else if (item->type == DAY_SEPARATOR) { wmove(win, y, 0); whline(win, 0, width); |