mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
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:

committed by
Phil Scott

parent
91f910326c
commit
3463dde543
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user