Fix AnsiConsoleBackend.Clear

1. Add an ED3 command to clear the scroll buffer.

This command is not in the original ANSI terminal control sequences but
was added later to XTerm to account for the fact that most modern
terminals have a scroll-buffer.

https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-J.1C8A

This command is now awailable in basically
all terminals with scroll-buffers

2. Change CUP coordinates to 1, 1

The coordinates 0, 0 also worked, but strictly speaking they are outside
the available screen area and are capped to 1, 1 anyways.

This commit fixes #337
This commit is contained in:
Christian Wischenbart 2021-04-04 21:58:11 +02:00 committed by Patrik Svensson
parent 256fcdd27f
commit be45a0ff4e
2 changed files with 4 additions and 3 deletions

View File

@ -8,8 +8,8 @@ namespace Spectre.Console.Tests.Unit
public partial class AnsiConsoleTests
{
[Theory]
[InlineData(false, "HelloWorld")]
[InlineData(true, "HelloWorld")]
[InlineData(false, "HelloWorld")]
[InlineData(true, "HelloWorld")]
public void Should_Clear_Screen(bool home, string expected)
{
// Given

View File

@ -23,10 +23,11 @@ namespace Spectre.Console
public void Clear(bool home)
{
Write(new ControlSequence(ED(2)));
Write(new ControlSequence(ED(3)));
if (home)
{
Write(new ControlSequence(CUP(0, 0)));
Write(new ControlSequence(CUP(1, 1)));
}
}