Fix #391 - Strip non-printable characters

This commit is contained in:
Junegunn Choi 2015-10-23 01:12:31 +09:00
parent ae04f56dbd
commit 4d709e0dd2

View File

@ -11,6 +11,7 @@ import "C"
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"syscall" "syscall"
"time" "time"
"unicode/utf8" "unicode/utf8"
@ -514,7 +515,12 @@ func MoveAndClear(y int, x int) {
} }
func Print(text string) { func Print(text string) {
C.addstr(C.CString(text)) C.addstr(C.CString(strings.Map(func(r rune) rune {
if r < 32 {
return -1
}
return r
}, text)))
} }
func CPrint(pair int, bold bool, text string) { func CPrint(pair int, bold bool, text string) {