aboutsummaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
authorKevin Kuehler <keur@xcf.berkeley.edu>2019-10-10 15:27:12 -0700
committerBen Burwell <ben@benburwell.com>2019-10-12 20:58:06 -0400
commitbaa8813dcc1bf4dbd18763df9ee654472ae0e433 (patch)
treef71a49c1eab79108cd6e674cce18b4e6b2c0eee1 /widgets
parent77c1a1714448092c2355eb1cc046f1939b46c5e4 (diff)
Add threading control path to msglist.Draw()
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msglist.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index ac3d6cc..228477d 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -12,6 +12,7 @@ import (
"git.sr.ht/~sircmpwn/aerc/lib/format"
"git.sr.ht/~sircmpwn/aerc/lib/ui"
"git.sr.ht/~sircmpwn/aerc/models"
+ "git.sr.ht/~sircmpwn/aerc/worker/types"
)
type MessageList struct {
@@ -69,12 +70,26 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
)
uids := store.Uids()
- for i := len(uids) - 1 - ml.scroll; i >= 0; i-- {
- uid := uids[i]
- if ml.drawRow(ctx, uid, i, row, &needsHeaders) {
- break
+ if ml.conf.Ui.ThreadingEnabled {
+ threads := store.Threads
+
+ for i := len(threads) - 1; i >= 0; i-- {
+ threads[i].FormatThread(func(thread *types.Thread, threadFmt []rune) bool {
+ if ml.drawRow(ctx, thread.Uid, row, row, &needsHeaders, string(threadFmt)) {
+ return true
+ }
+ row += 1
+ return false
+ })
+ }
+ } else {
+ for i := len(uids) - 1 - ml.scroll; i >= 0; i-- {
+ uid := uids[i]
+ if ml.drawRow(ctx, uid, i, row, &needsHeaders, "") {
+ break
+ }
+ row += 1
}
- row += 1
}
if len(uids) == 0 {
@@ -92,7 +107,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
// Draw one message.
//
// Return: If true, don't fetch any more messages
-func (ml *MessageList) drawRow(ctx *ui.Context, uid uint32, number int, row int, needsHeaders *[]uint32) bool {
+func (ml *MessageList) drawRow(ctx *ui.Context, uid uint32, number int, row int, needsHeaders *[]uint32, subjectThread string) bool {
store := ml.store
msg := store.Messages[uid]
@@ -130,7 +145,7 @@ func (ml *MessageList) drawRow(ctx *ui.Context, uid uint32, number int, row int,
ctx.Fill(0, row, ctx.Width(), 1, ' ', style)
fmtStr, args, err := format.ParseMessageFormat(
ml.conf.Ui.IndexFormat,
- ml.conf.Ui.TimestampFormat, "", number, msg)
+ ml.conf.Ui.TimestampFormat, "", number, msg, subjectThread)
if err != nil {
ctx.Printf(0, row, style, "%v", err)
} else {