public override void VisitBackgroundColorSpan(BackgroundColorSpan span) { if (span.RgbColor == null && _backgroundColorMappings.TryGetValue(span.Name, out var color)) { Terminal.BackgroundColor = color; } else { var foregroundColor = Terminal.ForegroundColor; Terminal.ResetColor(); Terminal.ForegroundColor = foregroundColor; } }
public override void VisitBackgroundColorSpan(BackgroundColorSpan span) { AnsiControlCode controlCode; if (span.RgbColor is RgbColor rgb) { controlCode = Color.Background.Rgb(rgb.Red, rgb.Green, rgb.Blue); } else if (!_backgroundColorControlCodeMappings.TryGetValue(span.Name, out controlCode)) { return; } Writer.Write(controlCode.EscapeSequence); }
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); }