Update ANSI processor to ignore ^N and ^O

This reverts commit 02c6ad0e59.
This commit is contained in:
Junegunn Choi 2016-10-30 12:29:29 +09:00
parent 02c6ad0e59
commit 06a6ad8bca
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 3 additions and 9 deletions

View File

@ -35,7 +35,7 @@ func (s *ansiState) equals(t *ansiState) bool {
var ansiRegex *regexp.Regexp var ansiRegex *regexp.Regexp
func init() { func init() {
ansiRegex = regexp.MustCompile("\x1b.[0-9;]*.") ansiRegex = regexp.MustCompile("\x1b\\[[0-9;]*.|[\x0e\x0f]")
} }
func extractColor(str string, state *ansiState, proc func(string, *ansiState) bool) (string, *[]ansiOffset, *ansiState) { func extractColor(str string, state *ansiState, proc func(string, *ansiState) bool) (string, *[]ansiOffset, *ansiState) {
@ -100,7 +100,7 @@ func interpretCode(ansiCode string, prevState *ansiState) *ansiState {
} else { } else {
state = &ansiState{prevState.fg, prevState.bg, prevState.attr} state = &ansiState{prevState.fg, prevState.bg, prevState.attr}
} }
if ansiCode[1] != '[' || ansiCode[len(ansiCode)-1] != 'm' { if ansiCode[0] != '\x1b' || ansiCode[len(ansiCode)-1] != 'm' {
return state return state
} }

View File

@ -682,13 +682,7 @@ func (w *Window) Erase() {
} }
func (w *Window) Fill(str string) bool { func (w *Window) Fill(str string) bool {
return C.waddstr(w.win, C.CString(strings.Map(func(r rune) rune { return C.waddstr(w.win, C.CString(str)) == C.OK
// 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 { func (w *Window) CFill(str string, fg int, bg int, a Attr) bool {