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.
This commit is contained in:
Patrik Svensson
2021-04-22 22:11:21 +02:00
committed by Phil Scott
parent 91f910326c
commit 3463dde543
14 changed files with 212 additions and 101 deletions

View File

@ -25,11 +25,11 @@ namespace Spectre.Console.Rendering
{
if (_shape == null)
{
return new ControlSequence(string.Empty);
return new ControlCode(string.Empty);
}
var linesToMoveUp = _shape.Value.Height - 1;
return new ControlSequence("\r" + CUU(linesToMoveUp));
return new ControlCode("\r" + CUU(linesToMoveUp));
}
}
@ -39,11 +39,11 @@ namespace Spectre.Console.Rendering
{
if (_shape == null)
{
return new ControlSequence(string.Empty);
return new ControlCode(string.Empty);
}
var linesToClear = _shape.Value.Height - 1;
return new ControlSequence("\r" + EL(2) + (CUU(1) + EL(2)).Repeat(linesToClear));
return new ControlCode("\r" + EL(2) + (CUU(1) + EL(2)).Repeat(linesToClear));
}
}

View File

@ -14,6 +14,11 @@ namespace Spectre.Console.Rendering
/// </summary>
public ColorSystem ColorSystem => _capabilities.ColorSystem;
/// <summary>
/// Gets a value indicating whether or not VT/Ansi codes are supported.
/// </summary>
public bool Ansi => _capabilities.Ansi;
/// <summary>
/// Gets a value indicating whether or not unicode is supported.
/// </summary>