Make compact mode and default panel configurable

Create configuration entries for these (currently undocumented) options
which were added in 4d0c095 (Add compact panels support, 2012-11-25) and
in 660eef8 (Add configuration option to set a default panel,
2012-11-24).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2014-08-03 23:37:13 +02:00
parent 1c7b1befe3
commit c093fcdfbf

View File

@ -518,10 +518,9 @@ void custom_color_config(void)
delwin(conf_win.p); delwin(conf_win.p);
} }
/* Prints the general options. */
static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_data)
{
enum { enum {
COMPACT_PANELS,
DEFAULT_PANEL,
AUTO_SAVE, AUTO_SAVE,
AUTO_GC, AUTO_GC,
PERIODIC_SAVE, PERIODIC_SAVE,
@ -534,8 +533,14 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
INPUT_DATE_FMT, INPUT_DATE_FMT,
NB_OPTIONS NB_OPTIONS
}; };
/* Prints the general options. */
static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_data)
{
const int XPOS = 1; const int XPOS = 1;
char *opt[NB_OPTIONS] = { char *opt[NB_OPTIONS] = {
"appearance.compactpanels = ",
"appearance.defaultpanel = ",
"general.autosave = ", "general.autosave = ",
"general.autogc = ", "general.autogc = ",
"general.periodicsave = ", "general.periodicsave = ",
@ -547,25 +552,45 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
"format.outputdate = ", "format.outputdate = ",
"format.inputdate = " "format.inputdate = "
}; };
const char *panel;
if (hilt) if (hilt)
custom_apply_attr(win, ATTR_HIGHEST); custom_apply_attr(win, ATTR_HIGHEST);
mvwprintw(win, y, XPOS, "%s", opt[i]); mvwprintw(win, y, XPOS, "%s", opt[i]);
switch (i) { switch (i) {
case 0: case COMPACT_PANELS:
print_bool_option_incolor(win, conf.compact_panels, y,
XPOS + strlen(opt[COMPACT_PANELS]));
mvwaddstr(win, y + XPOS, 1,
_("(if set to YES, compact panels are used)"));
break;
case DEFAULT_PANEL:
if (conf.default_panel == CAL)
panel = _("Calendar");
else if (conf.default_panel == APP)
panel = _("Appointments");
else
panel = _("TODO");
custom_apply_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y, XPOS + strlen(opt[DEFAULT_PANEL]), panel);
custom_remove_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y + 1, XPOS,
_("(specifies the panel that is selected by default)"));
break;
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]));
mvwaddstr(win, y + XPOS, 1, mvwaddstr(win, y + XPOS, 1,
_("(if set to YES, automatic save is done when quitting)")); _("(if set to YES, automatic save is done when quitting)"));
break; break;
case 1: case AUTO_GC:
print_bool_option_incolor(win, conf.auto_gc, y, print_bool_option_incolor(win, conf.auto_gc, y,
XPOS + strlen(opt[AUTO_GC])); XPOS + strlen(opt[AUTO_GC]));
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(run the garbage collector when quitting)")); _("(run the garbage collector when quitting)"));
break; break;
case 2: case PERIODIC_SAVE:
custom_apply_attr(win, ATTR_HIGHEST); custom_apply_attr(win, ATTR_HIGHEST);
mvwprintw(win, y, XPOS + strlen(opt[PERIODIC_SAVE]), "%d", mvwprintw(win, y, XPOS + strlen(opt[PERIODIC_SAVE]), "%d",
conf.periodic_save); conf.periodic_save);
@ -574,34 +599,34 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
_("(if not null, automatically save data every 'periodic_save' " _("(if not null, automatically save data every 'periodic_save' "
"minutes)")); "minutes)"));
break; break;
case 3: case CONFIRM_QUIT:
print_bool_option_incolor(win, conf.confirm_quit, y, print_bool_option_incolor(win, conf.confirm_quit, y,
XPOS + strlen(opt[CONFIRM_QUIT])); XPOS + strlen(opt[CONFIRM_QUIT]));
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(if set to YES, confirmation is required before quitting)")); _("(if set to YES, confirmation is required before quitting)"));
break; break;
case 4: case CONFIRM_DELETE:
print_bool_option_incolor(win, conf.confirm_delete, y, print_bool_option_incolor(win, conf.confirm_delete, y,
XPOS + strlen(opt[CONFIRM_DELETE])); XPOS + strlen(opt[CONFIRM_DELETE]));
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(if set to YES, confirmation is required " _("(if set to YES, confirmation is required "
"before deleting an event)")); "before deleting an event)"));
break; break;
case 5: case SYSTEM_DIAGS:
print_bool_option_incolor(win, conf.system_dialogs, y, print_bool_option_incolor(win, conf.system_dialogs, y,
XPOS + strlen(opt[SYSTEM_DIAGS])); XPOS + strlen(opt[SYSTEM_DIAGS]));
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(if set to YES, messages about loaded " _("(if set to YES, messages about loaded "
"and saved data will be displayed)")); "and saved data will be displayed)"));
break; break;
case 6: case PROGRESS_BAR:
print_bool_option_incolor(win, conf.progress_bar, y, print_bool_option_incolor(win, conf.progress_bar, y,
XPOS + strlen(opt[PROGRESS_BAR])); XPOS + strlen(opt[PROGRESS_BAR]));
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(if set to YES, progress bar will be displayed " _("(if set to YES, progress bar will be displayed "
"when saving data)")); "when saving data)"));
break; break;
case 7: 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_week_begins_on_monday()? _("Monday") : ui_calendar_week_begins_on_monday()? _("Monday") :
@ -610,7 +635,7 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
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)"));
break; break;
case 8: case OUTPUT_DATE_FMT:
custom_apply_attr(win, ATTR_HIGHEST); custom_apply_attr(win, ATTR_HIGHEST);
mvwaddstr(win, y, XPOS + strlen(opt[OUTPUT_DATE_FMT]), mvwaddstr(win, y, XPOS + strlen(opt[OUTPUT_DATE_FMT]),
conf.output_datefmt); conf.output_datefmt);
@ -618,7 +643,7 @@ static void print_general_option(int i, WINDOW *win, int y, int hilt, void *cb_d
mvwaddstr(win, y + 1, XPOS, mvwaddstr(win, y + 1, XPOS,
_("(Format of the date to be displayed in non-interactive mode)")); _("(Format of the date to be displayed in non-interactive mode)"));
break; break;
case 9: case INPUT_DATE_FMT:
custom_apply_attr(win, ATTR_HIGHEST); custom_apply_attr(win, ATTR_HIGHEST);
mvwprintw(win, y, XPOS + strlen(opt[INPUT_DATE_FMT]), "%d", mvwprintw(win, y, XPOS + strlen(opt[INPUT_DATE_FMT]), "%d",
conf.input_datefmt); conf.input_datefmt);
@ -666,13 +691,23 @@ static void general_option_edit(int i)
buf[0] = '\0'; buf[0] = '\0';
switch (i) { switch (i) {
case 0: case COMPACT_PANELS:
conf.compact_panels = !conf.compact_panels;
resize = 1;
break;
case DEFAULT_PANEL:
if (conf.default_panel == TOD)
conf.default_panel = CAL;
else
conf.default_panel++;
break;
case AUTO_SAVE:
conf.auto_save = !conf.auto_save; conf.auto_save = !conf.auto_save;
break; break;
case 1: case AUTO_GC:
conf.auto_gc = !conf.auto_gc; conf.auto_gc = !conf.auto_gc;
break; break;
case 2: case PERIODIC_SAVE:
status_mesg(periodic_save_str, ""); status_mesg(periodic_save_str, "");
if (updatestring(win[STA].p, &buf, 0, 1) == 0) { if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
val = atoi(buf); val = atoi(buf);
@ -685,22 +720,22 @@ static void general_option_edit(int i)
} }
status_mesg(number_str, keys); status_mesg(number_str, keys);
break; break;
case 3: case CONFIRM_QUIT:
conf.confirm_quit = !conf.confirm_quit; conf.confirm_quit = !conf.confirm_quit;
break; break;
case 4: case CONFIRM_DELETE:
conf.confirm_delete = !conf.confirm_delete; conf.confirm_delete = !conf.confirm_delete;
break; break;
case 5: case SYSTEM_DIAGS:
conf.system_dialogs = !conf.system_dialogs; conf.system_dialogs = !conf.system_dialogs;
break; break;
case 6: case PROGRESS_BAR:
conf.progress_bar = !conf.progress_bar; conf.progress_bar = !conf.progress_bar;
break; break;
case 7: case FIRST_DAY_OF_WEEK:
ui_calendar_change_first_day_of_week(); ui_calendar_change_first_day_of_week();
break; break;
case 8: case OUTPUT_DATE_FMT:
status_mesg(output_datefmt_str, ""); status_mesg(output_datefmt_str, "");
strncpy(buf, conf.output_datefmt, strncpy(buf, conf.output_datefmt,
strlen(conf.output_datefmt) + 1); strlen(conf.output_datefmt) + 1);
@ -710,7 +745,7 @@ static void general_option_edit(int i)
} }
status_mesg(number_str, keys); status_mesg(number_str, keys);
break; break;
case 9: case INPUT_DATE_FMT:
val = status_ask_simplechoice(input_datefmt_prefix, val = status_ask_simplechoice(input_datefmt_prefix,
datefmt_str, datefmt_str,
DATE_FORMATS); DATE_FORMATS);