diff options
| author | Kevin Kuehler <keur@xcf.berkeley.edu> | 2019-10-10 15:27:12 -0700 | 
|---|---|---|
| committer | Ben Burwell <ben@benburwell.com> | 2019-10-12 20:58:06 -0400 | 
| commit | baa8813dcc1bf4dbd18763df9ee654472ae0e433 (patch) | |
| tree | f71a49c1eab79108cd6e674cce18b4e6b2c0eee1 | |
| parent | 77c1a1714448092c2355eb1cc046f1939b46c5e4 (diff) | |
Add threading control path to msglist.Draw()
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
| -rw-r--r-- | config/triggers.go | 2 | ||||
| -rw-r--r-- | lib/format/format.go | 6 | ||||
| -rw-r--r-- | lib/msgstore.go | 2 | ||||
| -rw-r--r-- | widgets/msglist.go | 29 | 
4 files changed, 27 insertions, 12 deletions
| diff --git a/config/triggers.go b/config/triggers.go index d31f267..0e1f030 100644 --- a/config/triggers.go +++ b/config/triggers.go @@ -37,7 +37,7 @@ func (trig *TriggersConfig) ExecNewEmail(account *AccountConfig,  	err := trig.ExecTrigger(trig.NewEmail,  		func(part string) (string, error) {  			formatstr, args, err := format.ParseMessageFormat(part, -				conf.Ui.TimestampFormat, account.Name, 0, msg) +				conf.Ui.TimestampFormat, account.Name, 0, msg, "") // TODO: check with jeffas how to handle this  			if err != nil {  				return "", err  			} diff --git a/lib/format/format.go b/lib/format/format.go index b403f2d..c71ae93 100644 --- a/lib/format/format.go +++ b/lib/format/format.go @@ -10,8 +10,8 @@ import (  )  func ParseMessageFormat(format string, timestampformat string, -	accountName string, number int, msg *models.MessageInfo) (string, -	[]interface{}, error) { +	accountName string, number int, msg *models.MessageInfo, +	subjectThread string) (string, []interface{}, error) {  	retval := make([]byte, 0, len(format))  	var args []interface{} @@ -147,7 +147,7 @@ func ParseMessageFormat(format string, timestampformat string,  			args = append(args, addrs)  		case 's':  			retval = append(retval, 's') -			args = append(args, msg.Envelope.Subject) +			args = append(args, subjectThread+msg.Envelope.Subject)  		case 't':  			if len(msg.Envelope.To) == 0 {  				return "", nil, diff --git a/lib/msgstore.go b/lib/msgstore.go index bfea081..e86dc56 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -179,7 +179,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {  		newMap := make(map[uint32]*models.MessageInfo)  		for i := len(msg.Threads) - 1; i >= 0; i-- { -			msg.Threads[i].FormatThread(func(t *types.Thread, x string) bool { +			msg.Threads[i].FormatThread(func(t *types.Thread, x []rune) bool {  				uid := t.Uid  				uids = append([]uint32{uid}, uids...)  				if msg, ok := store.Messages[uid]; ok { 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 { | 
