From 35040bec9962cac3c92039fac85a4068e148b0a0 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Fri, 3 Mar 2023 17:37:05 +0100 Subject: templates: separate thread prefix from subject Extract {{.ThreadPrefix}} from {{.Subject}} so that the prefix can be styled in a different color. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- lib/state/templates.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lib/state') diff --git a/lib/state/templates.go b/lib/state/templates.go index d5631b11..2e351a7a 100644 --- a/lib/state/templates.go +++ b/lib/state/templates.go @@ -23,8 +23,8 @@ type TemplateData struct { msgNum int // message list threading - ThreadSameSubject bool - ThreadPrefix string + threadSameSubject bool + threadPrefix string // selected account account *config.AccountConfig @@ -50,6 +50,11 @@ func (d *TemplateData) SetInfo(info *models.MessageInfo, num int, marked bool) { d.marked = marked } +func (d *TemplateData) SetThreading(prefix string, same bool) { + d.threadPrefix = prefix + d.threadSameSubject = same +} + func (d *TemplateData) SetAccount(acct *config.AccountConfig) { d.account = acct d.myAddresses = make(map[string]bool) @@ -220,6 +225,10 @@ func (d *TemplateData) Header(name string) string { return text } +func (d *TemplateData) ThreadPrefix() string { + return d.threadPrefix +} + func (d *TemplateData) Subject() string { var subject string switch { @@ -228,10 +237,10 @@ func (d *TemplateData) Subject() string { case d.headers != nil: subject = d.Header("subject") } - if d.ThreadSameSubject { + if d.threadSameSubject { subject = "" } - return d.ThreadPrefix + subject + return subject } func (d *TemplateData) SubjectBase() string { -- cgit