public void RenderToRegion( Span span, Region region) { SpanVisitor visitor; if (span == null) { span = Span.Empty(); } else if (_resetAfterRender) { span = new ContainerSpan( span, ForegroundColorSpan.Reset(), BackgroundColorSpan.Reset()); } switch (Mode) { case OutputMode.NonAnsi: visitor = new NonAnsiRenderingSpanVisitor( _terminal, region); break; case OutputMode.Ansi: visitor = new AnsiRenderingSpanVisitor( _console, region); break; case OutputMode.File: visitor = new FileRenderingSpanVisitor( _console.Out, new Region(region.Left, region.Top, region.Width, region.Height, false)); break; default: throw new NotSupportedException(); } visitor.Visit(span); }