diff --git a/src/engine/image.go b/src/engine/image.go index efee113e..18e41b59 100644 --- a/src/engine/image.go +++ b/src/engine/image.go @@ -47,12 +47,14 @@ const ( fg = "FG" bg = "BG" + bc = "BC" // for base 16 colors str = "STR" url = "URL" invertedColor = "inverted" invertedColorSingle = "invertedsingle" fullColor = "full" foreground = "foreground" + background = "background" reset = "reset" bold = "bold" boldReset = "boldr" @@ -176,6 +178,7 @@ func (ir *ImageRenderer) Init(config string) { invertedColorSingle: `^(?P\x1b\[(?P\d{2,3});49m\x1b\[7m)`, fullColor: `^(?P(\x1b\[48;2;(?P(\d+;?){3})m)(\x1b\[38;2;(?P(\d+;?){3})m))`, foreground: `^(?P(\x1b\[38;2;(?P(\d+;?){3})m))`, + background: `^(?P(\x1b\[48;2;(?P(\d+;?){3})m))`, reset: `^(?P\x1b\[0m)`, bold: `^(?P\x1b\[1m)`, boldReset: `^(?P\x1b\[22m)`, @@ -185,7 +188,7 @@ func (ir *ImageRenderer) Init(config string) { underlineReset: `^(?P\x1b\[24m)`, strikethrough: `^(?P\x1b\[9m)`, strikethroughReset: `^(?P\x1b\[29m)`, - color16: `^(?P\x1b\[(?P\d{2,3})m)`, + color16: `^(?P\x1b\[(?P\d{2,3})m)`, left: `^(?P\x1b\[(\d{1,3})D)`, osc99: `^(?P\x1b\]9;9;(.+)\x1b\\)`, lineChange: `^(?P\x1b\[(\d)[FB])`, @@ -476,6 +479,9 @@ func (ir *ImageRenderer) shouldPrint() bool { case foreground: ir.foregroundColor = NewRGBColor(match[fg]) return false + case background: + ir.backgroundColor = NewRGBColor(match[bg]) + return false case reset: ir.foregroundColor = ir.defaultForegroundColor ir.backgroundColor = nil @@ -489,7 +495,7 @@ func (ir *ImageRenderer) shouldPrint() bool { case strikethrough, strikethroughReset, left, osc99, lineChange, consoleTitle: return false case color16: - ir.setBase16Color(match[fg]) + ir.setBase16Color(match[bc]) return false case link: ir.AnsiString = match[url] + ir.AnsiString