diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2019-03-06 19:05:05 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2019-03-06 19:05:05 +0900 |
commit | ef577a65094a38f82b2c18dfd3e524eb50748503 (patch) | |
tree | 54b4cb94db71b31e781ab2405732f812e6dd0df2 /src/util/chars.go | |
parent | b7c6838e4574fc07699fd7ea52e893021853cb42 (diff) |
Preserve the original color of each token when using --with-nth with --ansi
Close #1500
Diffstat (limited to 'src/util/chars.go')
-rw-r--r-- | src/util/chars.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/chars.go b/src/util/chars.go index ec6fca0e..35b28297 100644 --- a/src/util/chars.go +++ b/src/util/chars.go @@ -171,3 +171,12 @@ func (chars *Chars) CopyRunes(dest []rune) { } return } + +func (chars *Chars) Wrap(prefix string, suffix string) { + if runes := chars.optionalRunes(); runes != nil { + runes = append(append([]rune(prefix), runes...), []rune(suffix)...) + chars.slice = *(*[]byte)(unsafe.Pointer(&runes)) + } else { + chars.slice = append(append([]byte(prefix), chars.slice...), []byte(suffix)...) + } +} |