From 1af9ccccd79fa053dc5eb51f98e0bc1bd6f7d2b5 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 28 Sep 2016 19:00:01 +0200 Subject: Automatically select new appointments/events This is a follow-up to commit 65b699f (Make automatic selection of appointments/events smarter, 2016-02-16). Newly created appointments and events are now selected automatically. Signed-off-by: Lukas Fleischer --- src/calcurse.c | 2 -- src/ui-day.c | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/calcurse.c b/src/calcurse.c index 89710af..b84d22b 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -120,7 +120,6 @@ static inline void key_generic_config_menu(void) static inline void key_generic_add_appt(void) { ui_day_item_add(); - do_storage(1); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); } @@ -136,7 +135,6 @@ static inline void key_add_item(void) case APP: case CAL: ui_day_item_add(); - do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); break; case TOD: diff --git a/src/ui-day.c b/src/ui-day.c index c8a4420..1956a7f 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -524,6 +524,7 @@ void ui_day_item_add(void) unsigned apoint_duration; unsigned end_h, end_m; int is_appointment = 1; + union aptev_ptr item; /* Get the starting time */ for (;;) { @@ -580,26 +581,28 @@ void ui_day_item_add(void) status_mesg(format_message_2, enter_str); wgetch(win[KEY].p); } + } else { + heures = minutes = 0; } status_mesg(mesg_3, ""); if (getstring(win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID) { + apoint_start = date2sec(*ui_calendar_get_slctd_day(), heures, + minutes); if (is_appointment) { - apoint_start = - date2sec(*ui_calendar_get_slctd_day(), heures, - minutes); - apoint_new(item_mesg, 0L, apoint_start, - min2sec(apoint_duration), 0L); + item.apt = apoint_new(item_mesg, 0L, apoint_start, + min2sec(apoint_duration), 0L); if (notify_bar()) notify_check_added(item_mesg, apoint_start, 0L); } else { - event_new(item_mesg, 0L, - date2sec(*ui_calendar_get_slctd_day(), 0, - 0), 1); + item.ev = event_new(item_mesg, 0L, apoint_start, 1); } io_set_modified(); + day_process_storage(ui_calendar_get_slctd_day(), 0); + ui_day_load_items(); + ui_day_set_selitem_by_aptev_ptr(item); } ui_calendar_monthly_view_cache_set_invalid(); -- cgit v1.2.3-70-g09d2