Label stylizes text based on label's RGB hex color.
(hex string, x string)
| 264 | |
| 265 | // Label stylizes text based on label's RGB hex color. |
| 266 | func (c *ColorScheme) Label(hex string, x string) string { |
| 267 | if !c.Enabled || !c.TrueColor || !c.ColorLabels || len(hex) != 6 { |
| 268 | return x |
| 269 | } |
| 270 | |
| 271 | r, _ := strconv.ParseInt(hex[0:2], 16, 64) |
| 272 | g, _ := strconv.ParseInt(hex[2:4], 16, 64) |
| 273 | b, _ := strconv.ParseInt(hex[4:6], 16, 64) |
| 274 | return fmt.Sprintf("\033[38;2;%d;%d;%dm%s\033[0m", r, g, b, x) |
| 275 | } |
| 276 | |
| 277 | func (c *ColorScheme) TableHeader(t string) string { |
| 278 | // Table headers are only stylized if color is enabled including underline modifier. |