From d9a8edd8e9269aa1189d55c8d13caa05084435f5 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 27 Feb 2023 09:18:16 -0600 Subject: templates: allow inline user styles Allow custom user-defined styles in a styleset. The styles can take any name, and must be under the [user] ini section. All attributes apply to user defined styles. Example: [user] red.fg=red red.bold=true Add a .Style function which accepts the name of a user-defined style and applies it to the string. {{.Style "red" "foo"}} Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- lib/state/templates.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/state/templates.go b/lib/state/templates.go index 2d5e39f5..d5631b11 100644 --- a/lib/state/templates.go +++ b/lib/state/templates.go @@ -6,6 +6,7 @@ import ( "time" "git.sr.ht/~rjarry/aerc/config" + "git.sr.ht/~rjarry/aerc/lib/parse" "git.sr.ht/~rjarry/aerc/models" sortthread "github.com/emersion/go-imap-sortthread" "github.com/emersion/go-message/mail" @@ -449,3 +450,9 @@ func (d *TemplateData) TrayInfo() string { func (d *TemplateData) PendingKeys() string { return config.FormatKeyStrokes(d.pendingKeys) } + +func (d *TemplateData) Style(name string, content string) string { + cfg := config.Ui.ForAccount(d.Account()) + style := cfg.GetUserStyle(name) + return parse.ApplyStyle(style, content) +} -- cgit