Skip to content
Myr

Update ANSI processor to ignore ^N and ^O

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This reverts commit 02c6ad0e59be75981baeb1f41cb0bad03aad1c6b.

authored by Junegunn Choi · committed by Junegunn Choi · parent 02c6ad0 · Browse files · 2 files+3 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−9 removed

  • other:+3 added−9 removed

2 files+3 added−9 removed

modified:src/curses/curses.go+1 added-7 removed
680 unmodified lines
681 C.werase(w.win)682}683684func (w *Window) Fill(str string) bool {685 return C.waddstr(w.win, C.CString(strings.Map(func(r rune) rune {686 // Remove ^N and ^O (set and unset altcharset)687 if r == 14 || r == 15 {688 return -1689 }690 return r691 }, str))) == C.OK685 return C.waddstr(w.win, C.CString(str)) == C.OK686}687688func (w *Window) CFill(str string, fg int, bg int, a Attr) bool {689 attr := _colorFn(PairFor(fg, bg), a)
25 unmodified lines
modified:src/ansi.go+2 added-2 removed
33 unmodified lines
3435var ansiRegex *regexp.Regexp3637func init() {38 ansiRegex = regexp.MustCompile("\x1b.[0-9;]*.")38 ansiRegex = regexp.MustCompile("\x1b\\[[0-9;]*.|[\x0e\x0f]")39}4041func extractColor(str string, state *ansiState, proc func(string, *ansiState) bool) (string, *[]ansiOffset, *ansiState) {42 var offsets []ansiOffset
56 unmodified lines
99 state = &ansiState{-1, -1, 0}100 } else {101 state = &ansiState{prevState.fg, prevState.bg, prevState.attr}102 }103 if ansiCode[1] != '[' || ansiCode[len(ansiCode)-1] != 'm' {103 if ansiCode[0] != '\x1b' || ansiCode[len(ansiCode)-1] != 'm' {104 return state105 }106107 ptr := &state.fg
66 unmodified lines