mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
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:
parent
256fcdd27f
commit
be45a0ff4e
@ -8,8 +8,8 @@ namespace Spectre.Console.Tests.Unit
|
||||
public partial class AnsiConsoleTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(false, "Hello[2JWorld")]
|
||||
[InlineData(true, "Hello[2J[0;0HWorld")]
|
||||
[InlineData(false, "Hello[2J[3JWorld")]
|
||||
[InlineData(true, "Hello[2J[3J[1;1HWorld")]
|
||||
public void Should_Clear_Screen(bool home, string expected)
|
||||
{
|
||||
// Given
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user