16color fallback - argument handling error
This commit is contained in:
parent
a9e2212ed2
commit
5bc10073db
1 changed files with 37 additions and 4 deletions
|
@ -19,6 +19,7 @@ func rgb(r, g, b int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var colors = make(map[string]string)
|
var colors = make(map[string]string)
|
||||||
|
var oldcolors = make(map[string]int)
|
||||||
|
|
||||||
var logoIndex = 0
|
var logoIndex = 0
|
||||||
var isInProgressLine = false
|
var isInProgressLine = false
|
||||||
|
@ -52,12 +53,15 @@ func Initcolor() {
|
||||||
content = "red 255 0 0 \ngreen 0 255 0\nblue 0 0 255\nwhite 255 255 255"
|
content = "red 255 0 0 \ngreen 0 255 0\nblue 0 0 255\nwhite 255 255 255"
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(content), "\n")
|
lines := strings.Split(string(content), "\n")
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
word := strings.Split(line, " ")
|
word := strings.Split(line, " ")
|
||||||
|
|
||||||
R, _ := strconv.Atoi(word[1])
|
R, _ := strconv.Atoi(word[1])
|
||||||
G, _ := strconv.Atoi(word[2])
|
G, _ := strconv.Atoi(word[2])
|
||||||
B, _ := strconv.Atoi(word[3])
|
B, _ := strconv.Atoi(word[3])
|
||||||
colors[word[0]] = rgb(R, G, B)
|
colors[word[0]] = rgb(R, G, B)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,11 +131,13 @@ func uwuify(message string) string {
|
||||||
type Format struct {
|
type Format struct {
|
||||||
noUwuOverride bool
|
noUwuOverride bool
|
||||||
colorFormat string
|
colorFormat string
|
||||||
|
oldcolorFormat int
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFormat(format string) (parsedFormat Format) {
|
func parseFormat(format string) (parsedFormat Format) {
|
||||||
for _, v := range strings.Split(format, "|") {
|
for _, v := range strings.Split(format, "|") {
|
||||||
colorFormat, isColor := colors[v]
|
colorFormat, isColor := colors[v]
|
||||||
|
parsedFormat.colorFormat += colorFormat
|
||||||
if isColor && hascolor {
|
if isColor && hascolor {
|
||||||
parsedFormat.colorFormat += colorFormat
|
parsedFormat.colorFormat += colorFormat
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +150,7 @@ func parseFormat(format string) (parsedFormat Format) {
|
||||||
parsedFormat.noUwuOverride = true
|
parsedFormat.noUwuOverride = true
|
||||||
case "*":
|
case "*":
|
||||||
default:
|
default:
|
||||||
if hascolor {
|
if hascolor && !colorold {
|
||||||
println("Unknown format code: ", v)
|
println("Unknown format code: ", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +177,34 @@ func CutePrint(
|
||||||
if willUwuify {
|
if willUwuify {
|
||||||
message = uwuify(message)
|
message = uwuify(message)
|
||||||
}
|
}
|
||||||
|
if !colorold {
|
||||||
fmt.Printf("%s%s\x1b[0m", parsedFormat.colorFormat, message)
|
fmt.Printf("%s%s\x1b[0m", parsedFormat.colorFormat, message)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if colorold && hascolor {
|
||||||
|
switch {
|
||||||
|
case strings.Contains(format, "black"):
|
||||||
|
fmt.Printf("\033[1;30m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "red"):
|
||||||
|
fmt.Printf("\033[1;31m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "green"):
|
||||||
|
fmt.Printf("\033[1;32m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "yellow"):
|
||||||
|
fmt.Printf("\033[1;33m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "blue"):
|
||||||
|
fmt.Printf("\033[1;34m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "magenta"):
|
||||||
|
fmt.Printf("\033[1;35m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "cyan"):
|
||||||
|
fmt.Printf("\033[1;36m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "white"):
|
||||||
|
fmt.Printf("\033[1;37m%s\033[0m", message)
|
||||||
|
case strings.Contains(format, "*"):
|
||||||
|
fmt.Printf("\033[1;37m%s\033[0m", message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func CuteNewLine() {
|
func CuteNewLine() {
|
||||||
|
|
Loading…
Reference in a new issue