From 5514b0c6016d3770dc01f7f2b46d962f5e77aaf4 Mon Sep 17 00:00:00 2001 From: bertl4398 Date: Fri, 17 Aug 2018 21:24:22 +0200 Subject: [PATCH] update colors.go --- wtf/colors.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wtf/colors.go b/wtf/colors.go index b46be59b..befb20cf 100644 --- a/wtf/colors.go +++ b/wtf/colors.go @@ -1,6 +1,7 @@ package wtf import ( + "strings" "regexp" "strconv" @@ -411,7 +412,7 @@ var colors = map[string]tcell.Color{ func ASCIItoTviewColors(text string) string { boldRegExp := regexp.MustCompile(`\033\[1m`) - fgColorRegExp := regexp.MustCompile(`\033\[38;5;(?P\d+)m`) + fgColorRegExp := regexp.MustCompile(`\033\[38;5;(?P\d+);*\d*m`) resColorRegExp := regexp.MustCompile(`\033\[0m`) return resColorRegExp.ReplaceAllString( @@ -431,8 +432,10 @@ func colorFor(label string) tcell.Color { } func replaceWithHexColorString(substring string) string { - colorID, err := strconv.Atoi(substring[7 : len(substring)-1]) + colorID, err := strconv.Atoi(strings.Trim( + strings.Split(substring, ";")[2], "m")) if err != nil { + fmt.Println("ERROR", err) return substring }