mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-15 23:46:12 +00:00
Fix color codes not carrying over from last line of ascii art
This commit is contained in:
+16
-1
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user