Suppress CSI codes in the output

pull/836/head
Junegunn Choi 8 years ago
parent bd9c46ee34
commit c95bb109c8
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -748,13 +748,17 @@ func (w *LightWindow) Print(text string) {
w.cprint2(colDefault, w.bg, AttrRegular, text) w.cprint2(colDefault, w.bg, AttrRegular, text)
} }
func cleanse(str string) string {
return strings.Replace(str, "\x1b", "?", -1)
}
func (w *LightWindow) CPrint(pair ColorPair, attr Attr, text string) { func (w *LightWindow) CPrint(pair ColorPair, attr Attr, text string) {
if !w.colored { if !w.colored {
w.csiColor(colDefault, colDefault, attrFor(pair, attr)) w.csiColor(colDefault, colDefault, attrFor(pair, attr))
} else { } else {
w.csiColor(pair.Fg(), pair.Bg(), attr) w.csiColor(pair.Fg(), pair.Bg(), attr)
} }
w.stderrInternal(text, false) w.stderrInternal(cleanse(text), false)
w.csi("m") w.csi("m")
} }
@ -762,7 +766,7 @@ func (w *LightWindow) cprint2(fg Color, bg Color, attr Attr, text string) {
if w.csiColor(fg, bg, attr) { if w.csiColor(fg, bg, attr) {
defer w.csi("m") defer w.csi("m")
} }
w.stderrInternal(text, false) w.stderrInternal(cleanse(text), false)
} }
type wrappedLine struct { type wrappedLine struct {

Loading…
Cancel
Save