aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/msglist.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-11 20:42:55 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-31 21:02:23 +0200
commit2f46f64b0b0b93e99b4754a566c84a08d4563078 (patch)
treea91261379109115c6116e1106ec3e37b62eba048 /widgets/msglist.go
parent47675e80850d981b19c6fb231fbebaf5674f3682 (diff)
downloadaerc-2f46f64b0b0b93e99b4754a566c84a08d4563078.tar.gz
styleset: allow dynamic msglist styling
Add support for dynamic msglist*.$HEADER,$VALUE.$ATTR = $VALUE where $VALUE can be either a fixed string or a regular expression. This is intended as a replacement of contextual ui sections based on subject values. Implements: https://todo.sr.ht/~rjarry/aerc/18 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r--widgets/msglist.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go
index 4bf20b09..0937b786 100644
--- a/widgets/msglist.go
+++ b/widgets/msglist.go
@@ -7,6 +7,7 @@ import (
"strings"
sortthread "github.com/emersion/go-imap-sortthread"
+ "github.com/emersion/go-message/mail"
"github.com/gdamore/tcell/v2"
"git.sr.ht/~rjarry/aerc/config"
@@ -50,6 +51,7 @@ type messageRowParams struct {
needsHeaders bool
uiConfig *config.UIConfig
styles []config.StyleObject
+ headers *mail.Header
}
func (ml *MessageList) Draw(ctx *ui.Context) {
@@ -110,11 +112,13 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
row := &t.Rows[r]
params, _ := row.Priv.(messageRowParams)
if params.uid == store.SelectedUid() {
- style = params.uiConfig.GetComposedStyleSelected(
- config.STYLE_MSGLIST_DEFAULT, params.styles)
+ style = params.uiConfig.MsgComposedStyleSelected(
+ config.STYLE_MSGLIST_DEFAULT, params.styles,
+ params.headers)
} else {
- style = params.uiConfig.GetComposedStyle(
- config.STYLE_MSGLIST_DEFAULT, params.styles)
+ style = params.uiConfig.MsgComposedStyle(
+ config.STYLE_MSGLIST_DEFAULT, params.styles,
+ params.headers)
}
return style
}
@@ -266,6 +270,7 @@ func addMessage(
// TODO deprecate subject contextual UIs? Only related setting is
// styleset, should implement a better per-message styling method
params.uiConfig = uiConfig.ForSubject(msg.Envelope.Subject)
+ params.headers = msg.RFC822Headers
return table.AddRow(cells, params)
}