Don't limit tables and grids to markup text

Closes #13
This commit is contained in:
Patrik Svensson
2020-08-24 23:24:23 +02:00
committed by Patrik Svensson
parent effdecb1d4
commit 8a01b93aca
41 changed files with 472 additions and 193 deletions

View File

@ -1,4 +1,3 @@
using System;
using Spectre.Console;
namespace GridExample

View File

@ -1,4 +1,3 @@
using System;
using Spectre.Console;
namespace PanelExample

View File

@ -1,4 +1,3 @@
using System;
using Spectre.Console;
namespace TableExample
@ -12,6 +11,42 @@ namespace TableExample
// A big table
RenderBigTable();
// A complex table
RenderComplexTable();
}
private static void RenderComplexTable()
{
// Create simple table.
var simple = new Table { Border = BorderKind.Rounded };
simple.AddColumn(new TableColumn("[u]Foo[/]").Centered());
simple.AddColumn(new TableColumn("[u]Bar[/]"));
simple.AddColumn(new TableColumn("[u]Baz[/]"));
simple.AddRow("Hello", "[red]World![/]", "");
simple.AddRow("[blue]Bounjour[/]", "[white]le[/]", "[red]monde![/]");
simple.AddRow("[blue]Hej[/]", "[yellow]Världen![/]", "");
// Create other table.
var second = new Table { Border = BorderKind.Square };
second.AddColumn(new TableColumn("[u]Foo[/]"));
second.AddColumn(new TableColumn("[u]Bar[/]"));
second.AddColumn(new TableColumn("[u]Baz[/]"));
second.AddRow("Hello", "[red]World![/]", "");
second.AddRow(simple, new Text("Whaaat"), new Text("Lolz"));
second.AddRow("[blue]Hej[/]", "[yellow]Världen![/]", "");
var table = new Table { Border = BorderKind.Rounded };
table.AddColumn(new TableColumn(new Panel("[u]Foo[/]")));
table.AddColumn(new TableColumn(new Panel("[u]Bar[/]")));
table.AddColumn(new TableColumn(new Panel("[u]Baz[/]")));
// Add some rows
table.AddRow(new Text("Hello").Centered(), new Markup("[red]World![/] 🌍"), Text.Empty);
table.AddRow(second, new Text("Whaaat"), new Text("Lol"));
table.AddRow(new Markup("[blue]Hej[/]").Centered(), new Markup("[yellow]Världen![/]"), Text.Empty);
AnsiConsole.Render(table);
}
private static void RenderSimpleTable()