mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-08-02 18:17:30 +08:00
Add rule widget
Adds a new rule widget. Also fixes some bugs I encountered while testing some unrelated things in an extremely small console.
This commit is contained in:

committed by
Patrik Svensson

parent
1410cba6c5
commit
5a1b8a1710
28
examples/Rules/Program.cs
Normal file
28
examples/Rules/Program.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Spectre.Console;
|
||||
|
||||
namespace EmojiExample
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// No title
|
||||
Render(new Rule().SetStyle("yellow"));
|
||||
|
||||
// Left aligned title
|
||||
Render(new Rule("[white]Left aligned[/]").LeftAligned().SetStyle("red"));
|
||||
|
||||
// Centered title
|
||||
Render(new Rule("[silver]Centered[/]").Centered().SetStyle("green"));
|
||||
|
||||
// Right aligned title
|
||||
Render(new Rule("[grey]Right aligned[/]").RightAligned().SetStyle("blue"));
|
||||
}
|
||||
|
||||
private static void Render(Rule rule)
|
||||
{
|
||||
AnsiConsole.Render(new Panel(rule).Expand().SetBorderStyle(Style.Parse("grey")));
|
||||
AnsiConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
15
examples/Rules/Rules.csproj
Normal file
15
examples/Rules/Rules.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Title>Rules</Title>
|
||||
<Description>Demonstrates how to render horizontal rules (lines).</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Spectre.Console\Spectre.Console.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user