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>
This commit is contained in:
parent
550a2e9379
commit
d56cc7acfe
@ -264,6 +264,7 @@ struct conf {
|
|||||||
const char *mergetool;
|
const char *mergetool;
|
||||||
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
char output_datefmt[BUFSIZ]; /* format for displaying date */
|
||||||
int input_datefmt; /* format for reading date */
|
int input_datefmt; /* format for reading date */
|
||||||
|
char day_heading[BUFSIZ]; /* format for displaying heading in appts panel */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Daemon-related configuration. */
|
/* Daemon-related configuration. */
|
||||||
@ -291,6 +292,9 @@ enum datefmt {
|
|||||||
_("mm/dd/yyyy") : (datefmt == DATEFMT_DDMMYYYY ? _("dd/mm/yyyy") : \
|
_("mm/dd/yyyy") : (datefmt == DATEFMT_DDMMYYYY ? _("dd/mm/yyyy") : \
|
||||||
(datefmt == DATEFMT_YYYYMMDD ? _("yyyy/mm/dd") : _("yyyy-mm-dd"))))
|
(datefmt == DATEFMT_YYYYMMDD ? _("yyyy/mm/dd") : _("yyyy-mm-dd"))))
|
||||||
|
|
||||||
|
/* Day heading default format. */
|
||||||
|
#define DAY_HEADING_DEFAULT "%B %-d, %Y"
|
||||||
|
|
||||||
struct date {
|
struct date {
|
||||||
unsigned dd;
|
unsigned dd;
|
||||||
unsigned mm;
|
unsigned mm;
|
||||||
|
@ -102,6 +102,7 @@ static const struct confvar confmap[] = {
|
|||||||
{"format.notifydate", CONFIG_HANDLER_STR(nbar.datefmt)},
|
{"format.notifydate", CONFIG_HANDLER_STR(nbar.datefmt)},
|
||||||
{"format.notifytime", CONFIG_HANDLER_STR(nbar.timefmt)},
|
{"format.notifytime", CONFIG_HANDLER_STR(nbar.timefmt)},
|
||||||
{"format.outputdate", config_parse_output_datefmt, config_serialize_output_datefmt, NULL},
|
{"format.outputdate", config_parse_output_datefmt, config_serialize_output_datefmt, NULL},
|
||||||
|
{"format.dayheading", CONFIG_HANDLER_STR(conf.day_heading)},
|
||||||
{"general.autogc", CONFIG_HANDLER_BOOL(conf.auto_gc)},
|
{"general.autogc", CONFIG_HANDLER_BOOL(conf.auto_gc)},
|
||||||
{"general.autosave", CONFIG_HANDLER_BOOL(conf.auto_save)},
|
{"general.autosave", CONFIG_HANDLER_BOOL(conf.auto_save)},
|
||||||
{"general.confirmdelete", CONFIG_HANDLER_BOOL(conf.confirm_delete)},
|
{"general.confirmdelete", CONFIG_HANDLER_BOOL(conf.confirm_delete)},
|
||||||
|
20
src/custom.c
20
src/custom.c
@ -531,6 +531,7 @@ enum {
|
|||||||
FIRST_DAY_OF_WEEK,
|
FIRST_DAY_OF_WEEK,
|
||||||
OUTPUT_DATE_FMT,
|
OUTPUT_DATE_FMT,
|
||||||
INPUT_DATE_FMT,
|
INPUT_DATE_FMT,
|
||||||
|
DAY_HEADING_FMT,
|
||||||
NB_OPTIONS
|
NB_OPTIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -550,7 +551,8 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
|
|||||||
"general.progressbar = ",
|
"general.progressbar = ",
|
||||||
"general.firstdayofweek = ",
|
"general.firstdayofweek = ",
|
||||||
"format.outputdate = ",
|
"format.outputdate = ",
|
||||||
"format.inputdate = "
|
"format.inputdate = ",
|
||||||
|
"format.dayheading = "
|
||||||
};
|
};
|
||||||
const char *panel;
|
const char *panel;
|
||||||
|
|
||||||
@ -654,6 +656,14 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
|
|||||||
datefmt_str[0], datefmt_str[1], datefmt_str[2],
|
datefmt_str[0], datefmt_str[1], datefmt_str[2],
|
||||||
datefmt_str[3]);
|
datefmt_str[3]);
|
||||||
break;
|
break;
|
||||||
|
case DAY_HEADING_FMT:
|
||||||
|
custom_apply_attr(win, ATTR_HIGHEST);
|
||||||
|
mvwaddstr(win, y, XPOS + strlen(opt[DAY_HEADING_FMT]),
|
||||||
|
conf.day_heading);
|
||||||
|
custom_remove_attr(win, ATTR_HIGHEST);
|
||||||
|
mvwaddstr(win, y + 1, XPOS,
|
||||||
|
_("(Format of the date displayed in the appointments panel)"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hilt)
|
if (hilt)
|
||||||
@ -752,6 +762,14 @@ static void general_option_edit(int i)
|
|||||||
if (val != -1)
|
if (val != -1)
|
||||||
conf.input_datefmt = val;
|
conf.input_datefmt = val;
|
||||||
break;
|
break;
|
||||||
|
case DAY_HEADING_FMT:
|
||||||
|
status_mesg(output_datefmt_str, "");
|
||||||
|
strcpy(buf, conf.day_heading);
|
||||||
|
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
||||||
|
strcpy(conf.day_heading, buf);
|
||||||
|
}
|
||||||
|
status_mesg(number_str, keys);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_free(buf);
|
mem_free(buf);
|
||||||
|
21
src/ui-day.c
21
src/ui-day.c
@ -909,6 +909,17 @@ void ui_day_sel_move(int delta)
|
|||||||
listbox_sel_move(&lb_apt, 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. */
|
/* Display appointments in the corresponding panel. */
|
||||||
void ui_day_draw(int n, WINDOW *win, int y, int hilt, void *cb_data)
|
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;
|
int width = lb_apt.sw.w - 2;
|
||||||
|
|
||||||
hilt = hilt && (wins_slctd() == APP);
|
hilt = hilt && (wins_slctd() == APP);
|
||||||
|
|
||||||
if (item->type == EVNT || item->type == RECUR_EVNT) {
|
if (item->type == EVNT || item->type == RECUR_EVNT) {
|
||||||
day_display_item(item, win, !hilt, width - 1, y, 1);
|
day_display_item(item, win, !hilt, width - 1, y, 1);
|
||||||
} else if (item->type == APPT || item->type == RECUR_APPT) {
|
} else if (item->type == APPT || item->type == RECUR_APPT) {
|
||||||
day_display_item_date(item, win, !hilt, date, y, 1);
|
day_display_item_date(item, win, !hilt, date, y, 1);
|
||||||
day_display_item(item, win, !hilt, width - 1, y + 1, 1);
|
day_display_item(item, win, !hilt, width - 1, y + 1, 1);
|
||||||
} else if (item->type == DAY_HEADING) {
|
} 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);
|
custom_apply_attr(win, ATTR_HIGHEST);
|
||||||
mvwprintw(win, y, x, "%s %s %02d, %04d",
|
mvwprintw(win, y, width - utf8_strwidth(buf) - 1, "%s", buf);
|
||||||
ui_calendar_get_pom(date),
|
|
||||||
_(monthnames[slctd_date.mm - 1]), slctd_date.dd,
|
|
||||||
slctd_date.yyyy);
|
|
||||||
custom_remove_attr(win, ATTR_HIGHEST);
|
custom_remove_attr(win, ATTR_HIGHEST);
|
||||||
|
mem_free(buf);
|
||||||
} else if (item->type == DAY_SEPARATOR) {
|
} else if (item->type == DAY_SEPARATOR) {
|
||||||
wmove(win, y, 0);
|
wmove(win, y, 0);
|
||||||
whline(win, 0, width);
|
whline(win, 0, width);
|
||||||
|
@ -147,6 +147,7 @@ void vars_init(void)
|
|||||||
conf.progress_bar = 1;
|
conf.progress_bar = 1;
|
||||||
strncpy(conf.output_datefmt, "%D", 3);
|
strncpy(conf.output_datefmt, "%D", 3);
|
||||||
conf.input_datefmt = 1;
|
conf.input_datefmt = 1;
|
||||||
|
strcpy(conf.day_heading, DAY_HEADING_DEFAULT);
|
||||||
|
|
||||||
datefmt_str[0] = _("mm/dd/yyyy");
|
datefmt_str[0] = _("mm/dd/yyyy");
|
||||||
datefmt_str[1] = _("dd/mm/yyyy");
|
datefmt_str[1] = _("dd/mm/yyyy");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user