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"
|
|
|
|
)
|
|
|
|
|
2021-08-07 17:06:36 +02:00
|
|
|
var colorMap = style.ColorMap
|
2021-07-31 09:15:38 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
default:
|
|
|
|
value, present := colorMap[key]
|
|
|
|
if present {
|
|
|
|
var c style.TextStyle
|
|
|
|
if background {
|
2021-08-07 17:06:36 +02:00
|
|
|
c = value.Background
|
2021-07-31 09:15:38 +02:00
|
|
|
} else {
|
2021-08-07 17:06:36 +02:00
|
|
|
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.SetBg(c)
|
|
|
|
} else {
|
|
|
|
s.SetFg(c)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return s
|
|
|
|
}
|