From 3c910ca08f742510191ea885a9631794db5f13a9 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Tue, 21 Nov 2023 17:41:04 +0100 Subject: [PATCH] works but is ugly :( --- cfg/config.go | 10 +++++----- lib/helpers.go | 17 +++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/cfg/config.go b/cfg/config.go index 94e6e20..acafbcc 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -104,17 +104,17 @@ var ValidHooks []string func Colors() map[color.Level]map[string]color.Color { return map[color.Level]map[string]color.Color{ color.Level16: { - "bg": color.BgGreen, "fg": color.FgBlack, + "bg": color.BgGreen, "fg": color.FgWhite, "hlbg": color.BgGray, "hlfg": color.FgWhite, }, color.Level256: { - "bg": color.BgLightGreen, "fg": color.FgBlack, - "hlbg": color.BgGray, "hlfg": color.FgWhite, + "bg": color.BgLightGreen, "fg": color.FgWhite, + "hlbg": color.BgLightBlue, "hlfg": color.FgWhite, }, color.LevelRgb: { // FIXME: maybe use something nicer - "bg": color.BgLightGreen, "fg": color.FgBlack, - "hlbg": color.BgGray, "hlfg": color.FgWhite, + "bg": color.BgLightGreen, "fg": color.FgWhite, + "hlbg": color.BgBlue, "hlfg": color.FgWhite, }, } } diff --git a/lib/helpers.go b/lib/helpers.go index 90707a0..9398cb2 100644 --- a/lib/helpers.go +++ b/lib/helpers.go @@ -156,21 +156,18 @@ func trimRow(row []string) []string { func colorizeData(c cfg.Config, output string) string { if len(c.Pattern) > 0 && !c.NoColor && color.IsConsole(os.Stdout) { r := regexp.MustCompile("(" + c.Pattern + ")") + return r.ReplaceAllStringFunc(output, func(in string) string { + return c.ColorStyle.Sprint(in) + }) + } else if c.UseHighlight && color.IsConsole(os.Stdout) { highlight := true colorized := "" for _, line := range strings.Split(output, "\n") { - if c.UseHighlight { - if highlight { - line = c.HighlightStyle.Sprint(line) - } - highlight = !highlight - } else { - line = r.ReplaceAllStringFunc(line, func(in string) string { - return c.ColorStyle.Sprint(in) - }) + if highlight { + line = c.HighlightStyle.Sprint(line) } - + highlight = !highlight colorized += line + "\n" }