mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 04:30:56 +01:00
works but is ugly :(
This commit is contained in:
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user