From 2af3f7faeb0f5b89e48670af1b15619b3693388f Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Sat, 16 Sep 2023 22:08:52 +0100 Subject: [PATCH] Add an example showing the decorations off (#1191) --- .../Console/Decorations/Decorations.csproj | 15 ++++++++++ examples/Console/Decorations/Program.cs | 29 +++++++++++++++++++ examples/Examples.sln | 14 +++++++++ 3 files changed, 58 insertions(+) create mode 100644 examples/Console/Decorations/Decorations.csproj create mode 100644 examples/Console/Decorations/Program.cs diff --git a/examples/Console/Decorations/Decorations.csproj b/examples/Console/Decorations/Decorations.csproj new file mode 100644 index 0000000..ea1e26c --- /dev/null +++ b/examples/Console/Decorations/Decorations.csproj @@ -0,0 +1,15 @@ + + + + Exe + net7.0 + Decorations + Demonstrates how to [italic]use[/] [bold]decorations[/] [dim]in[/] the console. + Misc + + + + + + + diff --git a/examples/Console/Decorations/Program.cs b/examples/Console/Decorations/Program.cs new file mode 100644 index 0000000..e689df5 --- /dev/null +++ b/examples/Console/Decorations/Program.cs @@ -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))); + } + } +} diff --git a/examples/Examples.sln b/examples/Examples.sln index adba5e9..3166466 100644 --- a/examples/Examples.sln +++ b/examples/Examples.sln @@ -85,6 +85,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spectre.Console.Json", "..\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Help", "Cli\Help\Help.csproj", "{BAB490D6-FF8D-462B-B2B0-933384D629DB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decorations", "Console\Decorations\Decorations.csproj", "{FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -563,6 +565,18 @@ Global {BAB490D6-FF8D-462B-B2B0-933384D629DB}.Release|x64.Build.0 = Release|Any CPU {BAB490D6-FF8D-462B-B2B0-933384D629DB}.Release|x86.ActiveCfg = Release|Any CPU {BAB490D6-FF8D-462B-B2B0-933384D629DB}.Release|x86.Build.0 = Release|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Debug|x64.ActiveCfg = Debug|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Debug|x64.Build.0 = Debug|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Debug|x86.ActiveCfg = Debug|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Debug|x86.Build.0 = Debug|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Release|Any CPU.Build.0 = Release|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Release|x64.ActiveCfg = Release|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Release|x64.Build.0 = Release|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Release|x86.ActiveCfg = Release|Any CPU + {FC5852F1-E01F-4DF7-9B49-CA19A9EE670F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE