aboutsummaryrefslogtreecommitdiffstats
path: root/config/config.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-12-11 23:57:30 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-14 11:22:53 +0100
commit9d0297e9d913a92b2d7ae02692e83f0f4093a766 (patch)
treeb34425a8a295b3cc52c4cf20904f85019b6352ab /config/config.go
parent2937830491b5adedf79c8c218afb2c80b17c019a (diff)
downloadaerc-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 'config/config.go')
-rw-r--r--config/config.go46
1 files changed, 21 insertions, 25 deletions
diff --git a/config/config.go b/config/config.go
index b5cc0d60..90951985 100644
--- a/config/config.go
+++ b/config/config.go
@@ -15,20 +15,18 @@ import (
)
type AercConfig struct {
- Bindings BindingConfig
- ContextualBinds []BindingConfigContext
- Compose ComposeConfig
- Converters map[string]string
- Accounts []AccountConfig `ini:"-"`
- Filters []FilterConfig `ini:"-"`
- Viewer ViewerConfig `ini:"-"`
- Statusline StatuslineConfig `ini:"-"`
- Triggers TriggersConfig `ini:"-"`
- Ui UIConfig
- ContextualUis []UIConfigContext
- General GeneralConfig
- Templates TemplateConfig
- Openers map[string][]string
+ Bindings BindingConfig
+ Compose ComposeConfig
+ Converters map[string]string
+ Accounts []AccountConfig `ini:"-"`
+ Filters []FilterConfig `ini:"-"`
+ Viewer ViewerConfig `ini:"-"`
+ Statusline StatuslineConfig `ini:"-"`
+ Triggers TriggersConfig `ini:"-"`
+ Ui UIConfig
+ General GeneralConfig
+ Templates TemplateConfig
+ Openers map[string][]string
}
// Input: TimestampFormat
@@ -133,17 +131,15 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
}
file.NameMapper = mapName
config := &AercConfig{
- Bindings: defaultBindsConfig(),
- ContextualBinds: []BindingConfigContext{},
- General: defaultGeneralConfig(),
- Ui: defaultUiConfig(),
- ContextualUis: []UIConfigContext{},
- Viewer: defaultViewerConfig(),
- Statusline: defaultStatuslineConfig(),
- Compose: defaultComposeConfig(),
- Converters: make(map[string]string),
- Templates: defaultTemplatesConfig(),
- Openers: make(map[string][]string),
+ Bindings: defaultBindsConfig(),
+ General: defaultGeneralConfig(),
+ Ui: defaultUiConfig(),
+ Viewer: defaultViewerConfig(),
+ Statusline: defaultStatuslineConfig(),
+ Compose: defaultComposeConfig(),
+ Converters: make(map[string]string),
+ Templates: defaultTemplatesConfig(),
+ Openers: make(map[string][]string),
}
if err := config.parseGeneral(file); err != nil {