mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-19 02:12:49 +08:00

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.
29 lines
674 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|