forked from tangled.org/core
this repo has no description
1package engine 2 3import ( 4 "io" 5 6 "regexp" 7) 8 9// regex to match ANSI escape codes (e.g., color codes, cursor moves) 10const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))" 11 12var re = regexp.MustCompile(ansi) 13 14type ansiStrippingWriter struct { 15 underlying io.Writer 16} 17 18func (w *ansiStrippingWriter) Write(p []byte) (int, error) { 19 clean := re.ReplaceAll(p, []byte{}) 20 return w.underlying.Write(clean) 21}