From 6ed5a57e5ede8a6a9ee218cc21c51bc325b3b1ca Mon Sep 17 00:00:00 2001 From: delthas Date: Sun, 28 Aug 2022 18:22:47 +0200 Subject: Always show the date of the top message Even if it is a continuation line. Fixes: https://todo.sr.ht/~taiite/senpai/98 --- ui/buffers.go | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/ui/buffers.go b/ui/buffers.go index 5e2691c..75948af 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -757,23 +757,28 @@ func (bs *BufferList) DrawTimeline(screen tcell.Screen, x0, y0, nickColWidth int continue } - if yi >= y0 { - var showDate bool - if i == 0 || yi == y0 { - showDate = true - } else { - yb, mb, dd := b.lines[i-1].At.Local().Date() - ya, ma, da := b.lines[i].At.Local().Date() - showDate = yb != ya || mb != ma || dd != da - } - if showDate { - st := tcell.StyleDefault.Bold(true) - printDate(screen, x0, yi, st, line.At.Local()) - } else if b.lines[i-1].At.Truncate(time.Minute) != line.At.Truncate(time.Minute) { - st := tcell.StyleDefault.Foreground(tcell.ColorGray) - printTime(screen, x0, yi, st, line.At.Local()) + var showDate bool + if i == 0 || yi <= y0 { + showDate = true + } else { + yb, mb, dd := b.lines[i-1].At.Local().Date() + ya, ma, da := b.lines[i].At.Local().Date() + showDate = yb != ya || mb != ma || dd != da + } + if showDate { + st := tcell.StyleDefault.Bold(true) + // as a special case, always draw the first visible message date, even if it is a continuation line + yd := yi + if yd < y0 { + yd = y0 } + printDate(screen, x0, yd, st, line.At.Local()) + } else if b.lines[i-1].At.Truncate(time.Minute) != line.At.Truncate(time.Minute) && yi >= y0 { + st := tcell.StyleDefault.Foreground(tcell.ColorGray) + printTime(screen, x0, yi, st, line.At.Local()) + } + if yi >= y0 { identSt := tcell.StyleDefault. Foreground(line.HeadColor). Reverse(line.Highlight) -- cgit v1.2.3