viscal

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

commit 79a250f3da8dadfe05d3ff5850dc9bce52e1e607
parent 98c7824ed051f222a470a0cbb622e9c18b8e1a5a
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 22 Apr 2019 10:49:48 -0700

move_now: always deselect so we don't get stuck

fixes an annoying bug when trying to move when selecting something

Diffstat:
Mviscal.c | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/viscal.c b/viscal.c @@ -856,11 +856,32 @@ static void move_event_now(struct cal *cal) move_event_to(event, closest); } +static int time_in_view(struct cal *cal, time_t time) { + time_t st = calendar_loc_to_time(cal, 0); + time_t et = calendar_loc_to_time(cal, 1.0); + + return time >= st && time <= et; +} + +static int timeline_in_view(struct cal *cal) +{ + return time_in_view(cal, cal->current); +} + +static void deselect(struct cal *cal) +{ + cal->selected_event_ind = -1; +} + static void move_now(struct cal *cal) { + deselect(cal); + cal->current = get_smallest_closest_timeblock(time(NULL), SMALLEST_TIMEBLOCK); - //center_view(cal); + + if (!timeline_in_view(cal)) + center_view(cal); } static void insert_event(struct cal *cal, time_t st, time_t et,