about summary refs log tree commit diff stats
path: root/config/config.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-05-28 10:32:42 -0400
committerDrew DeVault <sir@cmpwn.com>2020-05-28 10:32:42 -0400
commitcaad1b2c06a0446059ee5ee916e3dce1794b159b (patch)
treeee81255485234137a5902d87d5960ac06618b341 /config/config.go
parent76a91813d8dc0f0011202f8120fc197097f022aa (diff)
downloadaerc-caad1b2c06a0446059ee5ee916e3dce1794b159b.tar.gz
Revert "Add Style configuration"
This reverts commit 0f78f06610c0e8887aba2ae50e99b86477a384b3.
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go63
1 files changed, 6 insertions, 57 deletions
diff --git a/config/config.go b/config/config.go
index c430724..8ebd69d 100644
--- a/config/config.go
+++ b/config/config.go
@@ -45,9 +45,6 @@ type UIConfig struct {
 	NextMessageOnDelete bool          `ini:"next-message-on-delete"`
 	CompletionDelay     time.Duration `ini:"completion-delay"`
 	CompletionPopovers  bool          `ini:"completion-popovers"`
-	StyleSetDirs        []string      `ini:"stylesets-dirs", delim:":"`
-	StyleSetName        string        `ini:"styleset-name"`
-	style               StyleSet
 }
 
 type ContextType int
@@ -335,11 +332,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 		if err := ui.MapTo(&config.Ui); err != nil {
 			return err
 		}
-
-		stylesetsDirs := ui.Key("stylesets-dirs").String()
-		if stylesetsDirs != "" {
-			config.Ui.StyleSetDirs = strings.Split(stylesetsDirs, ":")
-		}
 	}
 	for _, sectionName := range file.SectionStrings() {
 		if !strings.Contains(sectionName, "ui:") {
@@ -354,10 +346,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 		if err := uiSection.MapTo(&uiSubConfig); err != nil {
 			return err
 		}
-		stylesetsDirs := uiSection.Key("stylesets-dirs").String()
-		if stylesetsDirs != "" {
-			uiSubConfig.StyleSetDirs = strings.Split(stylesetsDirs, ":")
-		}
 		contextualUi :=
 			UIConfigContext{
 				UiConfig: uiSubConfig,
@@ -418,19 +406,6 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 			}
 		}
 	}
-
-	if err := config.Ui.loadStyleSet(
-		config.Ui.StyleSetDirs); err != nil {
-		return err
-	}
-
-	for idx, _ := range config.ContextualUis {
-		if err := config.ContextualUis[idx].UiConfig.loadStyleSet(
-			config.Ui.StyleSetDirs); err != nil {
-			return err
-		}
-	}
-
 	return nil
 }
 
@@ -491,8 +466,6 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 			NextMessageOnDelete: true,
 			CompletionDelay:     250 * time.Millisecond,
 			CompletionPopovers:  true,
-			StyleSetDirs:        []string{path.Join(sharedir, "stylesets")},
-			StyleSetName:        "default",
 		},
 
 		ContextualUis: []UIConfigContext{},
@@ -522,7 +495,6 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 			Forwards:     "forward_as_body",
 		},
 	}
-
 	// These bindings are not configurable
 	config.Bindings.AccountWizard.ExKey = KeyStroke{
 		Key: tcell.KeyCtrlE,
@@ -533,7 +505,6 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 	if err = config.LoadConfig(file); err != nil {
 		return nil, err
 	}
-
 	if ui, err := file.GetSection("general"); err == nil {
 		if err := ui.MapTo(&config.General); err != nil {
 			return nil, err
@@ -641,17 +612,8 @@ func parseLayout(layout string) [][]string {
 	return l
 }
 
-func (ui *UIConfig) loadStyleSet(styleSetDirs []string) error {
-	ui.style = NewStyleSet()
-	if err := ui.style.ParseStyleSet(ui.StyleSetName, styleSetDirs); err != nil {
-		return fmt.Errorf("Error whie parsing styleset \"%s\": %s", ui.StyleSetName, err)
-	}
-
-	return nil
-}
-
-func (config AercConfig) mergeContextualUi(baseUi UIConfig,
-	contextType ContextType, s string) UIConfig {
+func (config *AercConfig) mergeContextualUi(baseUi *UIConfig,
+	contextType ContextType, s string) {
 	for _, contextualUi := range config.ContextualUis {
 		if contextualUi.ContextType != contextType {
 			continue
@@ -661,30 +623,17 @@ func (config AercConfig) mergeContextualUi(baseUi UIConfig,
 			continue
 		}
 
-		mergo.Merge(&baseUi, contextualUi.UiConfig, mergo.WithOverride)
-		if contextualUi.UiConfig.StyleSetName != "" {
-			baseUi.style = contextualUi.UiConfig.style
-		}
-		return baseUi
+		mergo.MergeWithOverwrite(baseUi, contextualUi.UiConfig)
+		return
 	}
-
-	return baseUi
 }
 
-func (config AercConfig) GetUiConfig(params map[ContextType]string) UIConfig {
+func (config *AercConfig) GetUiConfig(params map[ContextType]string) UIConfig {
 	baseUi := config.Ui
 
 	for k, v := range params {
-		baseUi = config.mergeContextualUi(baseUi, k, v)
+		config.mergeContextualUi(&baseUi, k, v)
 	}
 
 	return baseUi
 }
-
-func (uiConfig UIConfig) GetStyle(so StyleObject) tcell.Style {
-	return uiConfig.style.Get(so)
-}
-
-func (uiConfig UIConfig) GetStyleSelected(so StyleObject) tcell.Style {
-	return uiConfig.style.Selected(so)
-}
232a31c621323ba1b8b93fad57c555b810'>90538f23 ^
531f14c9 ^

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56