From 02c6ad0e59be75981baeb1f41cb0bad03aad1c6b Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 30 Oct 2016 11:43:06 +0900 Subject: [PATCH] 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"' --- src/curses/curses.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/curses/curses.go b/src/curses/curses.go index 638a862..e0e728c 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 {