aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-12-28 09:55:16 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-05-22 01:56:59 -0400
commit80ce812effec8190bfbb1986dced1b143162a4c8 (patch)
tree2c1087f0754b5d186273766440a5435c8f947ec9
parent0bb4a59b5fb089062f0eb369d39289ff1ccfc2ba (diff)
downloadcalcurse-80ce812effec8190bfbb1986dced1b143162a4c8.tar.gz
calcurse-80ce812effec8190bfbb1986dced1b143162a4c8.zip
Add configuration variables for multiple days
The number of days displayed in the APP panel has been made configurable, maximum 21 days, default seven days. With several days in the APP panel, it may be desirable to "squeeze" the entries by leaving out the final empty line of each appointment and lower the number of lines between consecutive days (0, 1, or 2). Both are made general configuration options. To make a uniform display, an empty line is added to a day without appointments, if appointments have an empty line. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/calcurse.h3
-rw-r--r--src/config.c3
-rw-r--r--src/custom.c52
-rw-r--r--src/day.c7
-rw-r--r--src/ui-day.c4
-rw-r--r--src/vars.c3
6 files changed, 64 insertions, 8 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index afe4430..3429ee2 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -282,6 +282,9 @@ struct conf {
enum win default_panel;
unsigned compact_panels;
unsigned system_dialogs;
+ unsigned multiple_days;
+ unsigned dayseparator;
+ unsigned empty_appt_line;
const char *editor;
const char *pager;
const char *mergetool;
diff --git a/src/config.c b/src/config.c
index a6c5e59..1f61f62 100644
--- a/src/config.c
+++ b/src/config.c
@@ -94,6 +94,8 @@ static const struct confvar confmap[] = {
{"appearance.compactpanels", CONFIG_HANDLER_BOOL(conf.compact_panels)},
{"appearance.defaultpanel", config_parse_default_panel, config_serialize_default_panel, NULL},
{"appearance.layout", config_parse_layout, config_serialize_layout, NULL},
+ {"appearance.dayseparator", CONFIG_HANDLER_UNSIGNED(conf.dayseparator)},
+ {"appearance.emptyline", CONFIG_HANDLER_BOOL(conf.empty_appt_line)},
{"appearance.notifybar", CONFIG_HANDLER_BOOL(nbar.show)},
{"appearance.sidebarwidth", config_parse_sidebar_width, config_serialize_sidebar_width, NULL},
{"appearance.theme", config_parse_color_theme, config_serialize_color_theme, NULL},
@@ -111,6 +113,7 @@ static const struct confvar confmap[] = {
{"general.confirmdelete", CONFIG_HANDLER_BOOL(conf.confirm_delete)},
{"general.confirmquit", CONFIG_HANDLER_BOOL(conf.confirm_quit)},
{"general.firstdayofweek", config_parse_first_day_of_week, config_serialize_first_day_of_week, NULL},
+ {"general.multipledays", CONFIG_HANDLER_UNSIGNED(conf.multiple_days)},
{"general.periodicsave", CONFIG_HANDLER_UNSIGNED(conf.periodic_save)},
{"general.systemevents", CONFIG_HANDLER_BOOL(conf.systemevents)},
{"general.systemdialogs", CONFIG_HANDLER_BOOL(conf.system_dialogs)},
diff --git a/src/custom.c b/src/custom.c
index f3498b8..b5890cd 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -528,6 +528,9 @@ enum {
DEFAULT_PANEL,
CAL_VIEW,
TODO_VIEW,
+ MULTIPLE_DAYS,
+ DAYSEPARATOR,
+ EMPTY_APPT_LINE,
AUTO_SAVE,
AUTO_GC,
PERIODIC_SAVE,
@@ -552,6 +555,9 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
"appearance.defaultpanel = ",
"appearance.calendarview = ",
"appearance.todoview = ",
+ "general.multipledays = ",
+ "appearance.dayseparator = ",
+ "appearance.emptyline = ",
"general.autosave = ",
"general.autogc = ",
"general.periodicsave = ",
@@ -608,6 +614,30 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS, _("(preferred todo display)"));
break;
+ case DAYSEPARATOR:
+ custom_apply_attr(win, ATTR_HIGHEST);
+ mvwprintw(win, y, XPOS + strlen(opt[DAYSEPARATOR]), "%d",
+ conf.dayseparator);
+ custom_remove_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y + 1, XPOS,
+ _("(lines between days in the appointments "
+ "panel)"));
+ break;
+ case EMPTY_APPT_LINE:
+ print_bool_option_incolor(win, conf.empty_appt_line, y,
+ XPOS + strlen(opt[EMPTY_APPT_LINE]));
+ mvwaddstr(win, y + 1, XPOS,
+ _("(insert an empty line after each appointment)"));
+ break;
+ case MULTIPLE_DAYS:
+ custom_apply_attr(win, ATTR_HIGHEST);
+ mvwprintw(win, y, XPOS + strlen(opt[MULTIPLE_DAYS]), "%d",
+ conf.multiple_days);
+ custom_remove_attr(win, ATTR_HIGHEST);
+ mvwaddstr(win, y + 1, XPOS,
+ _("(number of days (1..21) to display in the appointments "
+ "panel)"));
+ break;
case AUTO_SAVE:
print_bool_option_incolor(win, conf.auto_save, y,
XPOS + strlen(opt[AUTO_SAVE]));
@@ -626,14 +656,15 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
conf.periodic_save);
custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS,
- _("(if not null, automatically save data every 'periodic_save' "
- "minutes)"));
+ _("(if not null, automatically save data every "
+ "'periodic_save' minutes)"));
break;
case SYSTEM_EVENTS:
print_bool_option_incolor(win, conf.systemevents, y,
XPOS + strlen(opt[SYSTEM_EVENTS]));
mvwaddstr(win, y + 1, XPOS,
- _("(if YES, system events are turned into appointments (or else deleted))"));
+ _("(if YES, system events are turned into "
+ "appointments (or else deleted))"));
break;
case CONFIRM_QUIT:
print_bool_option_incolor(win, conf.confirm_quit, y,
@@ -762,6 +793,21 @@ static void general_option_edit(int i)
ui_todo_set_view(conf.todo_view);
ui_todo_load_items();
break;
+ case EMPTY_APPT_LINE:
+ conf.empty_appt_line = !conf.empty_appt_line;
+ break;
+ case MULTIPLE_DAYS:
+ if (conf.multiple_days == 21)
+ conf.multiple_days = 1;
+ else
+ conf.multiple_days++;
+ break;
+ case DAYSEPARATOR:
+ if (conf.dayseparator == 2)
+ conf.dayseparator = 0;
+ else
+ conf.dayseparator++;
+ break;
case HEADING_POS:
if (conf.heading_pos == RIGHT)
conf.heading_pos = LEFT;
diff --git a/src/day.c b/src/day.c
index c88713c..44f9540 100644
--- a/src/day.c
+++ b/src/day.c
@@ -42,7 +42,6 @@
#include "calcurse.h"
-static unsigned day_days = 5;
static vector_t day_items;
static unsigned day_items_nb = 0;
@@ -109,7 +108,7 @@ int day_sel_index(void)
int day_get_days(void)
{
- return day_days;
+ return conf.multiple_days;
}
static void day_free(struct day_item *day)
@@ -462,8 +461,8 @@ day_store_items(time_t date, int include_captions, int n)
}
if (include_captions) {
- /* Two empty lines between days. */
- if (apts == 0)
+ /* Empty line at end of day if appointments have one. */
+ if (apts == 0 && conf.empty_appt_line)
day_add_item(EMPTY_SEPARATOR, 0, ENDOFDAY(date), p);
day_add_item(DAY_SEPARATOR, 0, ENDOFDAY(date), p);
}
diff --git a/src/ui-day.c b/src/ui-day.c
index ab4e7d9..f7fddef 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -1144,7 +1144,9 @@ int ui_day_height(int n, void *cb_data)
if (item->type == APPT ||
item->type == RECUR_APPT)
- return 3;
+ return conf.empty_appt_line ? 3 : 2;
+ else if (item->type == DAY_SEPARATOR)
+ return conf.dayseparator;
else
return 1;
}
diff --git a/src/vars.c b/src/vars.c
index 80e8e5c..d3080eb 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -122,6 +122,9 @@ void vars_init(void)
/* Variables for user configuration */
conf.cal_view = CAL_MONTH_VIEW;
conf.todo_view = TODO_HIDE_COMPLETED_VIEW;
+ conf.empty_appt_line = 1;
+ conf.multiple_days = 7;
+ conf.dayseparator = 2;
conf.confirm_quit = 1;
conf.confirm_delete = 1;
conf.auto_save = 1;