Fix color codes not carrying over from last line of ascii art

This commit is contained in:
2025-12-21 22:19:55 +02:00
parent 9680c024b9
commit 92ea038c77
+16 -1
View File
@@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"unicode"
) )
// Build-time variables // Build-time variables
@@ -48,6 +49,20 @@ func run() {
} }
asciiArtNoColor := asciiArt 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 // Setup color map and replace colors in ascii art
colorMap := setupColorMap(asciiArtHeader) colorMap := setupColorMap(asciiArtHeader)
for key, value := range colorMap { 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") asciiArtSplit := strings.Split(asciiArt, "\n")
asciiArtNoColorSplit := strings.Split(asciiArtNoColor, "\n") asciiArtNoColorSplit := strings.Split(asciiArtNoColor, "\n")