From 8d20e9218ece5927d786d6e2fac5c50572fb9c81 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 15 Mar 2019 01:12:06 -0400 Subject: Implement key bindings subsystem Which is not yet rigged up --- config/config.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go index 142a1e0..ff0e094 100644 --- a/config/config.go +++ b/config/config.go @@ -29,6 +29,7 @@ type AccountConfig struct { } type AercConfig struct { + Lbinds *KeyBindings Ini *ini.File `ini:"-"` Accounts []AccountConfig `ini:"-"` Ui UIConfig @@ -94,7 +95,9 @@ func LoadConfig(root *string) (*AercConfig, error) { } file.NameMapper = mapName config := &AercConfig{ - Ini: file, + Lbinds: NewKeyBindings(), + Ini: file, + Ui: UIConfig{ IndexFormat: "%4C %Z %D %-17.17n %s", TimestampFormat: "%F %l:%M %p", @@ -110,9 +113,18 @@ func LoadConfig(root *string) (*AercConfig, error) { EmptyMessage: "(no messages)", }, } - if ui, err := file.GetSection("ui"); err != nil { + if ui, err := file.GetSection("ui"); err == nil { ui.MapTo(config.Ui) } + if lbinds, err := file.GetSection("lbinds"); err == nil { + for key, value := range lbinds.KeysHash() { + binding, err := ParseBinding(key, value) + if err != nil { + return nil, err + } + config.Lbinds.Add(binding) + } + } accountsPath := path.Join(*root, "accounts.conf") if accounts, err := loadAccountConfig(accountsPath); err != nil { return nil, err -- cgit v1.2.3