public AnsiConsoleRenderer(TextWriter @out, Capabilities capabilities, ILinkIdentityGenerator?linkHasher) { _out = @out ?? throw new ArgumentNullException(nameof(@out)); Capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities)); Encoding = _out.IsStandardOut() ? System.Console.OutputEncoding : Encoding.UTF8; _ansiBuilder = new AnsiBuilder(Capabilities, linkHasher); }
public AnsiBackend(TextWriter @out, Capabilities capabilities, ILinkIdentityGenerator?linkHasher) { _out = @out ?? throw new ArgumentNullException(nameof(@out)); Capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities)); Encoding = _out.IsStandardOut() ? System.Console.OutputEncoding : Encoding.UTF8; Pipeline = new RenderPipeline(); _ansiBuilder = new AnsiBuilder(Capabilities, linkHasher); _cursor = new AnsiCursor(this); _input = new ConsoleInput(); _lock = new object(); }
public void Write(string text) { if (string.IsNullOrEmpty(text)) { return; } var parts = text.NormalizeLineEndings().Split(new[] { '\n' }); foreach (var(_, _, last, part) in parts.Enumerate()) { if (!string.IsNullOrEmpty(part)) { _out.Write(AnsiBuilder.GetAnsi(_system, part, Decoration, Foreground, Background)); } if (!last) { _out.Write(Environment.NewLine); } } }