v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-19 09:10:42 -07:00

check borderColor changed

This commit is contained in:
eeeXun 2022-10-24 16:49:49 +08:00
parent e3f67f4454
commit 8901983ccc
2 changed files with 19 additions and 3 deletions

View File

@ -95,6 +95,14 @@ func (s Style) DstBorderColor() tcell.Color {
return Themes[theme][s.dst.borderColor] return Themes[theme][s.dst.borderColor]
} }
func (s Style) SrcBorderStr() string {
return s.src.borderColor
}
func (s Style) DstBorderStr() string {
return s.dst.borderColor
}
func (s *Style) SetSrcBorderColor(color string) *Style { func (s *Style) SetSrcBorderColor(color string) *Style {
s.src.borderColor = color s.src.borderColor = color
return s return s

View File

@ -23,8 +23,8 @@ func configInit() {
config.Set("transparent", false) config.Set("transparent", false)
config.Set("theme", "Gruvbox") config.Set("theme", "Gruvbox")
config.Set("source.language", "English") config.Set("source.language", "English")
config.Set("destination.language", "Chinese (Traditional)")
config.Set("source.borderColor", "red") config.Set("source.borderColor", "red")
config.Set("destination.language", "Chinese (Traditional)")
config.Set("destination.borderColor", "blue") config.Set("destination.borderColor", "blue")
if _, err = os.Stat(defaultConfigPath); os.IsNotExist(err) { if _, err = os.Stat(defaultConfigPath); os.IsNotExist(err) {
os.Mkdir(defaultConfigPath, os.ModePerm) os.Mkdir(defaultConfigPath, os.ModePerm)
@ -37,8 +37,8 @@ func configInit() {
transparent = config.GetBool("transparent") transparent = config.GetBool("transparent")
translator.srcLang = config.GetString("source.language") translator.srcLang = config.GetString("source.language")
translator.dstLang = config.GetString("destination.language") translator.dstLang = config.GetString("destination.language")
style.SetSrcBorderColor(config.GetString("source.borderColor")) style.SetSrcBorderColor(config.GetString("source.borderColor")).
style.SetDstBorderColor(config.GetString("destination.borderColor")) SetDstBorderColor(config.GetString("destination.borderColor"))
} }
// Check if need to modify config file when quit program // Check if need to modify config file when quit program
@ -57,10 +57,18 @@ func updateConfig() {
changed = true changed = true
config.Set("source.language", translator.srcLang) config.Set("source.language", translator.srcLang)
} }
if config.GetString("source.borderColor") != style.SrcBorderStr() {
changed = true
config.Set("source.borderColor", style.SrcBorderStr())
}
if config.GetString("destination.language") != translator.dstLang { if config.GetString("destination.language") != translator.dstLang {
changed = true changed = true
config.Set("destination.language", translator.dstLang) config.Set("destination.language", translator.dstLang)
} }
if config.GetString("destination.borderColor") != style.DstBorderStr() {
changed = true
config.Set("destination.borderColor", style.DstBorderStr())
}
if changed { if changed {
config.WriteConfig() config.WriteConfig()