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
@ -22,12 +22,12 @@ namespace Spectre.Console
|
||||
|
||||
public void Clear(bool home)
|
||||
{
|
||||
Write(new ControlSequence(ED(2)));
|
||||
Write(new ControlSequence(ED(3)));
|
||||
Write(new ControlCode(ED(2)));
|
||||
Write(new ControlCode(ED(3)));
|
||||
|
||||
if (home)
|
||||
{
|
||||
Write(new ControlSequence(CUP(1, 1)));
|
||||
Write(new ControlCode(CUP(1, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,11 @@ namespace Spectre.Console
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
_backend.Write(new ControlSequence(SM(DECTCEM)));
|
||||
_backend.Write(new ControlCode(SM(DECTCEM)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_backend.Write(new ControlSequence(RM(DECTCEM)));
|
||||
_backend.Write(new ControlCode(RM(DECTCEM)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,23 +34,23 @@ namespace Spectre.Console
|
||||
switch (direction)
|
||||
{
|
||||
case CursorDirection.Up:
|
||||
_backend.Write(new ControlSequence(CUU(steps)));
|
||||
_backend.Write(new ControlCode(CUU(steps)));
|
||||
break;
|
||||
case CursorDirection.Down:
|
||||
_backend.Write(new ControlSequence(CUD(steps)));
|
||||
_backend.Write(new ControlCode(CUD(steps)));
|
||||
break;
|
||||
case CursorDirection.Right:
|
||||
_backend.Write(new ControlSequence(CUF(steps)));
|
||||
_backend.Write(new ControlCode(CUF(steps)));
|
||||
break;
|
||||
case CursorDirection.Left:
|
||||
_backend.Write(new ControlSequence(CUB(steps)));
|
||||
_backend.Write(new ControlCode(CUB(steps)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPosition(int column, int line)
|
||||
{
|
||||
_backend.Write(new ControlSequence(CUP(line, column)));
|
||||
_backend.Write(new ControlCode(CUP(line, column)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user