summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-10-30 11:43:06 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-10-30 11:43:06 +0900
commit02c6ad0e59be75981baeb1f41cb0bad03aad1c6b (patch)
tree824dbde417c53d7d0165bc9b3a9f8de58bebed47
parent9f321cbe138fa2d19d13be078f2a5d4ba7412787 (diff)
Strip ^N and ^O from preview output
https://github.com/junegunn/fzf/issues/391#issuecomment-257090266 e.g. fzf --preview 'printf "$(tput setaf 2)foo$(tput sgr0)bar\nbar\n"'
-rw-r--r--src/curses/curses.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/curses/curses.go b/src/curses/curses.go
index 638a8629..e0e728c3 100644
--- a/src/curses/curses.go
+++ b/src/curses/curses.go
@@ -682,7 +682,13 @@ func (w *Window) Erase() {
}
func (w *Window) Fill(str string) bool {
- return C.waddstr(w.win, C.CString(str)) == C.OK
+ return C.waddstr(w.win, C.CString(strings.Map(func(r rune) rune {
+ // Remove ^N and ^O (set and unset altcharset)
+ if r == 14 || r == 15 {
+ return -1
+ }
+ return r
+ }, str))) == C.OK
}
func (w *Window) CFill(str string, fg int, bg int, a Attr) bool {