mirror of
https://github.com/eeeXun/GTT.git
synced 2025-06-02 16:00:33 -07:00
fix: theme importing should before reading config file
This commit is contained in:
parent
fd4dab9217
commit
5b2d955eb8
26
config.go
26
config.go
@ -50,6 +50,19 @@ func configInit() {
|
|||||||
config.AddConfigPath("$HOME/.config/gtt")
|
config.AddConfigPath("$HOME/.config/gtt")
|
||||||
themeConfig.AddConfigPath("$HOME/.config/gtt")
|
themeConfig.AddConfigPath("$HOME/.config/gtt")
|
||||||
|
|
||||||
|
// import theme if file exists
|
||||||
|
if err := themeConfig.ReadInConfig(); err == nil {
|
||||||
|
var (
|
||||||
|
palate = make(map[string]int32)
|
||||||
|
colors = []string{"bg", "fg", "gray", "red", "green", "yellow", "blue", "purple", "cyan", "orange"}
|
||||||
|
)
|
||||||
|
for name := range themeConfig.AllSettings() {
|
||||||
|
for _, color := range colors {
|
||||||
|
palate[color] = themeConfig.GetInt32(fmt.Sprintf("%s.%s", name, color))
|
||||||
|
}
|
||||||
|
style.NewTheme(name, palate)
|
||||||
|
}
|
||||||
|
}
|
||||||
// Create config file if it does not exist
|
// Create config file if it does not exist
|
||||||
// Otherwise check if config value is missing
|
// Otherwise check if config value is missing
|
||||||
if err := config.ReadInConfig(); err != nil {
|
if err := config.ReadInConfig(); err != nil {
|
||||||
@ -82,19 +95,6 @@ func configInit() {
|
|||||||
config.WriteConfig()
|
config.WriteConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// import theme if file exists
|
|
||||||
if err := themeConfig.ReadInConfig(); err == nil {
|
|
||||||
var (
|
|
||||||
palate = make(map[string]int32)
|
|
||||||
colors = []string{"bg", "fg", "gray", "red", "green", "yellow", "blue", "purple", "cyan", "orange"}
|
|
||||||
)
|
|
||||||
for name := range themeConfig.AllSettings() {
|
|
||||||
for _, color := range colors {
|
|
||||||
palate[color] = themeConfig.GetInt32(fmt.Sprintf("%s.%s", name, color))
|
|
||||||
}
|
|
||||||
style.NewTheme(name, palate)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
for _, name := range translate.AllTranslator {
|
for _, name := range translate.AllTranslator {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user