Save active view on the todo panel
Add a configuration option appearance.todoview and use it to automatically save the currently active todo panel view and restore it when restarting calcurse. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
e3ac5542aa
commit
1b75acf01b
@ -1072,6 +1072,8 @@ void ui_todo_view_note(void);
|
||||
void ui_todo_edit_note(void);
|
||||
void ui_todo_view_prev(void);
|
||||
void ui_todo_view_next(void);
|
||||
int ui_todo_get_view(void);
|
||||
void ui_todo_set_view(int);
|
||||
|
||||
/* utf8.c */
|
||||
int utf8_width(char *);
|
||||
|
25
src/config.c
25
src/config.c
@ -59,6 +59,8 @@ static int config_parse_str(char *, const char *);
|
||||
static int config_serialize_str(char **, const char *);
|
||||
static int config_parse_calendar_view(void *, const char *);
|
||||
static int config_serialize_calendar_view(char **, void *);
|
||||
static int config_parse_todo_view(void *, const char *);
|
||||
static int config_serialize_todo_view(char **, void *);
|
||||
static int config_parse_default_panel(void *, const char *);
|
||||
static int config_serialize_default_panel(char **, void *);
|
||||
static int config_parse_first_day_of_week(void *, const char *);
|
||||
@ -91,6 +93,7 @@ static const struct confvar confmap[] = {
|
||||
{"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},
|
||||
{"appearance.todoview", config_parse_todo_view, config_serialize_todo_view, NULL},
|
||||
{"daemon.enable", CONFIG_HANDLER_BOOL(dmon.enable)},
|
||||
{"daemon.log", CONFIG_HANDLER_BOOL(dmon.log)},
|
||||
{"format.inputdate", config_parse_input_datefmt, config_serialize_input_datefmt, NULL},
|
||||
@ -206,6 +209,18 @@ static int config_parse_calendar_view(void *dummy, const char *val)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int config_parse_todo_view(void *dummy, const char *val)
|
||||
{
|
||||
if (!strcmp(val, "show-completed"))
|
||||
ui_todo_set_view(TODO_SHOW_COMPLETED_VIEW);
|
||||
else if (!strcmp(val, "hide-completed"))
|
||||
ui_todo_set_view(TODO_HIDE_COMPLETED_VIEW);
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int config_parse_default_panel(void *dummy, const char *val)
|
||||
{
|
||||
if (!strcmp(val, "calendar"))
|
||||
@ -378,6 +393,16 @@ static int config_serialize_calendar_view(char **buf, void *dummy)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int config_serialize_todo_view(char **buf, void *dummy)
|
||||
{
|
||||
if (ui_todo_get_view() == TODO_SHOW_COMPLETED_VIEW)
|
||||
*buf = mem_strdup("show-completed");
|
||||
else
|
||||
*buf = mem_strdup("hide-completed");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int config_serialize_default_panel(char **buf, void *dummy)
|
||||
{
|
||||
if (conf.default_panel == CAL)
|
||||
|
@ -327,3 +327,14 @@ void ui_todo_view_prev(void)
|
||||
ui_todo_view--;
|
||||
ui_todo_load_items();
|
||||
}
|
||||
|
||||
void ui_todo_set_view(int view)
|
||||
{
|
||||
ui_todo_view = (view < 0 || view >= TODO_VIEWS) ?
|
||||
TODO_SHOW_COMPLETED_VIEW : view;
|
||||
}
|
||||
|
||||
int ui_todo_get_view(void)
|
||||
{
|
||||
return (int)ui_todo_view;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user