diff --git a/src/main.go b/src/main.go index 319eff2..c203d2a 100644 --- a/src/main.go +++ b/src/main.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" "time" + "unicode" ) // Build-time variables @@ -48,6 +49,20 @@ func run() { } asciiArtNoColor := asciiArt + // Rewrite last color code to the start of the next line + lastColor := "0" + for i := 1; i < len(asciiArt); i++ { + rune := rune(asciiArt[i]) + + if unicode.IsDigit(rune) && asciiArt[i-1] == '%' { + lastColor = string(rune) + } + + if rune == '\n' { + asciiArt = asciiArt[:i+1] + "%" + lastColor + asciiArt[i+1:] + } + } + // Setup color map and replace colors in ascii art colorMap := setupColorMap(asciiArtHeader) for key, value := range colorMap { @@ -107,7 +122,7 @@ func run() { } } - // Split ascii art into each lien + // Split ascii art into each line asciiArtSplit := strings.Split(asciiArt, "\n") asciiArtNoColorSplit := strings.Split(asciiArtNoColor, "\n")