aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/calcurse.h31
-rw-r--r--src/config.c20
-rw-r--r--src/custom.c35
-rw-r--r--src/vars.c2
4 files changed, 66 insertions, 22 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 40e253e..a026896 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -256,8 +256,24 @@ enum pos {
RIGHT
};
+/* Available views for the calendar panel. */
+enum cal_view {
+ CAL_MONTH_VIEW,
+ CAL_WEEK_VIEW,
+ CAL_VIEWS
+};
+
+/* Available views for the todo panel. */
+enum todo_view {
+ TODO_SHOW_COMPLETED_VIEW,
+ TODO_HIDE_COMPLETED_VIEW,
+ TODO_VIEWS
+};
+
/* General configuration variables. */
struct conf {
+ enum cal_view cal_view;
+ enum todo_view todo_view;
unsigned auto_save;
unsigned auto_gc;
unsigned periodic_save;
@@ -447,20 +463,7 @@ struct day_item {
union aptev_ptr item;
};
-/* Available views for the calendar panel. */
-enum {
- CAL_MONTH_VIEW,
- CAL_WEEK_VIEW,
- CAL_VIEWS
-};
-
-/* Available views for the todo panel. */
-enum {
- TODO_SHOW_COMPLETED_VIEW,
- TODO_HIDE_COMPLETED_VIEW,
- TODO_VIEWS
-};
-
+/* Shared variables for the notification threads. */
struct notify_app {
long time;
int got_app;
diff --git a/src/config.c b/src/config.c
index ca81c67..a728c83 100644
--- a/src/config.c
+++ b/src/config.c
@@ -213,11 +213,13 @@ static int config_parse_color_pair(int *dest1, int *dest2, const char *val)
static int config_parse_calendar_view(void *dummy, const char *val)
{
- if (!strcmp(val, "monthly"))
+ if (!strcmp(val, "monthly")) {
ui_calendar_set_view(CAL_MONTH_VIEW);
- else if (!strcmp(val, "weekly"))
+ conf.cal_view = CAL_MONTH_VIEW;
+ } else if (!strcmp(val, "weekly")) {
ui_calendar_set_view(CAL_WEEK_VIEW);
- else
+ conf.cal_view = CAL_WEEK_VIEW;
+ } else
return 0;
return 1;
@@ -225,11 +227,13 @@ static int config_parse_calendar_view(void *dummy, const char *val)
static int config_parse_todo_view(void *dummy, const char *val)
{
- if (!strcmp(val, "show-completed"))
+ if (!strcmp(val, "show-completed")) {
ui_todo_set_view(TODO_SHOW_COMPLETED_VIEW);
- else if (!strcmp(val, "hide-completed"))
+ conf.todo_view = TODO_SHOW_COMPLETED_VIEW;
+ } else if (!strcmp(val, "hide-completed")) {
ui_todo_set_view(TODO_HIDE_COMPLETED_VIEW);
- else
+ conf.todo_view = TODO_HIDE_COMPLETED_VIEW;
+ } else
return 0;
return 1;
@@ -426,7 +430,7 @@ static char *config_color_theme_name(void)
static int config_serialize_calendar_view(char **buf, void *dummy)
{
- if (ui_calendar_get_view() == CAL_WEEK_VIEW)
+ if (conf.cal_view == CAL_WEEK_VIEW)
*buf = mem_strdup("weekly");
else
*buf = mem_strdup("monthly");
@@ -436,7 +440,7 @@ static int config_serialize_calendar_view(char **buf, void *dummy)
static int config_serialize_todo_view(char **buf, void *dummy)
{
- if (ui_todo_get_view() == TODO_SHOW_COMPLETED_VIEW)
+ if (conf.todo_view == TODO_SHOW_COMPLETED_VIEW)
*buf = mem_strdup("show-completed");
else
*buf = mem_strdup("hide-completed");
diff --git a/src/custom.c b/src/custom.c
index df5c174..7771349 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -526,6 +526,8 @@ void custom_color_config(void)
enum {
COMPACT_PANELS,
DEFAULT_PANEL,
+ CAL_VIEW,
+ TODO_VIEW,
AUTO_SAVE,
AUTO_GC,
PERIODIC_SAVE,
@@ -548,6 +550,8 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
char *opt[NB_OPTIONS] = {
"appearance.compactpanels = ",
"appearance.defaultpanel = ",
+ "appearance.calendarview = ",
+ "appearance.todoview = ",
"general.autosave = ",
"general.autogc = ",
"general.periodicsave = ",
@@ -588,6 +592,22 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
mvwaddstr(win, y + 1, XPOS,
_("(specifies the panel that is selected by default)"));
break;
+ case CAL_VIEW:
+ custom_apply_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y, XPOS + strlen(opt[CAL_VIEW]),
+ conf.cal_view == CAL_MONTH_VIEW ?
+ _("monthly") : _("weekly"));
+ custom_remove_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y + 1, XPOS, _("(preferred calendar display)"));
+ break;
+ case TODO_VIEW:
+ custom_apply_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y, XPOS + strlen(opt[TODO_VIEW]),
+ conf.todo_view == TODO_SHOW_COMPLETED_VIEW ?
+ _("show completed") : _("hide completed"));
+ custom_remove_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y + 1, XPOS, _("(preferred todo display)"));
+ break;
case AUTO_SAVE:
print_bool_option_incolor(win, conf.auto_save, y,
XPOS + strlen(opt[AUTO_SAVE]));
@@ -727,6 +747,21 @@ static void general_option_edit(int i)
else
conf.default_panel++;
break;
+ case CAL_VIEW:
+ if (conf.cal_view == CAL_WEEK_VIEW)
+ conf.cal_view = CAL_MONTH_VIEW;
+ else
+ conf.cal_view++;
+ ui_calendar_set_view(conf.cal_view);
+ break;
+ case TODO_VIEW:
+ if (conf.todo_view == TODO_HIDE_COMPLETED_VIEW)
+ conf.todo_view = TODO_SHOW_COMPLETED_VIEW;
+ else
+ conf.todo_view++;
+ ui_todo_set_view(conf.todo_view);
+ ui_todo_load_items();
+ break;
case HEADING_POS:
if (conf.heading_pos == RIGHT)
conf.heading_pos = LEFT;
diff --git a/src/vars.c b/src/vars.c
index 4e51b98..80e8e5c 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -120,6 +120,8 @@ void vars_init(void)
const char *ed, *pg, *mt;
/* Variables for user configuration */
+ conf.cal_view = CAL_MONTH_VIEW;
+ conf.todo_view = TODO_HIDE_COMPLETED_VIEW;
conf.confirm_quit = 1;
conf.confirm_delete = 1;
conf.auto_save = 1;