diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-02-02 13:14:27 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-02-02 13:14:27 +0900 |
commit | c95bb109c83f8a1b7b4a7c316ab7f0c1ef845cd9 (patch) | |
tree | 925f4270dc63bcfa44ce37394279aa5ea2ec1c70 | |
parent | bd9c46ee348811f5e42f13ff57d835d5f9301df7 (diff) |
Suppress CSI codes in the output
-rw-r--r-- | src/tui/light.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tui/light.go b/src/tui/light.go index d5631ec9..2ce0d5ff 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -748,13 +748,17 @@ func (w *LightWindow) Print(text string) { 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) { if !w.colored { w.csiColor(colDefault, colDefault, attrFor(pair, attr)) } else { w.csiColor(pair.Fg(), pair.Bg(), attr) } - w.stderrInternal(text, false) + w.stderrInternal(cleanse(text), false) 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) { defer w.csi("m") } - w.stderrInternal(text, false) + w.stderrInternal(cleanse(text), false) } type wrappedLine struct { |