|
|
|
@ -23,9 +23,9 @@ public class AnsiProcess : Process
|
|
|
|
|
StartInfo.RedirectStandardError = true; |
|
|
|
|
|
|
|
|
|
// Need this to parse ANSI escape sequences correctly |
|
|
|
|
StartInfo.StandardOutputEncoding = Encoding.UTF8; |
|
|
|
|
StartInfo.StandardErrorEncoding = Encoding.UTF8; |
|
|
|
|
StartInfo.StandardInputEncoding = Encoding.UTF8; |
|
|
|
|
StartInfo.StandardOutputEncoding = new UTF8Encoding(false); |
|
|
|
|
StartInfo.StandardErrorEncoding = new UTF8Encoding(false); |
|
|
|
|
StartInfo.StandardInputEncoding = new UTF8Encoding(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -35,18 +35,28 @@ public class AnsiProcess : Process
|
|
|
|
|
public void BeginAnsiRead(Action<ProcessOutput> callback) |
|
|
|
|
{ |
|
|
|
|
var stdoutStream = StandardOutput.BaseStream; |
|
|
|
|
stdoutReader = new AsyncStreamReader(stdoutStream, s => |
|
|
|
|
stdoutReader = new AsyncStreamReader( |
|
|
|
|
stdoutStream, |
|
|
|
|
s => |
|
|
|
|
{ |
|
|
|
|
if (s == null) return; |
|
|
|
|
if (s == null) |
|
|
|
|
return; |
|
|
|
|
callback(ProcessOutput.FromStdOutLine(s)); |
|
|
|
|
}, StandardOutput.CurrentEncoding); |
|
|
|
|
}, |
|
|
|
|
StandardOutput.CurrentEncoding |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
var stderrStream = StandardError.BaseStream; |
|
|
|
|
stderrReader = new AsyncStreamReader(stderrStream, s => |
|
|
|
|
stderrReader = new AsyncStreamReader( |
|
|
|
|
stderrStream, |
|
|
|
|
s => |
|
|
|
|
{ |
|
|
|
|
if (s == null) return; |
|
|
|
|
if (s == null) |
|
|
|
|
return; |
|
|
|
|
callback(ProcessOutput.FromStdErrLine(s)); |
|
|
|
|
}, StandardError.CurrentEncoding); |
|
|
|
|
}, |
|
|
|
|
StandardError.CurrentEncoding |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
stdoutReader.BeginReadLine(); |
|
|
|
|
stderrReader.BeginReadLine(); |
|
|
|
|