| 7 | ) |
| 8 | |
| 9 | func GetTextStyle(keys []string, background bool) style.TextStyle { |
| 10 | s := style.New() |
| 11 | |
| 12 | for _, key := range keys { |
| 13 | switch key { |
| 14 | case "bold": |
| 15 | s = s.SetBold() |
| 16 | case "reverse": |
| 17 | s = s.SetReverse() |
| 18 | case "underline": |
| 19 | s = s.SetUnderline() |
| 20 | case "strikethrough": |
| 21 | s = s.SetStrikethrough() |
| 22 | default: |
| 23 | value, present := style.ColorMap[key] |
| 24 | if present { |
| 25 | var c style.TextStyle |
| 26 | if background { |
| 27 | c = value.Background |
| 28 | } else { |
| 29 | c = value.Foreground |
| 30 | } |
| 31 | s = s.MergeStyle(c) |
| 32 | } else if utils.IsValidHexValue(key) { |
| 33 | c := style.NewRGBColor(color.HEX(key, background)) |
| 34 | if background { |
| 35 | s = s.SetBg(c) |
| 36 | } else { |
| 37 | s = s.SetFg(c) |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return s |
| 44 | } |