use config color

This commit is contained in:
raziman 2020-08-02 17:26:39 +08:00
parent 05cb4f1534
commit f3f317f2f3
3 changed files with 14 additions and 9 deletions

View File

@ -34,7 +34,7 @@ type Gomu struct {
func newGomu() *Gomu {
gomu := &Gomu{
popupBg: tcell.GetColor("#0A0F14"),
popupBg: tcell.GetColor(viper.GetString("color.popup")),
textColor: tcell.GetColor(viper.GetString("color.foreground")),
accentColor: tcell.GetColor(viper.GetString("color.accent")),
}

View File

@ -140,6 +140,9 @@ func timedPopup(
SetText(desc).
SetTextColor(gomu.accentColor)
// debugLog(fmt.Sprintf("from color: %d", tcell.GetColor("#FF0000")))
// debugLog(fmt.Sprintf("from color: %d", tcell.GetColor("#0A0F14")))
// debugLog(fmt.Sprintf("from config: %d", gomu.popupBg))
textView.SetTextAlign(tview.AlignCenter).SetBackgroundColor(gomu.popupBg)
box := tview.NewFrame(textView).SetBorders(1, 0, 0, 0, 0, 0)

View File

@ -95,16 +95,18 @@ func readConfig(args Args) {
}
}
} else {
// Validate hex color
for k, v := range colors {
cfgColor := viper.GetString(k)
if validateHexColor(cfgColor) {
continue
// Validate hex color
for k, v := range colors {
cfgColor := viper.GetString(k)
if validateHexColor(cfgColor) {
continue
}
// debugLog(fmt.Sprintf("%s is replaced by %s", cfgColor, v))
// use default value if invalid hex color was given
viper.Set(k, v)
}
// use default value if invalid hex color was given
viper.Set(k, v)
}
}