aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/style.go32
-rw-r--r--config/templates.go1
-rw-r--r--config/ui.go4
3 files changed, 37 insertions, 0 deletions
diff --git a/config/style.go b/config/style.go
index 65c5a3b1..317c77d0 100644
--- a/config/style.go
+++ b/config/style.go
@@ -254,6 +254,7 @@ func (s Style) composeWith(styles []*Style) Style {
type StyleSet struct {
objects map[StyleObject]*Style
selected map[StyleObject]*Style
+ user map[string]*Style
path string
}
@@ -261,6 +262,7 @@ func NewStyleSet() StyleSet {
ss := StyleSet{
objects: make(map[StyleObject]*Style),
selected: make(map[StyleObject]*Style),
+ user: make(map[string]*Style),
}
for _, so := range StyleNames {
ss.objects[so] = new(Style)
@@ -285,6 +287,10 @@ func (ss StyleSet) Selected(so StyleObject) tcell.Style {
return ss.selected[so].Get()
}
+func (ss StyleSet) UserStyle(name string) tcell.Style {
+ return ss.user[name].Get()
+}
+
func (ss StyleSet) Compose(so StyleObject, sos []StyleObject) tcell.Style {
base := *ss.objects[so]
styles := make([]*Style, len(sos))
@@ -437,6 +443,32 @@ func (ss *StyleSet) ParseStyleSet(file *ini.File) error {
}
}
+ user, err := file.GetSection("user")
+ if err != nil {
+ // This errors if the section doesn't exist, which is ok
+ return nil
+ }
+ for _, key := range user.KeyStrings() {
+ tokens := strings.Split(key, ".")
+ var styleName, attr string
+ switch len(tokens) {
+ case 2:
+ styleName, attr = tokens[0], tokens[1]
+ default:
+ return errors.New("Style parsing error: " + key)
+ }
+ val := user.KeysHash()[key]
+ s, ok := ss.user[styleName]
+ if !ok {
+ // Haven't seen this name before, add it to the map
+ s = &Style{}
+ ss.user[styleName] = s
+ }
+ if err := s.Set(attr, val); err != nil {
+ return err
+ }
+ }
+
return nil
}
diff --git a/config/templates.go b/config/templates.go
index bc05be66..f618d365 100644
--- a/config/templates.go
+++ b/config/templates.go
@@ -111,3 +111,4 @@ func (d *dummyData) ContentInfo() string { return "" }
func (d *dummyData) StatusInfo() string { return "" }
func (d *dummyData) TrayInfo() string { return "" }
func (d *dummyData) PendingKeys() string { return "" }
+func (d *dummyData) Style(string, string) string { return "" }
diff --git a/config/ui.go b/config/ui.go
index b1330ffd..64469643 100644
--- a/config/ui.go
+++ b/config/ui.go
@@ -629,6 +629,10 @@ func (base *UIConfig) mergeContextual(
return base
}
+func (uiConfig *UIConfig) GetUserStyle(name string) tcell.Style {
+ return uiConfig.style.UserStyle(name)
+}
+
func (uiConfig *UIConfig) GetStyle(so StyleObject) tcell.Style {
return uiConfig.style.Get(so)
}