aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-07-14 20:37:32 +0200
committerRobin Jarry <robin@jarry.cc>2023-07-16 10:13:12 +0200
commitb267de83e38c09d34215e7a33991ae5c111fe649 (patch)
treeadeb2619459228d43475d4efd92324ba82ad4e38 /lib
parent94b1c778dbe691a75b0d918e9c40cc34f8523768 (diff)
downloadaerc-b267de83e38c09d34215e7a33991ae5c111fe649.tar.gz
templates: add ThreadCount and ThreadFolded
Add the number of threads and a flag to indicated folded threads to the template data. Use {{.ThreadCount}} and {{.ThreadFolded}} in template expression for the message list. column-subject = {{.ThreadPrefix}}{{if .ThreadFolded}}[{{.ThreadCount}}] {{end}}{{.Subject}} Update default configuration accordingly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/state/templates.go34
1 files changed, 26 insertions, 8 deletions
diff --git a/lib/state/templates.go b/lib/state/templates.go
index 36f7b725..7b877c76 100644
--- a/lib/state/templates.go
+++ b/lib/state/templates.go
@@ -16,7 +16,7 @@ type DataSetter interface {
Data() models.TemplateData
SetHeaders(*mail.Header, *models.OriginalMail)
SetInfo(*models.MessageInfo, int, bool)
- SetThreading(string, bool)
+ SetThreading(string, bool, int, bool)
SetAccount(*config.AccountConfig)
SetFolder(*models.Directory)
SetRUE([]string, func(string) (int, int, int))
@@ -24,6 +24,13 @@ type DataSetter interface {
SetPendingKeys([]config.KeyStroke)
}
+type ThreadInfo struct {
+ SameSubject bool
+ Prefix string
+ Count int
+ Folded bool
+}
+
type templateData struct {
// only available when composing/replying/forwarding
headers *mail.Header
@@ -35,8 +42,7 @@ type templateData struct {
msgNum int
// message list threading
- threadSameSubject bool
- threadPrefix string
+ threadInfo ThreadInfo
// selected account
account *config.AccountConfig
@@ -72,9 +78,13 @@ 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) SetThreading(prefix string, same bool, count int,
+ folded bool,
+) {
+ d.threadInfo.Prefix = prefix
+ d.threadInfo.SameSubject = same
+ d.threadInfo.Count = count
+ d.threadInfo.Folded = folded
}
func (d *templateData) SetAccount(acct *config.AccountConfig) {
@@ -260,7 +270,15 @@ func (d *templateData) Header(name string) string {
}
func (d *templateData) ThreadPrefix() string {
- return d.threadPrefix
+ return d.threadInfo.Prefix
+}
+
+func (d *templateData) ThreadCount() int {
+ return d.threadInfo.Count
+}
+
+func (d *templateData) ThreadFolded() bool {
+ return d.threadInfo.Folded
}
func (d *templateData) Subject() string {
@@ -271,7 +289,7 @@ func (d *templateData) Subject() string {
case d.headers != nil:
subject = d.Header("subject")
}
- if d.threadSameSubject {
+ if d.threadInfo.SameSubject {
subject = ""
}
return subject