mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-13 15:42:50 +08:00

* Add width to panels * Add height to panels * Replace RenderContext with RenderOptions * Remove exclusivity from alternative buffer * Add Layout widget * Add Align widget
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using System;
|
|
using System.Threading;
|
|
using Spectre.Console;
|
|
|
|
namespace Paths;
|
|
|
|
public static class Program
|
|
{
|
|
public static void Main()
|
|
{
|
|
var windowsPath = @"C:\This is\A\Super Long\Windows\Path\That\Goes\On And On\And\Never\Seems\To\Stop\But\At\Some\Point\It\Must\I\Guess.txt";
|
|
var unixPath = @"//This is/A/Super Long/Unix/Path/That/Goes/On And On/And/Never/Seems/To/Stop/But/At/Some/Point/It/Must/I/Guess.txt";
|
|
|
|
AnsiConsole.WriteLine();
|
|
WritePlain(windowsPath, unixPath);
|
|
|
|
AnsiConsole.WriteLine();
|
|
WriteColorized(windowsPath, unixPath);
|
|
|
|
AnsiConsole.WriteLine();
|
|
WriteAligned(windowsPath);
|
|
}
|
|
|
|
private static void WritePlain(string windowsPath, string unixPath)
|
|
{
|
|
var table = new Table().BorderColor(Color.Grey).Title("Plain").RoundedBorder();
|
|
table.AddColumns("[grey]OS[/]", "[grey]Path[/]");
|
|
table.AddRow(new Text("Windows"), new TextPath(windowsPath));
|
|
table.AddRow(new Text("Unix"), new TextPath(unixPath));
|
|
|
|
AnsiConsole.Write(table);
|
|
}
|
|
|
|
private static void WriteColorized(string windowsPath, string unixPath)
|
|
{
|
|
var table = new Table().BorderColor(Color.Grey).Title("Colorized").RoundedBorder();
|
|
table.AddColumns("[grey]OS[/]", "[grey]Path[/]");
|
|
|
|
table.AddRow(new Text("Windows"),
|
|
new TextPath(windowsPath)
|
|
.RootColor(Color.Blue)
|
|
.SeparatorColor(Color.Yellow)
|
|
.StemColor(Color.Red)
|
|
.LeafColor(Color.Green));
|
|
|
|
table.AddRow(new Text("Unix"),
|
|
new TextPath(unixPath)
|
|
.RootColor(Color.Blue)
|
|
.SeparatorColor(Color.Yellow)
|
|
.StemColor(Color.Red)
|
|
.LeafColor(Color.Green));
|
|
|
|
AnsiConsole.Write(table);
|
|
}
|
|
|
|
private static void WriteAligned(string path)
|
|
{
|
|
var table = new Table().BorderColor(Color.Grey).Title("Aligned").RoundedBorder();
|
|
table.AddColumns("[grey]Alignment[/]", "[grey]Path[/]");
|
|
|
|
table.AddRow(new Text("Left"), new TextPath(path).LeftJustified());
|
|
table.AddRow(new Text("Center"), new TextPath(path).Centered());
|
|
table.AddRow(new Text("Right"), new TextPath(path).RightJustified());
|
|
|
|
AnsiConsole.Write(table);
|
|
}
|
|
}
|