diff options
Diffstat (limited to 'src/ansi.go')
-rw-r--r-- | src/ansi.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/ansi.go b/src/ansi.go index a80de478..876229f1 100644 --- a/src/ansi.go +++ b/src/ansi.go @@ -36,7 +36,7 @@ func init() { ansiRegex = regexp.MustCompile("\x1b\\[[0-9;]*[mK]") } -func extractColor(str *string, state *ansiState) (*string, []ansiOffset, *ansiState) { +func extractColor(str string, state *ansiState) (string, []ansiOffset, *ansiState) { var offsets []ansiOffset var output bytes.Buffer @@ -45,9 +45,9 @@ func extractColor(str *string, state *ansiState) (*string, []ansiOffset, *ansiSt } idx := 0 - for _, offset := range ansiRegex.FindAllStringIndex(*str, -1) { - output.WriteString((*str)[idx:offset[0]]) - newState := interpretCode((*str)[offset[0]:offset[1]], state) + for _, offset := range ansiRegex.FindAllStringIndex(str, -1) { + output.WriteString(str[idx:offset[0]]) + newState := interpretCode(str[offset[0]:offset[1]], state) if !newState.equals(state) { if state != nil { @@ -69,7 +69,7 @@ func extractColor(str *string, state *ansiState) (*string, []ansiOffset, *ansiSt idx = offset[1] } - rest := (*str)[idx:] + rest := str[idx:] if len(rest) > 0 { output.WriteString(rest) if state != nil { @@ -77,8 +77,7 @@ func extractColor(str *string, state *ansiState) (*string, []ansiOffset, *ansiSt (&offsets[len(offsets)-1]).offset[1] = int32(utf8.RuneCount(output.Bytes())) } } - outputStr := output.String() - return &outputStr, offsets, state + return output.String(), offsets, state } func interpretCode(ansiCode string, prevState *ansiState) *ansiState { |