ANSI parser now also handles SGR 39 and 49. Fixes #347

This commit is contained in:
Oliver 2020-01-08 17:16:08 +01:00
parent 5bbae91e1e
commit 1316ea7a4b
2 changed files with 9 additions and 1 deletions

View File

@ -145,9 +145,13 @@ func (a *ansi) Write(text []byte) (int, error) {
case "30", "31", "32", "33", "34", "35", "36", "37":
colorNumber, _ := strconv.Atoi(field)
foreground = lookupColor(colorNumber-30, false)
case "39":
foreground = "-"
case "40", "41", "42", "43", "44", "45", "46", "47":
colorNumber, _ := strconv.Atoi(field)
background = lookupColor(colorNumber-40, false)
case "49":
background = "-"
case "90", "91", "92", "93", "94", "95", "96", "97":
colorNumber, _ := strconv.Atoi(field)
foreground = lookupColor(colorNumber-90, true)

View File

@ -124,7 +124,11 @@ func overlayStyle(background tcell.Color, defaultStyle tcell.Style, fgColor, bgC
style = style.Foreground(defFg)
if fgColor != "" {
style = style.Foreground(tcell.GetColor(fgColor))
if fgColor == "-" {
style = style.Foreground(defFg)
} else {
style = style.Foreground(tcell.GetColor(fgColor))
}
}
if bgColor == "-" || bgColor == "" && defBg != tcell.ColorDefault {