mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
update colors.go
This commit is contained in:
parent
be29efc197
commit
5514b0c601
@ -1,6 +1,7 @@
|
|||||||
package wtf
|
package wtf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -411,7 +412,7 @@ var colors = map[string]tcell.Color{
|
|||||||
|
|
||||||
func ASCIItoTviewColors(text string) string {
|
func ASCIItoTviewColors(text string) string {
|
||||||
boldRegExp := regexp.MustCompile(`\033\[1m`)
|
boldRegExp := regexp.MustCompile(`\033\[1m`)
|
||||||
fgColorRegExp := regexp.MustCompile(`\033\[38;5;(?P<color>\d+)m`)
|
fgColorRegExp := regexp.MustCompile(`\033\[38;5;(?P<color>\d+);*\d*m`)
|
||||||
resColorRegExp := regexp.MustCompile(`\033\[0m`)
|
resColorRegExp := regexp.MustCompile(`\033\[0m`)
|
||||||
|
|
||||||
return resColorRegExp.ReplaceAllString(
|
return resColorRegExp.ReplaceAllString(
|
||||||
@ -431,8 +432,10 @@ func colorFor(label string) tcell.Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func replaceWithHexColorString(substring string) string {
|
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 {
|
if err != nil {
|
||||||
|
fmt.Println("ERROR", err)
|
||||||
return substring
|
return substring
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user