commit 5022ecf4b5c1fb614d13f7bc3a81a6cf3115a67e
parent 0df3b1ef5a4872fea719bb0e9d06dfceb3b2a18e
Author: William Casarin <jb55@jb55.com>
Date: Fri, 28 Aug 2020 10:13:55 -0700
show current minute in gutter
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
M | viscal.c | | | 30 | ++++++++++++++++++++++++++++++ |
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/viscal.c b/viscal.c
@@ -787,6 +787,13 @@ static time_t get_hour(time_t current)
return mktime(¤t_tm);
}
+static int get_minute(time_t current)
+{
+ struct tm current_tm;
+ current_tm = *localtime(¤t);
+ return current_tm.tm_min;
+}
+
static time_t get_smallest_closest_timeblock(time_t current, int round_by)
{
struct tm current_tm;
@@ -2299,6 +2306,28 @@ draw_selection (cairo_t *cr, struct cal *cal)
}
+static void draw_current_minute(cairo_t *cr, struct cal *cal)
+{
+ char buffer[32] = {0};
+ time_t now;
+ time(&now);
+
+ double y = calendar_time_to_loc_absolute(cal, now);
+ const double col = 0.4; // TODO: duplication from draw_hours
+
+ int min = get_minute(now);
+
+ format_margin_time(buffer, 32, min);
+
+ cairo_set_source_rgb (cr, 1.0, 0, 0);
+
+ cairo_move_to(cr, g_lmargin - (g_margin_time_w + EVPAD),
+ y+(TXTPAD/2.0)-2.0);
+
+ cairo_show_text(cr, buffer);
+ cairo_set_source_rgb (cr, col, col, col);
+}
+
static int
draw_calendar (cairo_t *cr, struct cal *cal) {
int i, width, height;
@@ -2309,6 +2338,7 @@ draw_calendar (cairo_t *cr, struct cal *cal) {
cairo_move_to(cr, cal->x, cal->y);
draw_background(cr, width, height);
draw_hours(cr, cal);
+ draw_current_minute(cr, cal);
struct event *selected =
get_selected_event(cal);