mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-19 01:00:20 -07:00
check borderColor changed
This commit is contained in:
parent
e3f67f4454
commit
8901983ccc
8
color.go
8
color.go
@ -95,6 +95,14 @@ func (s Style) DstBorderColor() tcell.Color {
|
||||
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 {
|
||||
s.src.borderColor = color
|
||||
return s
|
||||
|
14
config.go
14
config.go
@ -23,8 +23,8 @@ func configInit() {
|
||||
config.Set("transparent", false)
|
||||
config.Set("theme", "Gruvbox")
|
||||
config.Set("source.language", "English")
|
||||
config.Set("destination.language", "Chinese (Traditional)")
|
||||
config.Set("source.borderColor", "red")
|
||||
config.Set("destination.language", "Chinese (Traditional)")
|
||||
config.Set("destination.borderColor", "blue")
|
||||
if _, err = os.Stat(defaultConfigPath); os.IsNotExist(err) {
|
||||
os.Mkdir(defaultConfigPath, os.ModePerm)
|
||||
@ -37,8 +37,8 @@ func configInit() {
|
||||
transparent = config.GetBool("transparent")
|
||||
translator.srcLang = config.GetString("source.language")
|
||||
translator.dstLang = config.GetString("destination.language")
|
||||
style.SetSrcBorderColor(config.GetString("source.borderColor"))
|
||||
style.SetDstBorderColor(config.GetString("destination.borderColor"))
|
||||
style.SetSrcBorderColor(config.GetString("source.borderColor")).
|
||||
SetDstBorderColor(config.GetString("destination.borderColor"))
|
||||
}
|
||||
|
||||
// Check if need to modify config file when quit program
|
||||
@ -57,10 +57,18 @@ func updateConfig() {
|
||||
changed = true
|
||||
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 {
|
||||
changed = true
|
||||
config.Set("destination.language", translator.dstLang)
|
||||
}
|
||||
if config.GetString("destination.borderColor") != style.DstBorderStr() {
|
||||
changed = true
|
||||
config.Set("destination.borderColor", style.DstBorderStr())
|
||||
}
|
||||
|
||||
if changed {
|
||||
config.WriteConfig()
|
||||
|
Loading…
x
Reference in New Issue
Block a user