First day of week can now be any day
Previously only Sunday and Monday were allowed as the first day of the week, and this was internally treated as a binary variable. This patch allows for users to change the first day of the week to any day. Addresses GitHub feature request #321. Signed-off-by: Morgan Seltzer <MorganSeltzer000@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
e3fc73e0c7
commit
ee8ebebf92
16
src/config.c
16
src/config.c
@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
#include "calcurse.h"
|
#include "calcurse.h"
|
||||||
|
|
||||||
@ -261,15 +263,17 @@ static int config_parse_default_panel(void *dummy, const char *val)
|
|||||||
|
|
||||||
static int config_parse_first_day_of_week(void *dummy, const char *val)
|
static int config_parse_first_day_of_week(void *dummy, const char *val)
|
||||||
{
|
{
|
||||||
if (!strcmp(val, "monday"))
|
int i;
|
||||||
ui_calendar_set_first_day_of_week(MONDAY);
|
|
||||||
else if (!strcmp(val, "sunday"))
|
|
||||||
ui_calendar_set_first_day_of_week(SUNDAY);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
for (i = 0; i < WEEKINDAYS; i++) {
|
||||||
|
if(!strcasecmp(val, get_wday_default_string(i))) {
|
||||||
|
ui_calendar_set_first_day_of_week(i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int config_parse_color_theme(void *dummy, const char *val)
|
static int config_parse_color_theme(void *dummy, const char *val)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <langinfo.h>
|
||||||
|
|
||||||
#include "calcurse.h"
|
#include "calcurse.h"
|
||||||
|
|
||||||
@ -702,8 +703,7 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
|
|||||||
case FIRST_DAY_OF_WEEK:
|
case FIRST_DAY_OF_WEEK:
|
||||||
custom_apply_attr(win, ATTR_HIGHEST);
|
custom_apply_attr(win, ATTR_HIGHEST);
|
||||||
mvwaddstr(win, y, XPOS + strlen(opt[FIRST_DAY_OF_WEEK]),
|
mvwaddstr(win, y, XPOS + strlen(opt[FIRST_DAY_OF_WEEK]),
|
||||||
ui_calendar_get_wday_start()? _("Monday") :
|
nl_langinfo(DAY_1 + ui_calendar_get_wday_start()));
|
||||||
_("Sunday"));
|
|
||||||
custom_remove_attr(win, ATTR_HIGHEST);
|
custom_remove_attr(win, ATTR_HIGHEST);
|
||||||
mvwaddstr(win, y + 1, XPOS,
|
mvwaddstr(win, y + 1, XPOS,
|
||||||
_("(specifies the first day of week in the calendar view)"));
|
_("(specifies the first day of week in the calendar view)"));
|
||||||
|
@ -159,7 +159,9 @@ void ui_calendar_set_first_day_of_week(enum wday first_day)
|
|||||||
/* Swap first day of week in calendar. */
|
/* Swap first day of week in calendar. */
|
||||||
void ui_calendar_change_first_day_of_week(void)
|
void ui_calendar_change_first_day_of_week(void)
|
||||||
{
|
{
|
||||||
wday_start = !wday_start;
|
wday_start++;
|
||||||
|
if(wday_start >= WEEKINDAYS)
|
||||||
|
wday_start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 if week begins on monday, 0 otherwise. */
|
/* Return 1 if week begins on monday, 0 otherwise. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user