mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-24 04:02:50 +08:00
Add support for table footers
This commit is contained in:
parent
c9c0ad733f
commit
03334f693d
@ -48,8 +48,8 @@ namespace BordersExample
|
|||||||
static IRenderable CreateTable(string name, TableBorder border)
|
static IRenderable CreateTable(string name, TableBorder border)
|
||||||
{
|
{
|
||||||
var table = new Table().Border(border);
|
var table = new Table().Border(border);
|
||||||
table.AddColumn("[yellow]Header 1[/]");
|
table.AddColumn("[yellow]Header 1[/]", c => c.Footer("[grey]Footer 1[/]"));
|
||||||
table.AddColumn("[yellow]Header 2[/]", col => col.RightAligned());
|
table.AddColumn("[yellow]Header 2[/]", col => col.Footer("[grey]Footer 2[/]").RightAligned());
|
||||||
table.AddRow("Cell", "Cell");
|
table.AddRow("Cell", "Cell");
|
||||||
table.AddRow("Cell", "Cell");
|
table.AddRow("Cell", "Cell");
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ namespace TableExample
|
|||||||
var simple = new Table()
|
var simple = new Table()
|
||||||
.Border(TableBorder.Square)
|
.Border(TableBorder.Square)
|
||||||
.BorderColor(Color.Red)
|
.BorderColor(Color.Red)
|
||||||
.AddColumn(new TableColumn("[u]CDE[/]").Centered())
|
.AddColumn(new TableColumn("[u]CDE[/]").Footer("EDC").Centered())
|
||||||
.AddColumn(new TableColumn("[u]FED[/]"))
|
.AddColumn(new TableColumn("[u]FED[/]").Footer("DEF"))
|
||||||
.AddColumn(new TableColumn("[u]IHG[/]"))
|
.AddColumn(new TableColumn("[u]IHG[/]").Footer("GHI"))
|
||||||
.AddRow("Hello", "[red]World![/]", "")
|
.AddRow("Hello", "[red]World![/]", "")
|
||||||
.AddRow("[blue]Bonjour[/]", "[white]le[/]", "[red]monde![/]")
|
.AddRow("[blue]Bonjour[/]", "[white]le[/]", "[red]monde![/]")
|
||||||
.AddRow("[blue]Hej[/]", "[yellow]Världen![/]", "");
|
.AddRow("[blue]Hej[/]", "[yellow]Världen![/]", "");
|
||||||
@ -38,11 +38,11 @@ namespace TableExample
|
|||||||
return new Table()
|
return new Table()
|
||||||
.Centered()
|
.Centered()
|
||||||
.Border(TableBorder.DoubleEdge)
|
.Border(TableBorder.DoubleEdge)
|
||||||
.Heading("TABLE [yellow]HEADING[/]")
|
.Title("TABLE [yellow]TITLE[/]")
|
||||||
.Footnote("TABLE [yellow]FOOTNOTE[/]")
|
.Caption("TABLE [yellow]CAPTION[/]")
|
||||||
.AddColumn(new TableColumn(new Panel("[u]ABC[/]").BorderColor(Color.Red)))
|
.AddColumn(new TableColumn(new Panel("[u]ABC[/]").BorderColor(Color.Red)).Footer("[u]FOOTER 1[/]"))
|
||||||
.AddColumn(new TableColumn(new Panel("[u]DEF[/]").BorderColor(Color.Green)))
|
.AddColumn(new TableColumn(new Panel("[u]DEF[/]").BorderColor(Color.Green)).Footer("[u]FOOTER 2[/]"))
|
||||||
.AddColumn(new TableColumn(new Panel("[u]GHI[/]").BorderColor(Color.Blue)))
|
.AddColumn(new TableColumn(new Panel("[u]GHI[/]").BorderColor(Color.Blue)).Footer("[u]FOOTER 3[/]"))
|
||||||
.AddRow(new Text("Hello").Centered(), new Markup("[red]World![/]"), Text.Empty)
|
.AddRow(new Text("Hello").Centered(), new Markup("[red]World![/]"), Text.Empty)
|
||||||
.AddRow(second, new Text("Whaaat"), new Text("Lol"))
|
.AddRow(second, new Text("Whaaat"), new Text("Lol"))
|
||||||
.AddRow(new Markup("[blue]Hej[/]").Centered(), new Markup("[yellow]Världen![/]"), Text.Empty);
|
.AddRow(new Markup("[blue]Hej[/]").Centered(), new Markup("[yellow]Världen![/]"), Text.Empty);
|
||||||
|
@ -42,10 +42,11 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(3);
|
console.Lines.Count.ShouldBe(4);
|
||||||
console.Lines[0].ShouldBe("Header 1 Header 2");
|
console.Lines[0].ShouldBe("Header 1 Header 2");
|
||||||
console.Lines[1].ShouldBe("Cell Cell ");
|
console.Lines[1].ShouldBe("Cell Cell ");
|
||||||
console.Lines[2].ShouldBe("Cell Cell ");
|
console.Lines[2].ShouldBe("Cell Cell ");
|
||||||
|
console.Lines[3].ShouldBe("Footer 1 Footer 2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,13 +86,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("+---------------------+");
|
console.Lines[0].ShouldBe("+---------------------+");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("|----------+----------|");
|
console.Lines[2].ShouldBe("|----------+----------|");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe("+---------------------+");
|
console.Lines[5].ShouldBe("|----------+----------|");
|
||||||
|
console.Lines[6].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[7].ShouldBe("+---------------------+");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,13 +134,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("+----------+----------+");
|
console.Lines[0].ShouldBe("+----------+----------+");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("|----------+----------|");
|
console.Lines[2].ShouldBe("|----------+----------|");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe("+----------+----------+");
|
console.Lines[5].ShouldBe("|----------+----------|");
|
||||||
|
console.Lines[6].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[7].ShouldBe("+----------+----------+");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,13 +182,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("+----------+----------+");
|
console.Lines[0].ShouldBe("+----------+----------+");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("|==========+==========|");
|
console.Lines[2].ShouldBe("|==========+==========|");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe("+----------+----------+");
|
console.Lines[5].ShouldBe("+----------+----------+");
|
||||||
|
console.Lines[6].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[7].ShouldBe("+----------+----------+");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,13 +230,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("┌──────────┬──────────┐");
|
console.Lines[0].ShouldBe("┌──────────┬──────────┐");
|
||||||
console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │");
|
console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │");
|
||||||
console.Lines[2].ShouldBe("├──────────┼──────────┤");
|
console.Lines[2].ShouldBe("├──────────┼──────────┤");
|
||||||
console.Lines[3].ShouldBe("│ Cell │ Cell │");
|
console.Lines[3].ShouldBe("│ Cell │ Cell │");
|
||||||
console.Lines[4].ShouldBe("│ Cell │ Cell │");
|
console.Lines[4].ShouldBe("│ Cell │ Cell │");
|
||||||
console.Lines[5].ShouldBe("└──────────┴──────────┘");
|
console.Lines[5].ShouldBe("├──────────┼──────────┤");
|
||||||
|
console.Lines[6].ShouldBe("│ Footer 1 │ Footer 2 │");
|
||||||
|
console.Lines[7].ShouldBe("└──────────┴──────────┘");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,13 +278,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("╭──────────┬──────────╮");
|
console.Lines[0].ShouldBe("╭──────────┬──────────╮");
|
||||||
console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │");
|
console.Lines[1].ShouldBe("│ Header 1 │ Header 2 │");
|
||||||
console.Lines[2].ShouldBe("├──────────┼──────────┤");
|
console.Lines[2].ShouldBe("├──────────┼──────────┤");
|
||||||
console.Lines[3].ShouldBe("│ Cell │ Cell │");
|
console.Lines[3].ShouldBe("│ Cell │ Cell │");
|
||||||
console.Lines[4].ShouldBe("│ Cell │ Cell │");
|
console.Lines[4].ShouldBe("│ Cell │ Cell │");
|
||||||
console.Lines[5].ShouldBe("╰──────────┴──────────╯");
|
console.Lines[5].ShouldBe("├──────────┼──────────┤");
|
||||||
|
console.Lines[6].ShouldBe("│ Footer 1 │ Footer 2 │");
|
||||||
|
console.Lines[7].ShouldBe("╰──────────┴──────────╯");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,13 +326,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe(" Header 1 │ Header 2 ");
|
console.Lines[1].ShouldBe(" Header 1 │ Header 2 ");
|
||||||
console.Lines[2].ShouldBe(" ──────────┼────────── ");
|
console.Lines[2].ShouldBe(" ──────────┼────────── ");
|
||||||
console.Lines[3].ShouldBe(" Cell │ Cell ");
|
console.Lines[3].ShouldBe(" Cell │ Cell ");
|
||||||
console.Lines[4].ShouldBe(" Cell │ Cell ");
|
console.Lines[4].ShouldBe(" Cell │ Cell ");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe(" ──────────┼────────── ");
|
||||||
|
console.Lines[6].ShouldBe(" Footer 1 │ Footer 2 ");
|
||||||
|
console.Lines[7].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,13 +374,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe(" Header 1 │ Header 2 ");
|
console.Lines[1].ShouldBe(" Header 1 │ Header 2 ");
|
||||||
console.Lines[2].ShouldBe(" ━━━━━━━━━━┿━━━━━━━━━━ ");
|
console.Lines[2].ShouldBe(" ━━━━━━━━━━┿━━━━━━━━━━ ");
|
||||||
console.Lines[3].ShouldBe(" Cell │ Cell ");
|
console.Lines[3].ShouldBe(" Cell │ Cell ");
|
||||||
console.Lines[4].ShouldBe(" Cell │ Cell ");
|
console.Lines[4].ShouldBe(" Cell │ Cell ");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe(" ━━━━━━━━━━┿━━━━━━━━━━ ");
|
||||||
|
console.Lines[6].ShouldBe(" Footer 1 │ Footer 2 ");
|
||||||
|
console.Lines[7].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,13 +422,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe(" Header 1 │ Header 2 ");
|
console.Lines[1].ShouldBe(" Header 1 │ Header 2 ");
|
||||||
console.Lines[2].ShouldBe(" ══════════╪══════════ ");
|
console.Lines[2].ShouldBe(" ══════════╪══════════ ");
|
||||||
console.Lines[3].ShouldBe(" Cell │ Cell ");
|
console.Lines[3].ShouldBe(" Cell │ Cell ");
|
||||||
console.Lines[4].ShouldBe(" Cell │ Cell ");
|
console.Lines[4].ShouldBe(" Cell │ Cell ");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe(" ══════════╪══════════ ");
|
||||||
|
console.Lines[6].ShouldBe(" Footer 1 │ Footer 2 ");
|
||||||
|
console.Lines[7].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,13 +470,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe(" Header 1 Header 2 ");
|
console.Lines[1].ShouldBe(" Header 1 Header 2 ");
|
||||||
console.Lines[2].ShouldBe("───────────────────────");
|
console.Lines[2].ShouldBe("───────────────────────");
|
||||||
console.Lines[3].ShouldBe(" Cell Cell ");
|
console.Lines[3].ShouldBe(" Cell Cell ");
|
||||||
console.Lines[4].ShouldBe(" Cell Cell ");
|
console.Lines[4].ShouldBe(" Cell Cell ");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe("───────────────────────");
|
||||||
|
console.Lines[6].ShouldBe(" Footer 1 Footer 2 ");
|
||||||
|
console.Lines[7].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,13 +518,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("───────────────────────");
|
console.Lines[0].ShouldBe("───────────────────────");
|
||||||
console.Lines[1].ShouldBe(" Header 1 Header 2 ");
|
console.Lines[1].ShouldBe(" Header 1 Header 2 ");
|
||||||
console.Lines[2].ShouldBe("───────────────────────");
|
console.Lines[2].ShouldBe("───────────────────────");
|
||||||
console.Lines[3].ShouldBe(" Cell Cell ");
|
console.Lines[3].ShouldBe(" Cell Cell ");
|
||||||
console.Lines[4].ShouldBe(" Cell Cell ");
|
console.Lines[4].ShouldBe(" Cell Cell ");
|
||||||
console.Lines[5].ShouldBe("───────────────────────");
|
console.Lines[5].ShouldBe("───────────────────────");
|
||||||
|
console.Lines[6].ShouldBe(" Footer 1 Footer 2 ");
|
||||||
|
console.Lines[7].ShouldBe("───────────────────────");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,13 +566,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe(" Header 1 Header 2 ");
|
console.Lines[1].ShouldBe(" Header 1 Header 2 ");
|
||||||
console.Lines[2].ShouldBe("━━━━━━━━━━━━━━━━━━━━━━━");
|
console.Lines[2].ShouldBe("━━━━━━━━━━━━━━━━━━━━━━━");
|
||||||
console.Lines[3].ShouldBe(" Cell Cell ");
|
console.Lines[3].ShouldBe(" Cell Cell ");
|
||||||
console.Lines[4].ShouldBe(" Cell Cell ");
|
console.Lines[4].ShouldBe(" Cell Cell ");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe("━━━━━━━━━━━━━━━━━━━━━━━");
|
||||||
|
console.Lines[6].ShouldBe(" Footer 1 Footer 2 ");
|
||||||
|
console.Lines[7].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,13 +614,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓");
|
console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓");
|
||||||
console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃");
|
console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃");
|
||||||
console.Lines[2].ShouldBe("┣━━━━━━━━━━╋━━━━━━━━━━┫");
|
console.Lines[2].ShouldBe("┣━━━━━━━━━━╋━━━━━━━━━━┫");
|
||||||
console.Lines[3].ShouldBe("┃ Cell ┃ Cell ┃");
|
console.Lines[3].ShouldBe("┃ Cell ┃ Cell ┃");
|
||||||
console.Lines[4].ShouldBe("┃ Cell ┃ Cell ┃");
|
console.Lines[4].ShouldBe("┃ Cell ┃ Cell ┃");
|
||||||
console.Lines[5].ShouldBe("┗━━━━━━━━━━┻━━━━━━━━━━┛");
|
console.Lines[5].ShouldBe("┣━━━━━━━━━━╋━━━━━━━━━━┫");
|
||||||
|
console.Lines[6].ShouldBe("┃ Footer 1 ┃ Footer 2 ┃");
|
||||||
|
console.Lines[7].ShouldBe("┗━━━━━━━━━━┻━━━━━━━━━━┛");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,13 +662,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("┏━━━━━━━━━━┯━━━━━━━━━━┓");
|
console.Lines[0].ShouldBe("┏━━━━━━━━━━┯━━━━━━━━━━┓");
|
||||||
console.Lines[1].ShouldBe("┃ Header 1 │ Header 2 ┃");
|
console.Lines[1].ShouldBe("┃ Header 1 │ Header 2 ┃");
|
||||||
console.Lines[2].ShouldBe("┠──────────┼──────────┨");
|
console.Lines[2].ShouldBe("┠──────────┼──────────┨");
|
||||||
console.Lines[3].ShouldBe("┃ Cell │ Cell ┃");
|
console.Lines[3].ShouldBe("┃ Cell │ Cell ┃");
|
||||||
console.Lines[4].ShouldBe("┃ Cell │ Cell ┃");
|
console.Lines[4].ShouldBe("┃ Cell │ Cell ┃");
|
||||||
console.Lines[5].ShouldBe("┗━━━━━━━━━━┷━━━━━━━━━━┛");
|
console.Lines[5].ShouldBe("┠──────────┼──────────┨");
|
||||||
|
console.Lines[6].ShouldBe("┃ Footer 1 │ Footer 2 ┃");
|
||||||
|
console.Lines[7].ShouldBe("┗━━━━━━━━━━┷━━━━━━━━━━┛");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,13 +710,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓");
|
console.Lines[0].ShouldBe("┏━━━━━━━━━━┳━━━━━━━━━━┓");
|
||||||
console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃");
|
console.Lines[1].ShouldBe("┃ Header 1 ┃ Header 2 ┃");
|
||||||
console.Lines[2].ShouldBe("┡━━━━━━━━━━╇━━━━━━━━━━┩");
|
console.Lines[2].ShouldBe("┡━━━━━━━━━━╇━━━━━━━━━━┩");
|
||||||
console.Lines[3].ShouldBe("│ Cell │ Cell │");
|
console.Lines[3].ShouldBe("│ Cell │ Cell │");
|
||||||
console.Lines[4].ShouldBe("│ Cell │ Cell │");
|
console.Lines[4].ShouldBe("│ Cell │ Cell │");
|
||||||
console.Lines[5].ShouldBe("└──────────┴──────────┘");
|
console.Lines[5].ShouldBe("├──────────┼──────────┤");
|
||||||
|
console.Lines[6].ShouldBe("│ Footer 1 │ Footer 2 │");
|
||||||
|
console.Lines[7].ShouldBe("└──────────┴──────────┘");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,13 +758,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("╔══════════╦══════════╗");
|
console.Lines[0].ShouldBe("╔══════════╦══════════╗");
|
||||||
console.Lines[1].ShouldBe("║ Header 1 ║ Header 2 ║");
|
console.Lines[1].ShouldBe("║ Header 1 ║ Header 2 ║");
|
||||||
console.Lines[2].ShouldBe("╠══════════╬══════════╣");
|
console.Lines[2].ShouldBe("╠══════════╬══════════╣");
|
||||||
console.Lines[3].ShouldBe("║ Cell ║ Cell ║");
|
console.Lines[3].ShouldBe("║ Cell ║ Cell ║");
|
||||||
console.Lines[4].ShouldBe("║ Cell ║ Cell ║");
|
console.Lines[4].ShouldBe("║ Cell ║ Cell ║");
|
||||||
console.Lines[5].ShouldBe("╚══════════╩══════════╝");
|
console.Lines[5].ShouldBe("╠══════════╬══════════╣");
|
||||||
|
console.Lines[6].ShouldBe("║ Footer 1 ║ Footer 2 ║");
|
||||||
|
console.Lines[7].ShouldBe("╚══════════╩══════════╝");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -775,13 +806,15 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(8);
|
||||||
console.Lines[0].ShouldBe("╔══════════╤══════════╗");
|
console.Lines[0].ShouldBe("╔══════════╤══════════╗");
|
||||||
console.Lines[1].ShouldBe("║ Header 1 │ Header 2 ║");
|
console.Lines[1].ShouldBe("║ Header 1 │ Header 2 ║");
|
||||||
console.Lines[2].ShouldBe("╟──────────┼──────────╢");
|
console.Lines[2].ShouldBe("╟──────────┼──────────╢");
|
||||||
console.Lines[3].ShouldBe("║ Cell │ Cell ║");
|
console.Lines[3].ShouldBe("║ Cell │ Cell ║");
|
||||||
console.Lines[4].ShouldBe("║ Cell │ Cell ║");
|
console.Lines[4].ShouldBe("║ Cell │ Cell ║");
|
||||||
console.Lines[5].ShouldBe("╚══════════╧══════════╝");
|
console.Lines[5].ShouldBe("╟──────────┼──────────╢");
|
||||||
|
console.Lines[6].ShouldBe("║ Footer 1 │ Footer 2 ║");
|
||||||
|
console.Lines[7].ShouldBe("╚══════════╧══════════╝");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,13 +854,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(7);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("| -------- | -------- |");
|
console.Lines[2].ShouldBe("| -------- | -------- |");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[6].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -841,13 +875,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(7);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("| -------- | :------- |");
|
console.Lines[2].ShouldBe("| -------- | :------- |");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[6].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -861,13 +896,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(7);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("| -------- | :------: |");
|
console.Lines[2].ShouldBe("| -------- | :------: |");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[6].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -881,13 +917,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Render(table);
|
console.Render(table);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
console.Lines.Count.ShouldBe(6);
|
console.Lines.Count.ShouldBe(7);
|
||||||
console.Lines[0].ShouldBe(" ");
|
console.Lines[0].ShouldBe(" ");
|
||||||
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
console.Lines[1].ShouldBe("| Header 1 | Header 2 |");
|
||||||
console.Lines[2].ShouldBe("| -------- | -------: |");
|
console.Lines[2].ShouldBe("| -------- | -------: |");
|
||||||
console.Lines[3].ShouldBe("| Cell | Cell |");
|
console.Lines[3].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[4].ShouldBe("| Cell | Cell |");
|
console.Lines[4].ShouldBe("| Cell | Cell |");
|
||||||
console.Lines[5].ShouldBe(" ");
|
console.Lines[5].ShouldBe("| Footer 1 | Footer 2 |");
|
||||||
|
console.Lines[6].ShouldBe(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,8 +933,8 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
public static Table GetTable(Justify? header1 = null, Justify? header2 = null)
|
public static Table GetTable(Justify? header1 = null, Justify? header2 = null)
|
||||||
{
|
{
|
||||||
var table = new Table();
|
var table = new Table();
|
||||||
table.AddColumn("Header 1", c => c.Alignment = header1);
|
table.AddColumn("Header 1", c => c.Alignment(header1).Footer("Footer 1"));
|
||||||
table.AddColumn("Header 2", c => c.Alignment = header2);
|
table.AddColumn("Header 2", c => c.Alignment(header2).Footer("Footer 2"));
|
||||||
table.AddRow("Cell", "Cell");
|
table.AddRow("Cell", "Cell");
|
||||||
table.AddRow("Cell", "Cell");
|
table.AddRow("Cell", "Cell");
|
||||||
return table;
|
return table;
|
||||||
|
@ -168,6 +168,33 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
console.Lines[5].ShouldBe("└────────┴────────┴───────┘");
|
console.Lines[5].ShouldBe("└────────┴────────┴───────┘");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Should_Render_Table_With_Footers_Correctly()
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var console = new PlainConsole(width: 80);
|
||||||
|
var table = new Table();
|
||||||
|
table.AddColumn(new TableColumn("Foo").Footer("Oof").RightAligned());
|
||||||
|
table.AddColumn("Bar");
|
||||||
|
table.AddColumns(new TableColumn("Baz").Footer("Zab"));
|
||||||
|
table.AddRow("Qux", "Corgi", "Waldo");
|
||||||
|
table.AddRow("Grault", "Garply", "Fred");
|
||||||
|
|
||||||
|
// When
|
||||||
|
console.Render(table);
|
||||||
|
|
||||||
|
// Then
|
||||||
|
console.Lines.Count.ShouldBe(8);
|
||||||
|
console.Lines[0].ShouldBe("┌────────┬────────┬───────┐");
|
||||||
|
console.Lines[1].ShouldBe("│ Foo │ Bar │ Baz │");
|
||||||
|
console.Lines[2].ShouldBe("├────────┼────────┼───────┤");
|
||||||
|
console.Lines[3].ShouldBe("│ Qux │ Corgi │ Waldo │");
|
||||||
|
console.Lines[4].ShouldBe("│ Grault │ Garply │ Fred │");
|
||||||
|
console.Lines[5].ShouldBe("├────────┼────────┼───────┤");
|
||||||
|
console.Lines[6].ShouldBe("│ Oof │ │ Zab │");
|
||||||
|
console.Lines[7].ShouldBe("└────────┴────────┴───────┘");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Left_Align_Table_Correctly()
|
public void Should_Left_Align_Table_Correctly()
|
||||||
{
|
{
|
||||||
@ -460,13 +487,13 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Render_Table_With_Title_And_Footnote_Correctly()
|
public void Should_Render_Table_With_Title_And_Caption_Correctly()
|
||||||
{
|
{
|
||||||
// Given
|
// Given
|
||||||
var console = new PlainConsole(width: 80);
|
var console = new PlainConsole(width: 80);
|
||||||
var table = new Table { Border = TableBorder.Rounded };
|
var table = new Table { Border = TableBorder.Rounded };
|
||||||
table.Heading = new TableTitle("Hello World");
|
table.Title = new TableTitle("Hello World");
|
||||||
table.Footnote = new TableTitle("Goodbye World");
|
table.Caption = new TableTitle("Goodbye World");
|
||||||
table.AddColumns("Foo", "Bar", "Baz");
|
table.AddColumns("Foo", "Bar", "Baz");
|
||||||
table.AddRow("Qux", "Corgi", "Waldo");
|
table.AddRow("Qux", "Corgi", "Waldo");
|
||||||
table.AddRow("Grault", "Garply", "Fred");
|
table.AddRow("Grault", "Garply", "Fred");
|
||||||
@ -487,14 +514,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Left_Align_Table_With_Title_And_Footnote_Correctly()
|
public void Should_Left_Align_Table_With_Title_And_Caption_Correctly()
|
||||||
{
|
{
|
||||||
// Given
|
// Given
|
||||||
var console = new PlainConsole(width: 80);
|
var console = new PlainConsole(width: 80);
|
||||||
var table = new Table { Border = TableBorder.Rounded };
|
var table = new Table { Border = TableBorder.Rounded };
|
||||||
table.LeftAligned();
|
table.LeftAligned();
|
||||||
table.Heading = new TableTitle("Hello World");
|
table.Title = new TableTitle("Hello World");
|
||||||
table.Footnote = new TableTitle("Goodbye World");
|
table.Caption = new TableTitle("Goodbye World");
|
||||||
table.AddColumns("Foo", "Bar", "Baz");
|
table.AddColumns("Foo", "Bar", "Baz");
|
||||||
table.AddRow("Qux", "Corgi", "Waldo");
|
table.AddRow("Qux", "Corgi", "Waldo");
|
||||||
table.AddRow("Grault", "Garply", "Fred");
|
table.AddRow("Grault", "Garply", "Fred");
|
||||||
@ -515,14 +542,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Center_Table_With_Title_And_Footnote_Correctly()
|
public void Should_Center_Table_With_Title_And_Caption_Correctly()
|
||||||
{
|
{
|
||||||
// Given
|
// Given
|
||||||
var console = new PlainConsole(width: 80);
|
var console = new PlainConsole(width: 80);
|
||||||
var table = new Table { Border = TableBorder.Rounded };
|
var table = new Table { Border = TableBorder.Rounded };
|
||||||
table.Centered();
|
table.Centered();
|
||||||
table.Heading = new TableTitle("Hello World");
|
table.Title = new TableTitle("Hello World");
|
||||||
table.Footnote = new TableTitle("Goodbye World");
|
table.Caption = new TableTitle("Goodbye World");
|
||||||
table.AddColumns("Foo", "Bar", "Baz");
|
table.AddColumns("Foo", "Bar", "Baz");
|
||||||
table.AddRow("Qux", "Corgi", "Waldo");
|
table.AddRow("Qux", "Corgi", "Waldo");
|
||||||
table.AddRow("Grault", "Garply", "Fred");
|
table.AddRow("Grault", "Garply", "Fred");
|
||||||
@ -543,14 +570,14 @@ namespace Spectre.Console.Tests.Unit
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Should_Right_Align_Table_With_Title_And_Footnote_Correctly()
|
public void Should_Right_Align_Table_With_Title_And_Caption_Correctly()
|
||||||
{
|
{
|
||||||
// Given
|
// Given
|
||||||
var console = new PlainConsole(width: 80);
|
var console = new PlainConsole(width: 80);
|
||||||
var table = new Table { Border = TableBorder.Rounded };
|
var table = new Table { Border = TableBorder.Rounded };
|
||||||
table.RightAligned();
|
table.RightAligned();
|
||||||
table.Heading = new TableTitle("Hello World");
|
table.Title = new TableTitle("Hello World");
|
||||||
table.Footnote = new TableTitle("Goodbye World");
|
table.Caption = new TableTitle("Goodbye World");
|
||||||
table.AddColumns("Foo", "Bar", "Baz");
|
table.AddColumns("Foo", "Bar", "Baz");
|
||||||
table.AddRow("Qux", "Corgi", "Waldo");
|
table.AddRow("Qux", "Corgi", "Waldo");
|
||||||
table.AddRow("Grault", "Garply", "Fred");
|
table.AddRow("Grault", "Garply", "Fred");
|
||||||
|
@ -12,7 +12,7 @@ namespace Spectre.Console
|
|||||||
/// <param name="obj">The alignable object.</param>
|
/// <param name="obj">The alignable object.</param>
|
||||||
/// <param name="alignment">The alignment.</param>
|
/// <param name="alignment">The alignment.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
public static T Alignment<T>(this T obj, Justify alignment)
|
public static T Alignment<T>(this T obj, Justify? alignment)
|
||||||
where T : class, IAlignable
|
where T : class, IAlignable
|
||||||
{
|
{
|
||||||
if (obj is null)
|
if (obj is null)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.ComponentModel;
|
||||||
using Spectre.Console.Internal;
|
|
||||||
using Spectre.Console.Rendering;
|
|
||||||
|
|
||||||
namespace Spectre.Console
|
namespace Spectre.Console
|
||||||
{
|
{
|
||||||
@ -17,6 +15,7 @@ namespace Spectre.Console
|
|||||||
/// <param name="width">The width.</param>
|
/// <param name="width">The width.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
[Obsolete("Use Width(..) instead.")]
|
[Obsolete("Use Width(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public static Table SetWidth(this Table table, int width)
|
public static Table SetWidth(this Table table, int width)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
@ -36,6 +35,7 @@ namespace Spectre.Console
|
|||||||
/// <param name="style">The style.</param>
|
/// <param name="style">The style.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
[Obsolete("Use Heading(..) instead.")]
|
[Obsolete("Use Heading(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public static Table SetHeading(this Table table, string text, Style? style = null)
|
public static Table SetHeading(this Table table, string text, Style? style = null)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
@ -58,6 +58,7 @@ namespace Spectre.Console
|
|||||||
/// <param name="heading">The heading.</param>
|
/// <param name="heading">The heading.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
[Obsolete("Use Heading(..) instead.")]
|
[Obsolete("Use Heading(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public static Table SetHeading(this Table table, TableTitle heading)
|
public static Table SetHeading(this Table table, TableTitle heading)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
@ -65,7 +66,7 @@ namespace Spectre.Console
|
|||||||
throw new ArgumentNullException(nameof(table));
|
throw new ArgumentNullException(nameof(table));
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Heading = heading;
|
table.Title = heading;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,8 @@ namespace Spectre.Console
|
|||||||
/// <param name="text">The footnote.</param>
|
/// <param name="text">The footnote.</param>
|
||||||
/// <param name="style">The style.</param>
|
/// <param name="style">The style.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
[Obsolete("Use Footnote(..) instead.")]
|
[Obsolete("Use Caption(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public static Table SetFootnote(this Table table, string text, Style? style = null)
|
public static Table SetFootnote(this Table table, string text, Style? style = null)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
@ -98,7 +100,8 @@ namespace Spectre.Console
|
|||||||
/// <param name="table">The table.</param>
|
/// <param name="table">The table.</param>
|
||||||
/// <param name="footnote">The footnote.</param>
|
/// <param name="footnote">The footnote.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
[Obsolete("Use Footnote(..) instead.")]
|
[Obsolete("Use Caption(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public static Table SetFootnote(this Table table, TableTitle footnote)
|
public static Table SetFootnote(this Table table, TableTitle footnote)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
@ -106,7 +109,93 @@ namespace Spectre.Console
|
|||||||
throw new ArgumentNullException(nameof(table));
|
throw new ArgumentNullException(nameof(table));
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Footnote = footnote;
|
table.Caption = footnote;
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table footnote.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="text">The footnote.</param>
|
||||||
|
/// <param name="style">The style.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
[Obsolete("Use Caption(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public static Table Footnote(this Table table, string text, Style? style = null)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Footnote(table, new TableTitle(text, style));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table footnote.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="footnote">The footnote.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
[Obsolete("Use Caption(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public static Table Footnote(this Table table, TableTitle footnote)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
table.Caption = footnote;
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table heading.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="text">The heading.</param>
|
||||||
|
/// <param name="style">The style.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
[Obsolete("Use Title(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public static Table Heading(this Table table, string text, Style? style = null)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Heading(table, new TableTitle(text, style));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table heading.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="heading">The heading.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
[Obsolete("Use Title(..) instead.")]
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
public static Table Heading(this Table table, TableTitle heading)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
table.Title = heading;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
55
src/Spectre.Console/Extensions/TableColumnExtensions.cs
Normal file
55
src/Spectre.Console/Extensions/TableColumnExtensions.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using Spectre.Console.Rendering;
|
||||||
|
|
||||||
|
namespace Spectre.Console
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains extension methods for <see cref="TableColumn"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class TableColumnExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table column footer.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="column">The table column.</param>
|
||||||
|
/// <param name="footer">The table column markup text.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
public static TableColumn Footer(this TableColumn column, string footer)
|
||||||
|
{
|
||||||
|
if (column is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(column));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (footer is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
column.Footer = new Markup(footer);
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table column footer.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="column">The table column.</param>
|
||||||
|
/// <param name="footer">The table column footer.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
public static TableColumn Footer(this TableColumn column, IRenderable footer)
|
||||||
|
{
|
||||||
|
if (column is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(column));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (footer is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(footer));
|
||||||
|
}
|
||||||
|
|
||||||
|
column.Footer = footer;
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -178,52 +178,45 @@ namespace Spectre.Console
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the table heading.
|
/// Shows table footers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="table">The table.</param>
|
/// <param name="table">The table.</param>
|
||||||
/// <param name="text">The heading.</param>
|
|
||||||
/// <param name="style">The style.</param>
|
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
public static Table Heading(this Table table, string text, Style? style = null)
|
public static Table ShowFooters(this Table table)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(table));
|
throw new ArgumentNullException(nameof(table));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text is null)
|
table.ShowFooters = true;
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(text));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Heading(table, new TableTitle(text, style));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the table heading.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="table">The table.</param>
|
|
||||||
/// <param name="heading">The heading.</param>
|
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
|
||||||
public static Table Heading(this Table table, TableTitle heading)
|
|
||||||
{
|
|
||||||
if (table is null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(table));
|
|
||||||
}
|
|
||||||
|
|
||||||
table.Heading = heading;
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the table footnote.
|
/// Hides table footers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="table">The table.</param>
|
/// <param name="table">The table.</param>
|
||||||
/// <param name="text">The footnote.</param>
|
|
||||||
/// <param name="style">The style.</param>
|
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
public static Table Footnote(this Table table, string text, Style? style = null)
|
public static Table HideFooters(this Table table)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
table.ShowFooters = false;
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table title.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="text">The table title markup text.</param>
|
||||||
|
/// <param name="style">The table title style.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
public static Table Title(this Table table, string text, Style? style = null)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
{
|
{
|
||||||
@ -235,23 +228,62 @@ namespace Spectre.Console
|
|||||||
throw new ArgumentNullException(nameof(text));
|
throw new ArgumentNullException(nameof(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Footnote(table, new TableTitle(text, style));
|
return Title(table, new TableTitle(text, style));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the table footnote.
|
/// Sets the table title.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="table">The table.</param>
|
/// <param name="table">The table.</param>
|
||||||
/// <param name="footnote">The footnote.</param>
|
/// <param name="title">The table title.</param>
|
||||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
public static Table Footnote(this Table table, TableTitle footnote)
|
public static Table Title(this Table table, TableTitle title)
|
||||||
{
|
{
|
||||||
if (table is null)
|
if (table is null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(table));
|
throw new ArgumentNullException(nameof(table));
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Footnote = footnote;
|
table.Title = title;
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table caption.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="text">The caption markup text.</param>
|
||||||
|
/// <param name="style">The style.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
public static Table Caption(this Table table, string text, Style? style = null)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Caption(table, new TableTitle(text, style));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the table caption.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">The table.</param>
|
||||||
|
/// <param name="caption">The caption.</param>
|
||||||
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||||
|
public static Table Caption(this Table table, TableTitle caption)
|
||||||
|
{
|
||||||
|
if (table is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(table));
|
||||||
|
}
|
||||||
|
|
||||||
|
table.Caption = caption;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,26 @@ namespace Spectre.Console.Rendering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
HeaderBottomRight,
|
HeaderBottomRight,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The top left part of a footer.
|
||||||
|
/// </summary>
|
||||||
|
FooterTopLeft,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The top part of a footer.
|
||||||
|
/// </summary>
|
||||||
|
FooterTop,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The top separator part of a footer.
|
||||||
|
/// </summary>
|
||||||
|
FooterTopSeparator,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The top right part of a footer.
|
||||||
|
/// </summary>
|
||||||
|
FooterTopRight,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The left part of a cell.
|
/// The left part of a cell.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "|",
|
TableBorderPart.CellLeft => "|",
|
||||||
TableBorderPart.CellSeparator => "|",
|
TableBorderPart.CellSeparator => "|",
|
||||||
TableBorderPart.CellRight => "|",
|
TableBorderPart.CellRight => "|",
|
||||||
|
TableBorderPart.FooterTopLeft => "|",
|
||||||
|
TableBorderPart.FooterTop => "-",
|
||||||
|
TableBorderPart.FooterTopSeparator => "+",
|
||||||
|
TableBorderPart.FooterTopRight => "|",
|
||||||
TableBorderPart.FooterBottomLeft => "+",
|
TableBorderPart.FooterBottomLeft => "+",
|
||||||
TableBorderPart.FooterBottom => "-",
|
TableBorderPart.FooterBottom => "-",
|
||||||
TableBorderPart.FooterBottomSeparator => "+",
|
TableBorderPart.FooterBottomSeparator => "+",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "|",
|
TableBorderPart.CellLeft => "|",
|
||||||
TableBorderPart.CellSeparator => "|",
|
TableBorderPart.CellSeparator => "|",
|
||||||
TableBorderPart.CellRight => "|",
|
TableBorderPart.CellRight => "|",
|
||||||
|
TableBorderPart.FooterTopLeft => "+",
|
||||||
|
TableBorderPart.FooterTop => "-",
|
||||||
|
TableBorderPart.FooterTopSeparator => "+",
|
||||||
|
TableBorderPart.FooterTopRight => "+",
|
||||||
TableBorderPart.FooterBottomLeft => "+",
|
TableBorderPart.FooterBottomLeft => "+",
|
||||||
TableBorderPart.FooterBottom => "-",
|
TableBorderPart.FooterBottom => "-",
|
||||||
TableBorderPart.FooterBottomSeparator => "+",
|
TableBorderPart.FooterBottomSeparator => "+",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "|",
|
TableBorderPart.CellLeft => "|",
|
||||||
TableBorderPart.CellSeparator => "|",
|
TableBorderPart.CellSeparator => "|",
|
||||||
TableBorderPart.CellRight => "|",
|
TableBorderPart.CellRight => "|",
|
||||||
|
TableBorderPart.FooterTopLeft => "|",
|
||||||
|
TableBorderPart.FooterTop => "-",
|
||||||
|
TableBorderPart.FooterTopSeparator => "+",
|
||||||
|
TableBorderPart.FooterTopRight => "|",
|
||||||
TableBorderPart.FooterBottomLeft => "+",
|
TableBorderPart.FooterBottomLeft => "+",
|
||||||
TableBorderPart.FooterBottom => "-",
|
TableBorderPart.FooterBottom => "-",
|
||||||
TableBorderPart.FooterBottomSeparator => "-",
|
TableBorderPart.FooterBottomSeparator => "-",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "║",
|
TableBorderPart.CellLeft => "║",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => "║",
|
TableBorderPart.CellRight => "║",
|
||||||
|
TableBorderPart.FooterTopLeft => "╟",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┼",
|
||||||
|
TableBorderPart.FooterTopRight => "╢",
|
||||||
TableBorderPart.FooterBottomLeft => "╚",
|
TableBorderPart.FooterBottomLeft => "╚",
|
||||||
TableBorderPart.FooterBottom => "═",
|
TableBorderPart.FooterBottom => "═",
|
||||||
TableBorderPart.FooterBottomSeparator => "╧",
|
TableBorderPart.FooterBottomSeparator => "╧",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "║",
|
TableBorderPart.CellLeft => "║",
|
||||||
TableBorderPart.CellSeparator => "║",
|
TableBorderPart.CellSeparator => "║",
|
||||||
TableBorderPart.CellRight => "║",
|
TableBorderPart.CellRight => "║",
|
||||||
|
TableBorderPart.FooterTopLeft => "╠",
|
||||||
|
TableBorderPart.FooterTop => "═",
|
||||||
|
TableBorderPart.FooterTopSeparator => "╬",
|
||||||
|
TableBorderPart.FooterTopRight => "╣",
|
||||||
TableBorderPart.FooterBottomLeft => "╚",
|
TableBorderPart.FooterBottomLeft => "╚",
|
||||||
TableBorderPart.FooterBottom => "═",
|
TableBorderPart.FooterBottom => "═",
|
||||||
TableBorderPart.FooterBottomSeparator => "╩",
|
TableBorderPart.FooterBottomSeparator => "╩",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "┃",
|
TableBorderPart.CellLeft => "┃",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => "┃",
|
TableBorderPart.CellRight => "┃",
|
||||||
|
TableBorderPart.FooterTopLeft => "┠",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┼",
|
||||||
|
TableBorderPart.FooterTopRight => "┨",
|
||||||
TableBorderPart.FooterBottomLeft => "┗",
|
TableBorderPart.FooterBottomLeft => "┗",
|
||||||
TableBorderPart.FooterBottom => "━",
|
TableBorderPart.FooterBottom => "━",
|
||||||
TableBorderPart.FooterBottomSeparator => "┷",
|
TableBorderPart.FooterBottomSeparator => "┷",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "│",
|
TableBorderPart.CellLeft => "│",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => "│",
|
TableBorderPart.CellRight => "│",
|
||||||
|
TableBorderPart.FooterTopLeft => "├",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┼",
|
||||||
|
TableBorderPart.FooterTopRight => "┤",
|
||||||
TableBorderPart.FooterBottomLeft => "└",
|
TableBorderPart.FooterBottomLeft => "└",
|
||||||
TableBorderPart.FooterBottom => "─",
|
TableBorderPart.FooterBottom => "─",
|
||||||
TableBorderPart.FooterBottomSeparator => "┴",
|
TableBorderPart.FooterBottomSeparator => "┴",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "┃",
|
TableBorderPart.CellLeft => "┃",
|
||||||
TableBorderPart.CellSeparator => "┃",
|
TableBorderPart.CellSeparator => "┃",
|
||||||
TableBorderPart.CellRight => "┃",
|
TableBorderPart.CellRight => "┃",
|
||||||
|
TableBorderPart.FooterTopLeft => "┣",
|
||||||
|
TableBorderPart.FooterTop => "━",
|
||||||
|
TableBorderPart.FooterTopSeparator => "╋",
|
||||||
|
TableBorderPart.FooterTopRight => "┫",
|
||||||
TableBorderPart.FooterBottomLeft => "┗",
|
TableBorderPart.FooterBottomLeft => "┗",
|
||||||
TableBorderPart.FooterBottom => "━",
|
TableBorderPart.FooterBottom => "━",
|
||||||
TableBorderPart.FooterBottomSeparator => "┻",
|
TableBorderPart.FooterBottomSeparator => "┻",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => " ",
|
TableBorderPart.CellLeft => " ",
|
||||||
TableBorderPart.CellSeparator => " ",
|
TableBorderPart.CellSeparator => " ",
|
||||||
TableBorderPart.CellRight => " ",
|
TableBorderPart.CellRight => " ",
|
||||||
|
TableBorderPart.FooterTopLeft => "─",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "─",
|
||||||
|
TableBorderPart.FooterTopRight => "─",
|
||||||
TableBorderPart.FooterBottomLeft => "─",
|
TableBorderPart.FooterBottomLeft => "─",
|
||||||
TableBorderPart.FooterBottom => "─",
|
TableBorderPart.FooterBottom => "─",
|
||||||
TableBorderPart.FooterBottomSeparator => "─",
|
TableBorderPart.FooterBottomSeparator => "─",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "|",
|
TableBorderPart.CellLeft => "|",
|
||||||
TableBorderPart.CellSeparator => "|",
|
TableBorderPart.CellSeparator => "|",
|
||||||
TableBorderPart.CellRight => "|",
|
TableBorderPart.CellRight => "|",
|
||||||
|
TableBorderPart.FooterTopLeft => " ",
|
||||||
|
TableBorderPart.FooterTop => " ",
|
||||||
|
TableBorderPart.FooterTopSeparator => " ",
|
||||||
|
TableBorderPart.FooterTopRight => " ",
|
||||||
TableBorderPart.FooterBottomLeft => " ",
|
TableBorderPart.FooterBottomLeft => " ",
|
||||||
TableBorderPart.FooterBottom => " ",
|
TableBorderPart.FooterBottom => " ",
|
||||||
TableBorderPart.FooterBottomSeparator => " ",
|
TableBorderPart.FooterBottomSeparator => " ",
|
||||||
@ -40,7 +44,12 @@ namespace Spectre.Console.Rendering
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override string GetColumnRow(TablePart part, IReadOnlyList<int> widths, IReadOnlyList<IColumn> columns)
|
public override string GetColumnRow(TablePart part, IReadOnlyList<int> widths, IReadOnlyList<IColumn> columns)
|
||||||
{
|
{
|
||||||
if (part != TablePart.Separator)
|
if (part == TablePart.FooterSeparator)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part != TablePart.HeaderSeparator)
|
||||||
{
|
{
|
||||||
return base.GetColumnRow(part, widths, columns);
|
return base.GetColumnRow(part, widths, columns);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => " ",
|
TableBorderPart.CellLeft => " ",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => " ",
|
TableBorderPart.CellRight => " ",
|
||||||
|
TableBorderPart.FooterTopLeft => " ",
|
||||||
|
TableBorderPart.FooterTop => "═",
|
||||||
|
TableBorderPart.FooterTopSeparator => "╪",
|
||||||
|
TableBorderPart.FooterTopRight => " ",
|
||||||
TableBorderPart.FooterBottomLeft => " ",
|
TableBorderPart.FooterBottomLeft => " ",
|
||||||
TableBorderPart.FooterBottom => " ",
|
TableBorderPart.FooterBottom => " ",
|
||||||
TableBorderPart.FooterBottomSeparator => " ",
|
TableBorderPart.FooterBottomSeparator => " ",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => " ",
|
TableBorderPart.CellLeft => " ",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => " ",
|
TableBorderPart.CellRight => " ",
|
||||||
|
TableBorderPart.FooterTopLeft => " ",
|
||||||
|
TableBorderPart.FooterTop => "━",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┿",
|
||||||
|
TableBorderPart.FooterTopRight => " ",
|
||||||
TableBorderPart.FooterBottomLeft => " ",
|
TableBorderPart.FooterBottomLeft => " ",
|
||||||
TableBorderPart.FooterBottom => " ",
|
TableBorderPart.FooterBottom => " ",
|
||||||
TableBorderPart.FooterBottomSeparator => " ",
|
TableBorderPart.FooterBottomSeparator => " ",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => " ",
|
TableBorderPart.CellLeft => " ",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => " ",
|
TableBorderPart.CellRight => " ",
|
||||||
|
TableBorderPart.FooterTopLeft => " ",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┼",
|
||||||
|
TableBorderPart.FooterTopRight => " ",
|
||||||
TableBorderPart.FooterBottomLeft => " ",
|
TableBorderPart.FooterBottomLeft => " ",
|
||||||
TableBorderPart.FooterBottom => " ",
|
TableBorderPart.FooterBottom => " ",
|
||||||
TableBorderPart.FooterBottomSeparator => " ",
|
TableBorderPart.FooterBottomSeparator => " ",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "│",
|
TableBorderPart.CellLeft => "│",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => "│",
|
TableBorderPart.CellRight => "│",
|
||||||
|
TableBorderPart.FooterTopLeft => "├",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┼",
|
||||||
|
TableBorderPart.FooterTopRight => "┤",
|
||||||
TableBorderPart.FooterBottomLeft => "╰",
|
TableBorderPart.FooterBottomLeft => "╰",
|
||||||
TableBorderPart.FooterBottom => "─",
|
TableBorderPart.FooterBottom => "─",
|
||||||
TableBorderPart.FooterBottomSeparator => "┴",
|
TableBorderPart.FooterBottomSeparator => "┴",
|
||||||
|
@ -29,6 +29,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => " ",
|
TableBorderPart.CellLeft => " ",
|
||||||
TableBorderPart.CellSeparator => " ",
|
TableBorderPart.CellSeparator => " ",
|
||||||
TableBorderPart.CellRight => " ",
|
TableBorderPart.CellRight => " ",
|
||||||
|
TableBorderPart.FooterTopLeft => "━",
|
||||||
|
TableBorderPart.FooterTop => "━",
|
||||||
|
TableBorderPart.FooterTopSeparator => "━",
|
||||||
|
TableBorderPart.FooterTopRight => "━",
|
||||||
TableBorderPart.FooterBottomLeft => " ",
|
TableBorderPart.FooterBottomLeft => " ",
|
||||||
TableBorderPart.FooterBottom => " ",
|
TableBorderPart.FooterBottom => " ",
|
||||||
TableBorderPart.FooterBottomSeparator => " ",
|
TableBorderPart.FooterBottomSeparator => " ",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => " ",
|
TableBorderPart.CellLeft => " ",
|
||||||
TableBorderPart.CellSeparator => " ",
|
TableBorderPart.CellSeparator => " ",
|
||||||
TableBorderPart.CellRight => " ",
|
TableBorderPart.CellRight => " ",
|
||||||
|
TableBorderPart.FooterTopLeft => "─",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "─",
|
||||||
|
TableBorderPart.FooterTopRight => "─",
|
||||||
TableBorderPart.FooterBottomLeft => " ",
|
TableBorderPart.FooterBottomLeft => " ",
|
||||||
TableBorderPart.FooterBottom => " ",
|
TableBorderPart.FooterBottom => " ",
|
||||||
TableBorderPart.FooterBottomSeparator => " ",
|
TableBorderPart.FooterBottomSeparator => " ",
|
||||||
|
@ -26,6 +26,10 @@ namespace Spectre.Console.Rendering
|
|||||||
TableBorderPart.CellLeft => "│",
|
TableBorderPart.CellLeft => "│",
|
||||||
TableBorderPart.CellSeparator => "│",
|
TableBorderPart.CellSeparator => "│",
|
||||||
TableBorderPart.CellRight => "│",
|
TableBorderPart.CellRight => "│",
|
||||||
|
TableBorderPart.FooterTopLeft => "├",
|
||||||
|
TableBorderPart.FooterTop => "─",
|
||||||
|
TableBorderPart.FooterTopSeparator => "┼",
|
||||||
|
TableBorderPart.FooterTopRight => "┤",
|
||||||
TableBorderPart.FooterBottomLeft => "└",
|
TableBorderPart.FooterBottomLeft => "└",
|
||||||
TableBorderPart.FooterBottom => "─",
|
TableBorderPart.FooterBottom => "─",
|
||||||
TableBorderPart.FooterBottomSeparator => "┴",
|
TableBorderPart.FooterBottomSeparator => "┴",
|
||||||
|
@ -13,7 +13,12 @@ namespace Spectre.Console.Rendering
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The separator between the header and the cells.
|
/// The separator between the header and the cells.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Separator,
|
HeaderSeparator,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The separator between the footer and the cells.
|
||||||
|
/// </summary>
|
||||||
|
FooterSeparator,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bottom of a table.
|
/// The bottom of a table.
|
||||||
|
@ -83,10 +83,15 @@ namespace Spectre.Console
|
|||||||
GetPart(TableBorderPart.HeaderTopSeparator), GetPart(TableBorderPart.HeaderTopRight)),
|
GetPart(TableBorderPart.HeaderTopSeparator), GetPart(TableBorderPart.HeaderTopRight)),
|
||||||
|
|
||||||
// Separator between header and cells
|
// Separator between header and cells
|
||||||
TablePart.Separator =>
|
TablePart.HeaderSeparator =>
|
||||||
(GetPart(TableBorderPart.HeaderBottomLeft), GetPart(TableBorderPart.HeaderBottom),
|
(GetPart(TableBorderPart.HeaderBottomLeft), GetPart(TableBorderPart.HeaderBottom),
|
||||||
GetPart(TableBorderPart.HeaderBottomSeparator), GetPart(TableBorderPart.HeaderBottomRight)),
|
GetPart(TableBorderPart.HeaderBottomSeparator), GetPart(TableBorderPart.HeaderBottomRight)),
|
||||||
|
|
||||||
|
// Separator between footer and cells
|
||||||
|
TablePart.FooterSeparator =>
|
||||||
|
(GetPart(TableBorderPart.FooterTopLeft), GetPart(TableBorderPart.FooterTop),
|
||||||
|
GetPart(TableBorderPart.FooterTopSeparator), GetPart(TableBorderPart.FooterTopRight)),
|
||||||
|
|
||||||
// Bottom part
|
// Bottom part
|
||||||
TablePart.Bottom =>
|
TablePart.Bottom =>
|
||||||
(GetPart(TableBorderPart.FooterBottomLeft), GetPart(TableBorderPart.FooterBottom),
|
(GetPart(TableBorderPart.FooterBottomLeft), GetPart(TableBorderPart.FooterBottom),
|
||||||
|
@ -209,7 +209,7 @@ namespace Spectre.Console
|
|||||||
if (ShowHeader)
|
if (ShowHeader)
|
||||||
{
|
{
|
||||||
var heading = new DateTime(Year, Month, Day).ToString("Y", culture).EscapeMarkup();
|
var heading = new DateTime(Year, Month, Day).ToString("Y", culture).EscapeMarkup();
|
||||||
table.Heading = new TableTitle(heading, HeaderStyle);
|
table.Title = new TableTitle(heading, HeaderStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add columns
|
// Add columns
|
||||||
|
@ -17,7 +17,7 @@ namespace Spectre.Console
|
|||||||
private readonly List<List<IRenderable>> _rows;
|
private readonly List<List<IRenderable>> _rows;
|
||||||
|
|
||||||
private static Style _defaultHeadingStyle = new Style(Color.Silver);
|
private static Style _defaultHeadingStyle = new Style(Color.Silver);
|
||||||
private static Style _defaultFootnoteStyle = new Style(Color.Grey);
|
private static Style _defaultCaptionStyle = new Style(Color.Grey);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the number of columns in the table.
|
/// Gets the number of columns in the table.
|
||||||
@ -43,6 +43,11 @@ namespace Spectre.Console
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowHeaders { get; set; } = true;
|
public bool ShowHeaders { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether or not table footers should be shown.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowFooters { get; set; } = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether or not the table should
|
/// Gets or sets a value indicating whether or not the table should
|
||||||
/// fit the available space. If <c>false</c>, the table width will be
|
/// fit the available space. If <c>false</c>, the table width will be
|
||||||
@ -58,12 +63,12 @@ namespace Spectre.Console
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the table title.
|
/// Gets or sets the table title.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TableTitle? Heading { get; set; }
|
public TableTitle? Title { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the table footnote.
|
/// Gets or sets the table footnote.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TableTitle? Footnote { get; set; }
|
public TableTitle? Caption { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Justify? Alignment { get; set; }
|
public Justify? Alignment { get; set; }
|
||||||
@ -174,6 +179,7 @@ namespace Spectre.Console
|
|||||||
var showBorder = Border.Visible;
|
var showBorder = Border.Visible;
|
||||||
var hideBorder = !Border.Visible;
|
var hideBorder = !Border.Visible;
|
||||||
var hasRows = _rows.Count > 0;
|
var hasRows = _rows.Count > 0;
|
||||||
|
var hasFooters = _columns.Any(c => c.Footer != null);
|
||||||
|
|
||||||
if (Width != null)
|
if (Width != null)
|
||||||
{
|
{
|
||||||
@ -196,14 +202,19 @@ namespace Spectre.Console
|
|||||||
if (ShowHeaders)
|
if (ShowHeaders)
|
||||||
{
|
{
|
||||||
// Add columns to top of rows
|
// Add columns to top of rows
|
||||||
rows.Add(new List<IRenderable>(_columns.Select(c => c.Text)));
|
rows.Add(new List<IRenderable>(_columns.Select(c => c.Header)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add rows.
|
// Add rows.
|
||||||
rows.AddRange(_rows);
|
rows.AddRange(_rows);
|
||||||
|
|
||||||
|
if (hasFooters)
|
||||||
|
{
|
||||||
|
rows.Add(new List<IRenderable>(_columns.Select(c => c.Footer ?? Text.Empty)));
|
||||||
|
}
|
||||||
|
|
||||||
var result = new List<Segment>();
|
var result = new List<Segment>();
|
||||||
result.AddRange(RenderAnnotation(context, Heading, actualMaxWidth, tableWidth, _defaultHeadingStyle));
|
result.AddRange(RenderAnnotation(context, Title, actualMaxWidth, tableWidth, _defaultHeadingStyle));
|
||||||
|
|
||||||
// Iterate all rows
|
// Iterate all rows
|
||||||
foreach (var (index, firstRow, lastRow, row) in rows.Enumerate())
|
foreach (var (index, firstRow, lastRow, row) in rows.Enumerate())
|
||||||
@ -230,6 +241,18 @@ namespace Spectre.Console
|
|||||||
result.Add(Segment.LineBreak);
|
result.Add(Segment.LineBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show footer separator?
|
||||||
|
if (ShowFooters && lastRow && showBorder && hasFooters)
|
||||||
|
{
|
||||||
|
var textBorder = border.GetColumnRow(TablePart.FooterSeparator, columnWidths, _columns);
|
||||||
|
if (!string.IsNullOrEmpty(textBorder))
|
||||||
|
{
|
||||||
|
var separator = Aligner.Align(context, textBorder, Alignment, actualMaxWidth);
|
||||||
|
result.Add(new Segment(separator, borderStyle));
|
||||||
|
result.Add(Segment.LineBreak);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make cells the same shape
|
// Make cells the same shape
|
||||||
cells = Segment.MakeSameHeight(cellHeight, cells);
|
cells = Segment.MakeSameHeight(cellHeight, cells);
|
||||||
|
|
||||||
@ -310,7 +333,7 @@ namespace Spectre.Console
|
|||||||
// Show header separator?
|
// Show header separator?
|
||||||
if (firstRow && showBorder && ShowHeaders && hasRows)
|
if (firstRow && showBorder && ShowHeaders && hasRows)
|
||||||
{
|
{
|
||||||
var separator = Aligner.Align(context, border.GetColumnRow(TablePart.Separator, columnWidths, _columns), Alignment, actualMaxWidth);
|
var separator = Aligner.Align(context, border.GetColumnRow(TablePart.HeaderSeparator, columnWidths, _columns), Alignment, actualMaxWidth);
|
||||||
result.Add(new Segment(separator, borderStyle));
|
result.Add(new Segment(separator, borderStyle));
|
||||||
result.Add(Segment.LineBreak);
|
result.Add(Segment.LineBreak);
|
||||||
}
|
}
|
||||||
@ -324,7 +347,7 @@ namespace Spectre.Console
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.AddRange(RenderAnnotation(context, Footnote, actualMaxWidth, tableWidth, _defaultFootnoteStyle));
|
result.AddRange(RenderAnnotation(context, Caption, actualMaxWidth, tableWidth, _defaultCaptionStyle));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -437,16 +460,17 @@ namespace Spectre.Console
|
|||||||
var minWidths = new List<int>();
|
var minWidths = new List<int>();
|
||||||
var maxWidths = new List<int>();
|
var maxWidths = new List<int>();
|
||||||
|
|
||||||
// Include columns in measurement
|
// Include columns (both header and footer) in measurement
|
||||||
var measure = column.Text.Measure(options, maxWidth);
|
var headerMeasure = column.Header.Measure(options, maxWidth);
|
||||||
minWidths.Add(measure.Min);
|
var footerMeasure = column.Footer?.Measure(options, maxWidth) ?? headerMeasure;
|
||||||
maxWidths.Add(measure.Max);
|
minWidths.Add(Math.Min(headerMeasure.Min, footerMeasure.Min));
|
||||||
|
maxWidths.Add(Math.Max(headerMeasure.Max, footerMeasure.Max));
|
||||||
|
|
||||||
foreach (var row in rows)
|
foreach (var row in rows)
|
||||||
{
|
{
|
||||||
measure = row.Measure(options, maxWidth);
|
var rowMeasure = row.Measure(options, maxWidth);
|
||||||
minWidths.Add(measure.Min);
|
minWidths.Add(rowMeasure.Min);
|
||||||
maxWidths.Add(measure.Max);
|
maxWidths.Add(rowMeasure.Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (minWidths.Count > 0 ? minWidths.Max() : padding,
|
return (minWidths.Count > 0 ? minWidths.Max() : padding,
|
||||||
|
@ -9,9 +9,14 @@ namespace Spectre.Console
|
|||||||
public sealed class TableColumn : IColumn
|
public sealed class TableColumn : IColumn
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the text associated with the column.
|
/// Gets the column header.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IRenderable Text { get; }
|
public IRenderable Header { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the column footer.
|
||||||
|
/// </summary>
|
||||||
|
public IRenderable? Footer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the width of the column.
|
/// Gets or sets the width of the column.
|
||||||
@ -39,19 +44,19 @@ namespace Spectre.Console
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TableColumn"/> class.
|
/// Initializes a new instance of the <see cref="TableColumn"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">The table column text.</param>
|
/// <param name="header">The table column header.</param>
|
||||||
public TableColumn(string text)
|
public TableColumn(string header)
|
||||||
: this(new Markup(text).Overflow(Overflow.Ellipsis))
|
: this(new Markup(header).Overflow(Overflow.Ellipsis))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TableColumn"/> class.
|
/// Initializes a new instance of the <see cref="TableColumn"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="renderable">The <see cref="IRenderable"/> instance to use as the table column.</param>
|
/// <param name="header">The <see cref="IRenderable"/> instance to use as the table column header.</param>
|
||||||
public TableColumn(IRenderable renderable)
|
public TableColumn(IRenderable header)
|
||||||
{
|
{
|
||||||
Text = renderable ?? throw new ArgumentNullException(nameof(renderable));
|
Header = header ?? throw new ArgumentNullException(nameof(header));
|
||||||
Width = null;
|
Width = null;
|
||||||
Padding = new Padding(1, 0, 1, 0);
|
Padding = new Padding(1, 0, 1, 0);
|
||||||
NoWrap = false;
|
NoWrap = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user