diff options
author | Kevin Kuehler <keur@xcf.berkeley.edu> | 2019-10-28 12:07:05 -0700 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2019-10-29 11:07:45 -0400 |
commit | 75cbf8dc0376429d6cdb6a6716b6a9b41fb681f1 (patch) | |
tree | be0db1beda8f84c5ad4ad8cc2924b511487a5759 /widgets/msglist.go | |
parent | 4c8d9ad26cce588cc4ea2259cd7ca83d2801c102 (diff) |
Add threading control path to msglist.Draw()
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r-- | widgets/msglist.go | 29 |
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 { |