m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 06:43:47 -05:00

Fix ANSI processor to handle multi-line regions

This commit is contained in:
Junegunn Choi
2015-07-22 14:19:45 +09:00
parent f71ea5f3ea
commit 5e3cb3a4ea
4 changed files with 72 additions and 20 deletions

View File

@@ -36,11 +36,13 @@ func init() {
ansiRegex = regexp.MustCompile("\x1b\\[[0-9;]*[mK]")
}
func extractColor(str *string) (*string, []ansiOffset) {
func extractColor(str *string, state *ansiState) (*string, []ansiOffset, *ansiState) {
var offsets []ansiOffset
var output bytes.Buffer
var state *ansiState
if state != nil {
offsets = append(offsets, ansiOffset{[2]int32{0, 0}, *state})
}
idx := 0
for _, offset := range ansiRegex.FindAllStringIndex(*str, -1) {
@@ -76,7 +78,7 @@ func extractColor(str *string) (*string, []ansiOffset) {
}
}
outputStr := output.String()
return &outputStr, offsets
return &outputStr, offsets, state
}
func interpretCode(ansiCode string, prevState *ansiState) *ansiState {