From 2c7bc6ac7a8adcb591a975fbc3ab3abe47fa99fa Mon Sep 17 00:00:00 2001 From: delthas Date: Wed, 14 Jul 2021 00:13:46 +0200 Subject: Add notify types for fine-grained control of unread/highlight state Namely, we want the unread light to show up only on actual messages, not commands etc. This opens the way for not showing an unread light when printing topic on join. --- ui/buffers.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ui/buffers.go') diff --git a/ui/buffers.go b/ui/buffers.go index 6de3923..4726447 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -16,6 +16,14 @@ type point struct { Split bool } +type NotifyType int + +const ( + NotifyNone NotifyType = iota + NotifyUnread + NotifyHighlight +) + type Line struct { At time.Time Head string @@ -251,7 +259,7 @@ func (bs *BufferList) Remove(title string) (ok bool) { return } -func (bs *BufferList) AddLine(title string, highlight bool, line Line) { +func (bs *BufferList) AddLine(title string, notify NotifyType, line Line) { idx := bs.idx(title) if idx < 0 { return @@ -280,10 +288,10 @@ func (bs *BufferList) AddLine(title string, highlight bool, line Line) { } } - if !line.Mergeable && idx != bs.current { + if notify != NotifyNone && idx != bs.current { b.unread = true } - if highlight && idx != bs.current { + if notify == NotifyHighlight && idx != bs.current { b.highlights++ } } -- cgit v1.2.3