works but is ugly :(

This commit is contained in:
2023-11-21 17:41:04 +01:00
parent a8c9ede77e
commit 3c910ca08f
2 changed files with 12 additions and 15 deletions

View File

@@ -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,
},
}
}

View File

@@ -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"
}