v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-29 05:50:17 -07:00

refactor: Change theme name to lowercase

This commit is contained in:
eeeXun 2023-04-27 01:05:51 +08:00
parent 7788d82c4f
commit a76807d254
2 changed files with 11 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"github.com/eeeXun/gtt/internal/style"
"github.com/eeeXun/gtt/internal/translate"
config "github.com/spf13/viper"
)
@ -15,7 +16,7 @@ func configInit() {
defaultConfig = map[string]interface{}{
"hide_below": false,
"transparent": false,
"theme": "Gruvbox",
"theme": "gruvbox",
"source.border_color": "red",
"destination.border_color": "blue",
"source.language.apertiumtranslate": "English",
@ -42,7 +43,7 @@ func configInit() {
}
config.AddConfigPath("$HOME/.config/gtt")
// Create config file if not exists
// Create config file if it does not exist
// Otherwise check if config value is missing
if err := config.ReadInConfig(); err != nil {
for key, value := range defaultConfig {
@ -60,6 +61,11 @@ func configInit() {
missing = true
}
}
// Set to default theme if theme in config does not exist
if IndexOf(config.GetString("theme"), style.AllTheme) < 0 {
config.Set("theme", defaultConfig["theme"])
missing = true
}
if missing {
config.WriteConfig()
}

View File

@ -5,10 +5,10 @@ import (
)
var (
AllTheme = []string{"Gruvbox", "Nord"}
AllTheme = []string{"gruvbox", "nord"}
Palette = []string{"red", "green", "yellow", "blue", "purple", "cyan", "orange"}
themes = map[string]map[string]tcell.Color{
"Gruvbox": {
"gruvbox": {
"bg": tcell.NewHexColor(0x282828),
"fg": tcell.NewHexColor(0xebdbb2),
"gray": tcell.NewHexColor(0x665c54),
@ -20,7 +20,7 @@ var (
"cyan": tcell.NewHexColor(0x8ec07c),
"orange": tcell.NewHexColor(0xfe8019),
},
"Nord": {
"nord": {
"bg": tcell.NewHexColor(0x3b4252),
"fg": tcell.NewHexColor(0xeceff4),
"gray": tcell.NewHexColor(0x4c566a),