From 48fa63ff5d0e12edf86db7f01def635aa0aaa9fb Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 18 Oct 2026 15:29:35 +0200 Subject: fix(calendar): mark events past this week on the month grid The sampler asked khal for 8 days only, so the grid never coloured an event later in the month. Sample through the month's end instead, and cut the event table back to the coming week with calendar_upcoming(). Co-Authored-By: Claude Opus 5.5 --- widgets/calendar.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'widgets/calendar.lua') diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 11dcb63..5e08a7b 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -209,7 +209,10 @@ function M.draw(cr, rect, colors) local ey = grid_bottom + ev_size * 1.1 - if #cal.events == 0 then + -- The cache spans the month for the grid; the table is the week ahead. + local events = data.calendar_upcoming(cal.events, today, 8) + + if #events == 0 then card.font(cr, card.FONT_UI, ev_size, false) card.rgba(cr, colors.label, 0.8) card.text(cr, inner.x, ey, 'nothing this week') @@ -225,7 +228,7 @@ function M.draw(cr, rect, colors) -- 'all day' is wider than '13:00'. card.font(cr, card.FONT_MONO, ev_size, false) local time_w = 0 - for _, e in ipairs(cal.events) do + for _, e in ipairs(events) do local w = card.advance(cr, when(e)) if w > time_w then time_w = w end end @@ -253,16 +256,16 @@ function M.draw(cr, rect, colors) local probe = ey while probe <= floor_y do room = room + 1; probe = probe + ev_step end - local shown = #cal.events + local shown = #events -- The overflow line costs a row, so it is only worth taking when it reports -- more than the row it displaces. if room < shown then shown = (room >= 2) and (room - 1) or room end - local hidden = #cal.events - shown + local hidden = #events - shown for i = 1, shown do - local e = cal.events[i] + local e = events[i] if ey > floor_y then break end local colour = cal_colour(e.calendar, colors, cal.colors) -- cgit v1.2.3