From 6a8db1f41253d11c829dbe7d1d76722aa3fa8772 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 10 Nov 2024 19:19:38 +0100 Subject: WIP: xA: date change indicator --- xA/xA.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'xA') diff --git a/xA/xA.go b/xA/xA.go index f1de18f..417a24a 100644 --- a/xA/xA.go +++ b/xA/xA.go @@ -482,7 +482,7 @@ func convertBufferLine(m *RelayEventDataBufferLine) bufferLine { } } -func bufferPrintDateChange(sameline *bool, last, current time.Time) { +func bufferPrintDateChange(last, current time.Time) { last, current = last.Local(), current.Local() if last.Year() == current.Year() && last.Month() == current.Month() && @@ -490,11 +490,16 @@ func bufferPrintDateChange(sameline *bool, last, current time.Time) { return } - // TODO(p): Also print it. - // XXX: Not sure if "sameline" is appropriate with RichText. - _ = sameline - _ = current.Format(time.DateOnly) - *sameline = false + wRichText.Segments = append(wRichText.Segments, &widget.TextSegment{ + Style: widget.RichTextStyle{ + Alignment: fyne.TextAlignLeading, + ColorName: "", + Inline: false, + SizeName: theme.SizeNameText, + TextStyle: fyne.TextStyle{Bold: true}, + }, + Text: current.Format(time.DateOnly), + }) } func bufferPrintAndWatchTrailingDateChanges() { @@ -502,8 +507,7 @@ func bufferPrintAndWatchTrailingDateChanges() { b := bufferByName(bufferCurrent) if b != nil && len(b.lines) != 0 { last := b.lines[len(b.lines)-1].when - sameline := len(wRichText.Segments) == 0 - bufferPrintDateChange(&sameline, last, current) + bufferPrintDateChange(last, current) } // TODO(p): The watching part. @@ -519,9 +523,7 @@ func bufferPrintLine(lines []bufferLine, index int) { last = lines[index-1].when } - // XXX: Not sure if "sameline" is appropriate with RichText. - sameline := len(wRichText.Segments) == 0 - bufferPrintDateChange(&sameline, last, current) + bufferPrintDateChange(last, current) // TODO(p): Why don't the colour names work? texts := []widget.RichTextSegment{&widget.TextSegment{ -- cgit v1.2.3-70-g09d2