From 9bb96433be61d89f8e86f6f9ded8e35f74156a63 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 11 Aug 2021 09:32:13 +0300 Subject: add colorTable option --- internal/color/table.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/color/table.go (limited to 'internal/color/table.go') diff --git a/internal/color/table.go b/internal/color/table.go new file mode 100644 index 0000000..8e40a78 --- /dev/null +++ b/internal/color/table.go @@ -0,0 +1,41 @@ +package color + +import ( + "fmt" + "os" +) + +var ColorNames = []string{ + "Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White", "Default", +} + +var AttributeNames = []string{ + "Bold", "Dim", "Italic", "Underline", "Blink", "SlowBlink", "RapidBlink", "Reverse", "Hidden", "None", +} + +func TablePrintAndExit() { + for _, attr := range AttributeNames { + if attr == "Hidden" || attr == "SlowBlink" { + continue + } + printColorTable(attr) + } + os.Exit(0) +} + +func printColorTable(attr string) { + for _, fg := range ColorNames { + fgColor, _ := ToFgColor(fg) + for _, bg := range ColorNames { + if fg == bg { + continue + } + bgColor, _ := ToBgColor(bg) + attribute, _ := ToAttribute(attr) + + text := fmt.Sprintf(" Foreground:%10s | Background:%10s | Attribute:%10s ", fg, bg, attr) + fmt.Print(PaintWithAttr(text, fgColor, bgColor, attribute)) + fmt.Print("\n") + } + } +} -- cgit v1.2.3