Allow configuration of appointment time format

Added the option to configure the format in which appointment time is
displayed. The setting is called "format.appointmenttime" under the
general settings menu. Setting defaults to previous behavior, which was
"%H:%M".

Signed-off-by: mercurialmoon <mercurialmoon@protonmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
mercurialmoon
2020-12-23 19:15:05 -08:00
committed by Lukas Fleischer
parent 9b148900b8
commit a49adf2db7
5 changed files with 32 additions and 8 deletions

View File

@@ -545,6 +545,7 @@ enum {
INPUT_DATE_FMT,
HEADING_POS,
DAY_HEADING_FMT,
APPOINTMENT_TIME_FMT,
NB_OPTIONS
};
@@ -573,7 +574,8 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
"format.outputdate = ",
"format.inputdate = ",
"appearance.headingposition = ",
"format.dayheading = "
"format.dayheading = ",
"format.appointmenttime = "
};
const char *panel;
const char *position;
@@ -746,6 +748,14 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
mvwaddstr(win, y + 1, XPOS,
_("(Format of the date displayed in the appointments panel)"));
break;
case APPOINTMENT_TIME_FMT:
custom_apply_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y, XPOS + strlen(opt[APPOINTMENT_TIME_FMT]),
conf.timefmt);
custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS,
_("(Format of the time displayed in the appointments panel)"));
break;
}
if (hilt)
@@ -771,6 +781,8 @@ static void general_option_edit(int i)
_("Enter a text string (an empty string for the default text)");
const char *output_datefmt_str =
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
const char *output_timefmt_str =
_("Enter the time format (see 'man 3 strftime' for possible formats) ");
const char *input_datefmt_prefix = _("Enter the date format: ");
const char *periodic_save_str =
_("Enter the delay, in minutes, between automatic saves (0 to disable) ");
@@ -893,6 +905,15 @@ static void general_option_edit(int i)
conf.day_heading[BUFSIZ - 1] = '\0';
}
break;
case APPOINTMENT_TIME_FMT:
status_mesg(output_timefmt_str, "");
strncpy(buf, conf.timefmt, BUFSIZ);
buf[BUFSIZ - 1] = '\0';
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
strncpy(conf.timefmt, buf, BUFSIZ);
conf.timefmt[BUFSIZ - 1] = '\0';
}
break;
}
mem_free(buf);