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>
This commit is contained in:
Lars Henriksen 2018-12-28 09:55:16 +01:00 committed by Lukas Fleischer
parent 0bb4a59b5f
commit 80ce812eff
6 changed files with 64 additions and 8 deletions

View File

@ -282,6 +282,9 @@ struct conf {
enum win default_panel; enum win default_panel;
unsigned compact_panels; unsigned compact_panels;
unsigned system_dialogs; unsigned system_dialogs;
unsigned multiple_days;
unsigned dayseparator;
unsigned empty_appt_line;
const char *editor; const char *editor;
const char *pager; const char *pager;
const char *mergetool; const char *mergetool;

View File

@ -94,6 +94,8 @@ static const struct confvar confmap[] = {
{"appearance.compactpanels", CONFIG_HANDLER_BOOL(conf.compact_panels)}, {"appearance.compactpanels", CONFIG_HANDLER_BOOL(conf.compact_panels)},
{"appearance.defaultpanel", config_parse_default_panel, config_serialize_default_panel, NULL}, {"appearance.defaultpanel", config_parse_default_panel, config_serialize_default_panel, NULL},
{"appearance.layout", config_parse_layout, config_serialize_layout, 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.notifybar", CONFIG_HANDLER_BOOL(nbar.show)},
{"appearance.sidebarwidth", config_parse_sidebar_width, config_serialize_sidebar_width, NULL}, {"appearance.sidebarwidth", config_parse_sidebar_width, config_serialize_sidebar_width, NULL},
{"appearance.theme", config_parse_color_theme, config_serialize_color_theme, 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.confirmdelete", CONFIG_HANDLER_BOOL(conf.confirm_delete)},
{"general.confirmquit", CONFIG_HANDLER_BOOL(conf.confirm_quit)}, {"general.confirmquit", CONFIG_HANDLER_BOOL(conf.confirm_quit)},
{"general.firstdayofweek", config_parse_first_day_of_week, config_serialize_first_day_of_week, NULL}, {"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.periodicsave", CONFIG_HANDLER_UNSIGNED(conf.periodic_save)},
{"general.systemevents", CONFIG_HANDLER_BOOL(conf.systemevents)}, {"general.systemevents", CONFIG_HANDLER_BOOL(conf.systemevents)},
{"general.systemdialogs", CONFIG_HANDLER_BOOL(conf.system_dialogs)}, {"general.systemdialogs", CONFIG_HANDLER_BOOL(conf.system_dialogs)},

View File

@ -528,6 +528,9 @@ enum {
DEFAULT_PANEL, DEFAULT_PANEL,
CAL_VIEW, CAL_VIEW,
TODO_VIEW, TODO_VIEW,
MULTIPLE_DAYS,
DAYSEPARATOR,
EMPTY_APPT_LINE,
AUTO_SAVE, AUTO_SAVE,
AUTO_GC, AUTO_GC,
PERIODIC_SAVE, 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.defaultpanel = ",
"appearance.calendarview = ", "appearance.calendarview = ",
"appearance.todoview = ", "appearance.todoview = ",
"general.multipledays = ",
"appearance.dayseparator = ",
"appearance.emptyline = ",
"general.autosave = ", "general.autosave = ",
"general.autogc = ", "general.autogc = ",
"general.periodicsave = ", "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); custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS, _("(preferred todo display)")); mvwaddstr(win, y + 1, XPOS, _("(preferred todo display)"));
break; 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: case AUTO_SAVE:
print_bool_option_incolor(win, conf.auto_save, y, print_bool_option_incolor(win, conf.auto_save, y,
XPOS + strlen(opt[AUTO_SAVE])); 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); conf.periodic_save);
custom_remove_attr(win, ATTR_HIGHEST); custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(if not null, automatically save data every 'periodic_save' " _("(if not null, automatically save data every "
"minutes)")); "'periodic_save' minutes)"));
break; break;
case SYSTEM_EVENTS: case SYSTEM_EVENTS:
print_bool_option_incolor(win, conf.systemevents, y, print_bool_option_incolor(win, conf.systemevents, y,
XPOS + strlen(opt[SYSTEM_EVENTS])); XPOS + strlen(opt[SYSTEM_EVENTS]));
mvwaddstr(win, y + 1, XPOS, 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; break;
case CONFIRM_QUIT: case CONFIRM_QUIT:
print_bool_option_incolor(win, conf.confirm_quit, y, 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_set_view(conf.todo_view);
ui_todo_load_items(); ui_todo_load_items();
break; 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: case HEADING_POS:
if (conf.heading_pos == RIGHT) if (conf.heading_pos == RIGHT)
conf.heading_pos = LEFT; conf.heading_pos = LEFT;

View File

@ -42,7 +42,6 @@
#include "calcurse.h" #include "calcurse.h"
static unsigned day_days = 5;
static vector_t day_items; static vector_t day_items;
static unsigned day_items_nb = 0; static unsigned day_items_nb = 0;
@ -109,7 +108,7 @@ int day_sel_index(void)
int day_get_days(void) int day_get_days(void)
{ {
return day_days; return conf.multiple_days;
} }
static void day_free(struct day_item *day) 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) { if (include_captions) {
/* Two empty lines between days. */ /* Empty line at end of day if appointments have one. */
if (apts == 0) if (apts == 0 && conf.empty_appt_line)
day_add_item(EMPTY_SEPARATOR, 0, ENDOFDAY(date), p); day_add_item(EMPTY_SEPARATOR, 0, ENDOFDAY(date), p);
day_add_item(DAY_SEPARATOR, 0, ENDOFDAY(date), p); day_add_item(DAY_SEPARATOR, 0, ENDOFDAY(date), p);
} }

View File

@ -1144,7 +1144,9 @@ int ui_day_height(int n, void *cb_data)
if (item->type == APPT || if (item->type == APPT ||
item->type == RECUR_APPT) item->type == RECUR_APPT)
return 3; return conf.empty_appt_line ? 3 : 2;
else if (item->type == DAY_SEPARATOR)
return conf.dayseparator;
else else
return 1; return 1;
} }

View File

@ -122,6 +122,9 @@ void vars_init(void)
/* Variables for user configuration */ /* Variables for user configuration */
conf.cal_view = CAL_MONTH_VIEW; conf.cal_view = CAL_MONTH_VIEW;
conf.todo_view = TODO_HIDE_COMPLETED_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_quit = 1;
conf.confirm_delete = 1; conf.confirm_delete = 1;
conf.auto_save = 1; conf.auto_save = 1;