aboutsummaryrefslogtreecommitdiff
path: root/xA
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-11-10 19:19:38 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-11-10 19:19:38 +0100
commit6a8db1f41253d11c829dbe7d1d76722aa3fa8772 (patch)
treebecb657ee6308edc88b87afd713ed81d4dd5e48b /xA
parent066b99e4cac9c51fa9bd46e62e8e593c1c80d3e5 (diff)
downloadxK-6a8db1f41253d11c829dbe7d1d76722aa3fa8772.tar.gz
xK-6a8db1f41253d11c829dbe7d1d76722aa3fa8772.tar.xz
xK-6a8db1f41253d11c829dbe7d1d76722aa3fa8772.zip
WIP: xA: date change indicator
Diffstat (limited to 'xA')
-rw-r--r--xA/xA.go24
1 files changed, 13 insertions, 11 deletions
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{