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 {
|
func Colors() map[color.Level]map[string]color.Color {
|
||||||
return map[color.Level]map[string]color.Color{
|
return map[color.Level]map[string]color.Color{
|
||||||
color.Level16: {
|
color.Level16: {
|
||||||
"bg": color.BgGreen, "fg": color.FgBlack,
|
"bg": color.BgGreen, "fg": color.FgWhite,
|
||||||
"hlbg": color.BgGray, "hlfg": color.FgWhite,
|
"hlbg": color.BgGray, "hlfg": color.FgWhite,
|
||||||
},
|
},
|
||||||
color.Level256: {
|
color.Level256: {
|
||||||
"bg": color.BgLightGreen, "fg": color.FgBlack,
|
"bg": color.BgLightGreen, "fg": color.FgWhite,
|
||||||
"hlbg": color.BgGray, "hlfg": color.FgWhite,
|
"hlbg": color.BgLightBlue, "hlfg": color.FgWhite,
|
||||||
},
|
},
|
||||||
color.LevelRgb: {
|
color.LevelRgb: {
|
||||||
// FIXME: maybe use something nicer
|
// FIXME: maybe use something nicer
|
||||||
"bg": color.BgLightGreen, "fg": color.FgBlack,
|
"bg": color.BgLightGreen, "fg": color.FgWhite,
|
||||||
"hlbg": color.BgGray, "hlfg": 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 {
|
func colorizeData(c cfg.Config, output string) string {
|
||||||
if len(c.Pattern) > 0 && !c.NoColor && color.IsConsole(os.Stdout) {
|
if len(c.Pattern) > 0 && !c.NoColor && color.IsConsole(os.Stdout) {
|
||||||
r := regexp.MustCompile("(" + c.Pattern + ")")
|
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
|
highlight := true
|
||||||
colorized := ""
|
colorized := ""
|
||||||
|
|
||||||
for _, line := range strings.Split(output, "\n") {
|
for _, line := range strings.Split(output, "\n") {
|
||||||
if c.UseHighlight {
|
if highlight {
|
||||||
if highlight {
|
line = c.HighlightStyle.Sprint(line)
|
||||||
line = c.HighlightStyle.Sprint(line)
|
|
||||||
}
|
|
||||||
highlight = !highlight
|
|
||||||
} else {
|
|
||||||
line = r.ReplaceAllStringFunc(line, func(in string) string {
|
|
||||||
return c.ColorStyle.Sprint(in)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
highlight = !highlight
|
||||||
colorized += line + "\n"
|
colorized += line + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user