1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/theme/style.go

45 lines
860 B
Go
Raw Normal View History

2021-07-31 09:15:38 +02:00
package theme
import (
"github.com/gookit/color"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/utils"
)
func GetTextStyle(keys []string, background bool) style.TextStyle {
s := style.New()
for _, key := range keys {
switch key {
case "bold":
s = s.SetBold()
case "reverse":
s = s.SetReverse()
case "underline":
s = s.SetUnderline()
2023-05-21 02:45:45 +02:00
case "strikethrough":
s = s.SetStrikethrough()
2021-07-31 09:15:38 +02:00
default:
value, present := style.ColorMap[key]
2021-07-31 09:15:38 +02:00
if present {
var c style.TextStyle
if background {
c = value.Background
2021-07-31 09:15:38 +02:00
} else {
c = value.Foreground
2021-07-31 09:15:38 +02:00
}
s = s.MergeStyle(c)
} else if utils.IsValidHexValue(key) {
c := style.NewRGBColor(color.HEX(key, background))
if background {
s = s.SetBg(c)
2021-07-31 09:15:38 +02:00
} else {
s = s.SetFg(c)
2021-07-31 09:15:38 +02:00
}
}
}
}
return s
}