File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -66,15 +66,37 @@ func (t *TextView) Buffer() ui.Buffer {
6666 x := t .Block .X + t .padding [0 ]
6767 y := t .Block .Y + t .padding [1 ]
6868
69+ colorMap := map [string ]string {
70+ "[31m" : "status.danger" ,
71+ "[33m" : "status.warn" ,
72+ "[39m" : "menu.text.fg" ,
73+ }
74+ colorCode := ""
75+ loopSkipper := 0
76+
6977 for _ , line := range t .TextOut {
70- for _ , ch := range line {
71- cell = ui.Cell {Ch : ch , Fg : t .TextFgColor , Bg : t .TextBgColor }
78+ colorCode = "[39m"
79+ for index , ch := range line {
80+ if loopSkipper > 0 {
81+ loopSkipper --
82+ continue
83+ }
84+
85+ // Checking to see the start of the color code
86+ if ch == '[' && line [index + 3 ] == 'm' {
87+ colorCode = string (line [index ]) + string (line [index + 1 ]) + string (line [index + 2 ]) + string (line [index + 3 ])
88+ loopSkipper = 3
89+ continue
90+ }
91+ cell = ui.Cell {Ch : ch , Fg : ui .ThemeAttr (colorMap [colorCode ]), Bg : t .TextBgColor }
92+
7293 buf .Set (x , y , cell )
7394 x ++
7495 }
7596 x = t .Block .X + t .padding [0 ]
7697 y ++
7798 }
99+
78100 return buf
79101}
80102
You can’t perform that action at this time.
0 commit comments