From 75cbf8dc0376429d6cdb6a6716b6a9b41fb681f1 Mon Sep 17 00:00:00 2001 From: Kevin Kuehler Date: Mon, 28 Oct 2019 12:07:05 -0700 Subject: Add threading control path to msglist.Draw() Signed-off-by: Kevin Kuehler --- widgets/msglist.go | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'widgets') 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 { -- cgit v1.2.3