1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package config
import (
"git.sr.ht/~rjarry/aerc/log"
"github.com/go-ini/ini"
)
type StatuslineConfig struct {
StatusColumns []*ColumnDef `ini:"status-columns" parse:"ParseColumns" default:"left<*,center>=,right>*"`
ColumnSeparator string `ini:"column-separator" default:" "`
Separator string `ini:"separator" default:" | "`
DisplayMode string `ini:"display-mode" default:"text"`
}
var Statusline = new(StatuslineConfig)
func parseStatusline(file *ini.File) error {
statusline := file.Section("statusline")
if err := MapToStruct(statusline, Statusline, true); err != nil {
return err
}
log.Debugf("aerc.conf: [statusline] %#v", Statusline)
return nil
}
func (s *StatuslineConfig) ParseColumns(sec *ini.Section, key *ini.Key) ([]*ColumnDef, error) {
if !sec.HasKey("column-left") {
_, _ = sec.NewKey("column-left", "[{{.Account}}] {{.StatusInfo}}")
}
if !sec.HasKey("column-center") {
_, _ = sec.NewKey("column-center", "{{.PendingKeys}}")
}
if !sec.HasKey("column-right") {
_, _ = sec.NewKey("column-right", "{{.TrayInfo}}")
}
return ParseColumnDefs(key, sec)
}
|