handle unusual escape codes in files
This commit is contained in:
parent
bfd33f8437
commit
217d89ff96
15
ui.go
15
ui.go
@ -111,12 +111,14 @@ func (win *Win) print(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
for i := 0; i < len(s); i++ {
|
||||
r, w := utf8.DecodeRuneInString(s[i:])
|
||||
|
||||
if r == EscapeCode {
|
||||
i++
|
||||
if s[i] == '[' {
|
||||
j := strings.IndexByte(s[i:], 'm')
|
||||
if r == EscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
||||
j := strings.IndexByte(s[i:min(len(s), i+8)], 'm')
|
||||
|
||||
toks := strings.Split(s[i+1:i+j], ";")
|
||||
if j == -1 {
|
||||
continue
|
||||
}
|
||||
|
||||
toks := strings.Split(s[i+2:i+j], ";")
|
||||
|
||||
var nums []int
|
||||
for _, t := range toks {
|
||||
@ -185,10 +187,9 @@ func (win *Win) print(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
}
|
||||
}
|
||||
|
||||
i = i + j
|
||||
i += j
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if x >= win.w {
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user