diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-11 23:57:30 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-14 11:22:53 +0100 |
commit | 9d0297e9d913a92b2d7ae02692e83f0f4093a766 (patch) | |
tree | b34425a8a295b3cc52c4cf20904f85019b6352ab /widgets/msglist.go | |
parent | 2937830491b5adedf79c8c218afb2c80b17c019a (diff) | |
download | aerc-9d0297e9d913a92b2d7ae02692e83f0f4093a766.tar.gz |
config: rework contextual sections implementation
The current contextual binds and ui config API is awkward and cumbersome
to use. Rework it to make it more elegant.
Store the contextual sections as private fields of the UIConfig and
KeyBindings structures. Add cache to avoid recomputation of the composed
UIConfig and KeyBindings objects every time a contextual item is
requested. Replace the cache from DirectoryList with that.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets/msglist.go')
-rw-r--r-- | widgets/msglist.go | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/widgets/msglist.go b/widgets/msglist.go index 09ee705e..85b8f168 100644 --- a/widgets/msglist.go +++ b/widgets/msglist.go @@ -202,19 +202,9 @@ func (ml *MessageList) drawRow(textWidth int, ctx *ui.Context, uid uint32, row i // TODO deprecate subject contextual UIs? Only related setting is styleset, // should implement a better per-message styling method // Check if we have any applicable ContextualUIConfigs - confs := ml.aerc.conf.GetContextualUIConfigs() uiConfig := acct.Directories().UiConfig(store.DirInfo.Name) - for _, c := range confs { - if c.ContextType == config.UI_CONTEXT_SUBJECT && msg.Envelope != nil { - if c.Regex.Match([]byte(msg.Envelope.Subject)) { - confParams := map[config.ContextType]string{ - config.UI_CONTEXT_ACCOUNT: acct.AccountConfig().Name, - config.UI_CONTEXT_FOLDER: acct.Directories().Selected(), - config.UI_CONTEXT_SUBJECT: msg.Envelope.Subject, - } - uiConfig = ml.conf.GetUiConfig(confParams) - } - } + if msg.Envelope != nil { + uiConfig = uiConfig.ForSubject(msg.Envelope.Subject) } msg_styles := []config.StyleObject{} |