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

@@ -69,14 +69,17 @@ func Run(opts *Options) {
}
if opts.Ansi {
if opts.Theme != nil {
var state *ansiState
ansiProcessor = func(data *string) (*string, []ansiOffset) {
return extractColor(data)
trimmed, offsets, newState := extractColor(data, state)
state = newState
return trimmed, offsets
}
} else {
// When color is disabled but ansi option is given,
// we simply strip out ANSI codes from the input
ansiProcessor = func(data *string) (*string, []ansiOffset) {
trimmed, _ := extractColor(data)
trimmed, _, _ := extractColor(data, nil)
return trimmed, nil
}
}