diff options
author | Robin Jarry <robin@jarry.cc> | 2022-11-15 22:43:17 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-16 16:12:07 +0100 |
commit | 3710e459825b78a5adfa7af04128713010e4c9e4 (patch) | |
tree | 5367ff6138c2892ee1bb03aeeac6d8866c464152 /config/config.go | |
parent | f96172f5064b7245dfdb766163ceee856e2ee51b (diff) | |
download | aerc-3710e459825b78a5adfa7af04128713010e4c9e4.tar.gz |
config: move [viewer] parsing in separate file
The config.go file is getting too big. Move the aerc.conf [viewer]
section parsing logic into a dedicated viewer.go file.
No functional change.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'config/config.go')
-rw-r--r-- | config/config.go | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/config/config.go b/config/config.go index 95bf8d43..0c2bf5f3 100644 --- a/config/config.go +++ b/config/config.go @@ -16,16 +16,6 @@ import ( "git.sr.ht/~rjarry/aerc/logging" ) -type ViewerConfig struct { - Pager string - Alternatives []string - ShowHeaders bool `ini:"show-headers"` - AlwaysShowMime bool `ini:"always-show-mime"` - ParseHttpLinks bool `ini:"parse-http-links"` - HeaderLayout [][]string `ini:"-"` - KeyPassthrough bool `ini:"-"` -} - type StatuslineConfig struct { RenderFormat string `ini:"render-format"` Separator string @@ -143,19 +133,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { } } } - if viewer, err := file.GetSection("viewer"); err == nil { - if err := viewer.MapTo(&config.Viewer); err != nil { - return err - } - for key, val := range viewer.KeysHash() { - switch key { - case "alternatives": - config.Viewer.Alternatives = strings.Split(val, ",") - case "header-layout": - config.Viewer.HeaderLayout = parseLayout(val) - } - } - } if statusline, err := file.GetSection("statusline"); err == nil { if err := statusline.MapTo(&config.Statusline); err != nil { return err @@ -203,19 +180,7 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { General: defaultGeneralConfig(), Ui: defaultUiConfig(), ContextualUis: []UIConfigContext{}, - - Viewer: ViewerConfig{ - Pager: "less -R", - Alternatives: []string{"text/plain", "text/html"}, - ShowHeaders: false, - HeaderLayout: [][]string{ - {"From", "To"}, - {"Cc", "Bcc"}, - {"Date"}, - {"Subject"}, - }, - ParseHttpLinks: true, - }, + Viewer: defaultViewerConfig(), Statusline: StatuslineConfig{ RenderFormat: "[%a] %S %>%T", @@ -234,6 +199,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { if err := config.parseCompose(file); err != nil { return nil, err } + if err := config.parseViewer(file); err != nil { + return nil, err + } if err = config.LoadConfig(file); err != nil { return nil, err } @@ -245,7 +213,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) { } logging.Debugf("aerc.conf: [statusline] %#v", config.Statusline) - logging.Debugf("aerc.conf: [viewer] %#v", config.Viewer) logging.Debugf("aerc.conf: [openers] %#v", config.Openers) logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers) |