Fix data type of "general.firstdayofweek"
This option wasn't converted to a proper data type when it was renamed from "week_begins_on_monday" to "general.firstdayofweek". Convert the boolean option into an enumeration type that can take the values "monday" and "sunday". Also, update the documentation, add a conversion rule to the upgrade script and convert the configuration file used in the test suite. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
dec97c7c81
commit
6c11b8985c
@ -756,11 +756,10 @@ These options control `calcurse` general behavior, as described below:
|
|||||||
If set to `0`, the monthly calendar view will be displayed by default
|
If set to `0`, the monthly calendar view will be displayed by default
|
||||||
otherwise it is the weekly view that will be displayed.
|
otherwise it is the weekly view that will be displayed.
|
||||||
|
|
||||||
`general.firstdayofweek` (default: *yes*)::
|
`general.firstdayofweek` (default: *monday*)::
|
||||||
One can choose between Monday and Sunday as the first day of the week. If the
|
One can choose between Monday and Sunday as the first day of the week. If
|
||||||
option `general.firstdayofweek` is set to *yes*, Monday will be first in the
|
`general.firstdayofweek` is set to *monday*, Monday will be first in the
|
||||||
calendar view. Else if the option is set to *no*, then Sunday will be the
|
calendar view. Otherwise, Sunday will be the first day of the week.
|
||||||
first day of the week.
|
|
||||||
|
|
||||||
`format.outputdate` (default: *%D*)::
|
`format.outputdate` (default: *%D*)::
|
||||||
This option indicates the format to be used when displaying dates in
|
This option indicates the format to be used when displaying dates in
|
||||||
|
@ -68,6 +68,7 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \
|
|||||||
BEGIN { FS=OFS="=" }
|
BEGIN { FS=OFS="=" }
|
||||||
$1 == "general.systemdialogs" || $1 == "general.progressbar" \
|
$1 == "general.systemdialogs" || $1 == "general.progressbar" \
|
||||||
{ $2 = ($2 == "yes") ? "no" : "yes" }
|
{ $2 = ($2 == "yes") ? "no" : "yes" }
|
||||||
|
$1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" }
|
||||||
{ print }
|
{ print }
|
||||||
' < "$CONFFILE" > "$tmpfile" || exit 1
|
' < "$CONFFILE" > "$tmpfile" || exit 1
|
||||||
mv "$tmpfile" "$CONFFILE" || exit 1
|
mv "$tmpfile" "$CONFFILE" || exit 1
|
||||||
|
18
src/config.c
18
src/config.c
@ -204,16 +204,14 @@ config_parse_calendar_view (void *dummy, const char *val)
|
|||||||
static int
|
static int
|
||||||
config_parse_first_day_of_week (void *dummy, const char *val)
|
config_parse_first_day_of_week (void *dummy, const char *val)
|
||||||
{
|
{
|
||||||
unsigned tmp;
|
if (!strcmp (val, "monday"))
|
||||||
if (config_parse_bool (&tmp, val)) {
|
|
||||||
if (tmp)
|
|
||||||
calendar_set_first_day_of_week (MONDAY);
|
calendar_set_first_day_of_week (MONDAY);
|
||||||
else
|
else if (!strcmp (val, "sunday"))
|
||||||
calendar_set_first_day_of_week (SUNDAY);
|
calendar_set_first_day_of_week (SUNDAY);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -381,8 +379,12 @@ config_serialize_calendar_view (char *buf, void *dummy)
|
|||||||
static int
|
static int
|
||||||
config_serialize_first_day_of_week (char *buf, void *dummy)
|
config_serialize_first_day_of_week (char *buf, void *dummy)
|
||||||
{
|
{
|
||||||
unsigned tmp = calendar_week_begins_on_monday ();
|
if (calendar_week_begins_on_monday ())
|
||||||
return config_serialize_bool (buf, &tmp);
|
strcpy(buf, "monday");
|
||||||
|
else
|
||||||
|
strcpy(buf, "sunday");
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
13
src/custom.c
13
src/custom.c
@ -630,7 +630,7 @@ print_general_options (WINDOW *win)
|
|||||||
CONFIRM_DELETE,
|
CONFIRM_DELETE,
|
||||||
SYSTEM_DIAGS,
|
SYSTEM_DIAGS,
|
||||||
PROGRESS_BAR,
|
PROGRESS_BAR,
|
||||||
WEEK_BEGINS_MONDAY,
|
FIRST_DAY_OF_WEEK,
|
||||||
OUTPUT_DATE_FMT,
|
OUTPUT_DATE_FMT,
|
||||||
INPUT_DATE_FMT,
|
INPUT_DATE_FMT,
|
||||||
NB_OPTIONS
|
NB_OPTIONS
|
||||||
@ -700,12 +700,13 @@ print_general_options (WINDOW *win)
|
|||||||
_("(if set to YES, progress bar will be displayed "
|
_("(if set to YES, progress bar will be displayed "
|
||||||
"when saving data)"));
|
"when saving data)"));
|
||||||
y += YOFF;
|
y += YOFF;
|
||||||
mvwprintw (win, y, XPOS, "[8] %s ", opt[WEEK_BEGINS_MONDAY]);
|
mvwprintw (win, y, XPOS, "[8] %s ", opt[FIRST_DAY_OF_WEEK]);
|
||||||
print_bool_option_incolor (win, calendar_week_begins_on_monday (), y,
|
custom_apply_attr (win, ATTR_HIGHEST);
|
||||||
XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY]));
|
mvwprintw (win, y, XPOS + 4 + strlen (opt[FIRST_DAY_OF_WEEK]), "%s",
|
||||||
|
calendar_week_begins_on_monday () ? _("Monday") : _("Sunday"));
|
||||||
|
custom_remove_attr (win, ATTR_HIGHEST);
|
||||||
mvwprintw (win, y + 1, XPOS,
|
mvwprintw (win, y + 1, XPOS,
|
||||||
_("(if set to YES, monday is the first day of the week, "
|
_("(specifies the first day of week in the calendar view)"));
|
||||||
"else it is sunday)"));
|
|
||||||
y += YOFF;
|
y += YOFF;
|
||||||
mvwprintw (win, y, XPOS, "[9] %s ", opt[OUTPUT_DATE_FMT]);
|
mvwprintw (win, y, XPOS, "[9] %s ", opt[OUTPUT_DATE_FMT]);
|
||||||
custom_apply_attr (win, ATTR_HIGHEST);
|
custom_apply_attr (win, ATTR_HIGHEST);
|
||||||
|
@ -33,7 +33,7 @@ general.progressbar=no
|
|||||||
appearance.calendarview=0
|
appearance.calendarview=0
|
||||||
|
|
||||||
# If this option is set to yes, monday is the first day of the week, else it is sunday
|
# If this option is set to yes, monday is the first day of the week, else it is sunday
|
||||||
general.firstdayofweek=yes
|
general.firstdayofweek=monday
|
||||||
|
|
||||||
# This is the color theme used for menus :
|
# This is the color theme used for menus :
|
||||||
appearance.theme=red on default
|
appearance.theme=red on default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user