diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-12 15:03:30 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-14 11:22:58 +0100 |
commit | c05c2ffe0424b048b10e7dd1aca59ae9cf631f12 (patch) | |
tree | 13a3a84eb74fdea77996161f01bec5596f67f39f /config/statusline.go | |
parent | 9d0297e9d913a92b2d7ae02692e83f0f4093a766 (diff) | |
download | aerc-c05c2ffe0424b048b10e7dd1aca59ae9cf631f12.tar.gz |
config: make various sections accessible via global vars
There is only one instance of AercConfig which is associated to the Aerc
widget. Everywhere we need to access configuration options, we need
somehow to get a reference either to the Aerc widget or to a pointer to
the AercConfig instance. This makes the code cluttered.
Remove the AercConfig structure and every place where it is referenced.
Instead, declare global variables for every configuration section and
access them directly from the `config` module.
Since bindings and ui sections can be "contextual" (i.e. per account,
per folder or per subject), leave most local references intact.
Replacing them with config.{Ui,Binds}.For{Account,Folder,Subject} would
make this patch even more unreadable. This is something that may be
addressed in the future.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'config/statusline.go')
-rw-r--r-- | config/statusline.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/config/statusline.go b/config/statusline.go index 1e7d723e..483241c0 100644 --- a/config/statusline.go +++ b/config/statusline.go @@ -11,23 +11,25 @@ type StatuslineConfig struct { DisplayMode string `ini:"display-mode"` } -func defaultStatuslineConfig() StatuslineConfig { - return StatuslineConfig{ +func defaultStatuslineConfig() *StatuslineConfig { + return &StatuslineConfig{ RenderFormat: "[%a] %S %>%T", Separator: " | ", DisplayMode: "", } } -func (config *AercConfig) parseStatusline(file *ini.File) error { +var Statusline = defaultStatuslineConfig() + +func parseStatusline(file *ini.File) error { statusline, err := file.GetSection("statusline") if err != nil { goto out } - if err := statusline.MapTo(&config.Statusline); err != nil { + if err := statusline.MapTo(&Statusline); err != nil { return err } out: - log.Debugf("aerc.conf: [statusline] %#v", config.Statusline) + log.Debugf("aerc.conf: [statusline] %#v", Statusline) return nil } |