mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-08-03 20:45:34 +08:00

committed by
Phil Scott

parent
2e5d18fa78
commit
fd4b96944e
26
examples/Console/AlternateScreen/Program.cs
Normal file
26
examples/Console/AlternateScreen/Program.cs
Normal 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);
|
||||
});
|
Reference in New Issue
Block a user