viscal

cairo/gtk vi-like timeblocking calendar
git clone git://jb55.com/viscal
Log | Files | Refs | README | LICENSE

commit df019eaf7f3fd734d3e682c1088e112b513e638c
parent 0dca2e9d96ef216ce75640dbb79d0d734f9ab221
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 28 Jun 2019 12:24:59 -0700

open: add event to end of timeblock cursor

Before open would only work with a selected event. This adds support
so that you can open after your unselected cursor timeblock

Diffstat:
Mviscal.c | 21+++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/viscal.c b/viscal.c @@ -894,19 +894,30 @@ static void insert_event(struct cal *cal, time_t st, time_t et, create_event(cal, st, et, ical->calendar); } -static void insert_event_action(struct cal *cal) +static void insert_event_action_with(struct cal *cal, time_t st) { // we should eventually always have a calendar // at least a temporary one if (cal->ncalendars == 0) return; - time_t st = cal->current; - time_t et = cal->current + cal->timeblock_size * 60; + time_t et = st + cal->timeblock_size * 60; insert_event(cal, st, et, current_calendar(cal)); } +static void insert_event_after_action(struct cal *cal) +{ + time_t start = cal->current + cal->timeblock_size * 60; + insert_event_action_with(cal, start); +} + + +static void insert_event_action(struct cal *cal) +{ + insert_event_action_with(cal, cal->current); +} + static void calendar_view_clicked(struct cal *cal, int mx, int my) { time_t closest; @@ -1171,8 +1182,10 @@ static void open_below(struct cal *cal) ev = get_selected_event(cal); - if (ev == NULL) + if (ev == NULL) { + insert_event_after_action(cal); return; + } vevent_span_timet(ev->vevent, &st, &et);