Patrik Svensson 3463dde543 Add method to write VT/ANSI control codes
Adds a new extension method IAnsiConsole.WriteAnsi that writes
VT/ANSI control codes to the console. If VT/ANSI control codes are
not supported, nothing will be written.
2021-04-22 22:16:10 -04:00

29 lines
674 B
C#

using System.Collections.Generic;
using Spectre.Console.Rendering;
namespace Spectre.Console
{
internal sealed class ControlCode : Renderable
{
private readonly Segment _segment;
public ControlCode(string control)
{
_segment = Segment.Control(control);
}
protected override Measurement Measure(RenderContext context, int maxWidth)
{
return new Measurement(0, 0);
}
protected override IEnumerable<Segment> Render(RenderContext context, int maxWidth)
{
if (context.Ansi)
{
yield return _segment;
}
}
}
}