blob: 69c404e3b9d1e3ada91c88d47a9b7cb8b8f80462 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
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()
default:
value, present := style.ColorMap[key]
if present {
var c style.TextStyle
if background {
c = value.Background
} else {
c = value.Foreground
}
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
}
|