-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example showing the decorations off (#1191)
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ExampleTitle>Decorations</ExampleTitle> | ||
<ExampleDescription>Demonstrates how to [italic]use[/] [bold]decorations[/] [dim]in[/] the console.</ExampleDescription> | ||
<ExampleGroup>Misc</ExampleGroup> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Shared\Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Spectre.Console; | ||
|
||
namespace Colors; | ||
|
||
public static class Program | ||
{ | ||
public static void Main() | ||
{ | ||
AnsiConsole.ResetDecoration(); | ||
AnsiConsole.WriteLine(); | ||
|
||
if (AnsiConsole.Profile.Capabilities.Ansi) | ||
{ | ||
AnsiConsole.Write(new Rule("[bold green]ANSI Decorations[/]")); | ||
} | ||
else | ||
{ | ||
AnsiConsole.Write(new Rule("[bold red]Legacy Decorations (unsupported)[/]")); | ||
} | ||
|
||
var decorations = System.Enum.GetValues(typeof(Decoration)); | ||
foreach (var decoration in decorations) | ||
{ | ||
var name = System.Enum.GetName(typeof(Decoration),decoration); | ||
AnsiConsole.Write(name + ": "); | ||
AnsiConsole.Write(new Markup(name+"\n", new Style(decoration: (Decoration)decoration))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters