Add support for alternate screen buffers

Closes #250
This commit is contained in:
Patrik Svensson
2021-11-30 13:15:17 +01:00
committed by Phil Scott
parent 2e5d18fa78
commit fd4b96944e
17 changed files with 245 additions and 11 deletions

View File

@ -0,0 +1,26 @@
// Check if we can use alternate screen buffers
using Spectre.Console;
if (!AnsiConsole.Profile.Capabilities.AlternateBuffer)
{
AnsiConsole.MarkupLine(
"[red]Alternate screen buffers are not supported " +
"by your terminal[/] [yellow]:([/]");
return;
}
// Write to the terminal
AnsiConsole.Write(new Rule("[yellow]Normal universe[/]"));
AnsiConsole.Write(new Panel("Hello World!"));
AnsiConsole.MarkupLine("[grey]Press a key to continue[/]");
AnsiConsole.Console.Input.ReadKey(true);
AnsiConsole.AlternateScreen(() =>
{
// Now we're in another terminal screen buffer
AnsiConsole.Write(new Rule("[red]Mirror universe[/]"));
AnsiConsole.Write(new Panel("[red]Welcome to the upside down![/]"));
AnsiConsole.MarkupLine("[grey]Press a key to return[/]");
AnsiConsole.Console.Input.ReadKey(true);
});