diff options
| author | Paul Buetow <paul@buetow.org> | 2021-08-11 09:42:51 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2021-08-11 09:42:51 +0300 |
| commit | 1e00c256842e125a865a6cc3f9aa70a1a498f6dc (patch) | |
| tree | a7ebd3e782cf2abbb72bc06bf242363e1c6877f2 /internal/color/color.go | |
| parent | 9bb96433be61d89f8e86f6f9ded8e35f74156a63 (diff) | |
add paint.go
Diffstat (limited to 'internal/color/color.go')
| -rw-r--r-- | internal/color/color.go | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/internal/color/color.go b/internal/color/color.go index a2490be..692de51 100644 --- a/internal/color/color.go +++ b/internal/color/color.go @@ -52,35 +52,12 @@ const ( AttrHidden Attribute = escape + "[8m" ) -// Colored DTail client output enabled. -var Colored bool - -// Paint paints a given text in a given foreground/background color combination. -func Paint(text string, fg FgColor, bg BgColor) string { - return fmt.Sprintf("%s%s%s%s%s", fg, bg, text, BgDefault, FgDefault) -} - -// PaintWithAttr paints a given text in a given foreground/background/attribute combination -func PaintWithAttr(text string, fg FgColor, bg BgColor, attr Attribute) string { - if attr == AttrNone { - return Paint(text, fg, bg) - } - return fmt.Sprintf("%s%s%s%s%s%s%s", fg, bg, attr, text, AttrReset, BgDefault, FgDefault) -} - -// PaintFg paints a given text in a given foreground color. -func PaintFg(text string, fg FgColor) string { - return fmt.Sprintf("%s%s%s", fg, text, FgDefault) -} - -// PaintBg paints a given text in a given background color. -func PaintBg(text string, bg BgColor) string { - return fmt.Sprintf("%s%s%s", bg, text, BgDefault) +var ColorNames = []string{ + "Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White", "Default", } -// PaintAttr adds a given attribute to a given text, such as "bold" or "italic". -func PaintAttr(text string, attr Attribute) string { - return fmt.Sprintf("%s%s%s", attr, text, AttrReset) +var AttributeNames = []string{ + "Bold", "Dim", "Italic", "Underline", "Blink", "SlowBlink", "RapidBlink", "Reverse", "Hidden", "None", } // ToFgColor converts a given string (e.g. from a config file) into a foreground color code. |
