From 41ae3639051869921b62c1bda51b88b6b71faec5 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sat, 4 Mar 2023 01:15:16 +0100 Subject: templates: add conditional style method Add .StyleSwitch that takes a string and an arbitrary number of cases (regexp, style). Reuse some of the constructs introduced by previous commit. The style of the first regular expression that matches will be applied. If the string does not match any of the expressions, it will be left as-is. Signed-off-by: Robin Jarry Acked-by: Tim Culverhouse --- config/templates.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'config/templates.go') diff --git a/config/templates.go b/config/templates.go index 98be7781..ff88689f 100644 --- a/config/templates.go +++ b/config/templates.go @@ -6,6 +6,7 @@ import ( "git.sr.ht/~rjarry/aerc/lib/templates" "git.sr.ht/~rjarry/aerc/log" + "git.sr.ht/~rjarry/aerc/models" "github.com/emersion/go-message/mail" "github.com/go-ini/ini" ) @@ -97,4 +98,6 @@ func (d *dummyData) ContentInfo() string { return "" } func (d *dummyData) StatusInfo() string { return "" } func (d *dummyData) TrayInfo() string { return "" } func (d *dummyData) PendingKeys() string { return "" } -func (d *dummyData) Style(string, string) string { return "" } + +func (d *dummyData) Style(string, string) string { return "" } +func (d *dummyData) StyleSwitch(string, ...models.Case) string { return "" } -- cgit