diff --git a/src/Sample/Program.cs b/src/Sample/Program.cs
index 8ee07ea6..9b375c74 100644
--- a/src/Sample/Program.cs
+++ b/src/Sample/Program.cs
@@ -51,12 +51,18 @@ namespace Sample
// Nest some panels and text
AnsiConsole.Foreground = Color.Maroon;
- AnsiConsole.Render(new Panel(new Panel(new Panel(new Panel(
- Text.New(
- "[underline]I[/] heard [underline on blue]you[/] like 📦\n\n\n\n" +
- "So I put a 📦 in a 📦\nin a 📦 in a 📦\n\n" +
- "😅",
- foreground: Color.White), content: Justify.Center)))));
+ AnsiConsole.Render(
+ new Panel(
+ new Panel(
+ new Panel(
+ new Panel(
+ Text.New(
+ "[underline]I[/] heard [underline on blue]you[/] like 📦\n\n\n\n" +
+ "So I put a 📦 in a 📦\nin a 📦 in a 📦\n\n" +
+ "😅", foreground: Color.White),
+ content: Justify.Center,
+ border: BorderKind.Rounded))),
+ border: BorderKind.Ascii));
// Reset colors
AnsiConsole.ResetColors();
diff --git a/src/Spectre.Console/Composition/BorderPart.cs b/src/Spectre.Console/Composition/BorderPart.cs
index 5b8d7b65..decfc1c5 100644
--- a/src/Spectre.Console/Composition/BorderPart.cs
+++ b/src/Spectre.Console/Composition/BorderPart.cs
@@ -73,7 +73,7 @@ namespace Spectre.Console.Composition
///
/// The right part of a cell.
///
- ColumnRight,
+ CellRight,
///
/// The bottom left part of a footer.
diff --git a/src/Spectre.Console/Composition/Borders/AsciiBorder.cs b/src/Spectre.Console/Composition/Borders/AsciiBorder.cs
index 06bc5cb8..d9521fe0 100644
--- a/src/Spectre.Console/Composition/Borders/AsciiBorder.cs
+++ b/src/Spectre.Console/Composition/Borders/AsciiBorder.cs
@@ -25,7 +25,7 @@ namespace Spectre.Console.Composition
BorderPart.HeaderBottomRight => "|",
BorderPart.CellLeft => "|",
BorderPart.CellSeparator => "|",
- BorderPart.ColumnRight => "|",
+ BorderPart.CellRight => "|",
BorderPart.FooterBottomLeft => "+",
BorderPart.FooterBottom => "-",
BorderPart.FooterBottomSeparator => "-",
diff --git a/src/Spectre.Console/Composition/Borders/RoundedBorder.cs b/src/Spectre.Console/Composition/Borders/RoundedBorder.cs
index 8b84e998..27b0321a 100644
--- a/src/Spectre.Console/Composition/Borders/RoundedBorder.cs
+++ b/src/Spectre.Console/Composition/Borders/RoundedBorder.cs
@@ -25,7 +25,7 @@ namespace Spectre.Console.Composition
BorderPart.HeaderBottomRight => "┤",
BorderPart.CellLeft => "│",
BorderPart.CellSeparator => "│",
- BorderPart.ColumnRight => "│",
+ BorderPart.CellRight => "│",
BorderPart.FooterBottomLeft => "╰",
BorderPart.FooterBottom => "─",
BorderPart.FooterBottomSeparator => "┴",
diff --git a/src/Spectre.Console/Composition/Borders/SquareBorder.cs b/src/Spectre.Console/Composition/Borders/SquareBorder.cs
index 8213d23a..4c49c7b4 100644
--- a/src/Spectre.Console/Composition/Borders/SquareBorder.cs
+++ b/src/Spectre.Console/Composition/Borders/SquareBorder.cs
@@ -25,7 +25,7 @@ namespace Spectre.Console.Composition
BorderPart.HeaderBottomRight => "┤",
BorderPart.CellLeft => "│",
BorderPart.CellSeparator => "│",
- BorderPart.ColumnRight => "│",
+ BorderPart.CellRight => "│",
BorderPart.FooterBottomLeft => "└",
BorderPart.FooterBottom => "─",
BorderPart.FooterBottomSeparator => "┴",
diff --git a/src/Spectre.Console/Composition/Panel.cs b/src/Spectre.Console/Composition/Panel.cs
index f6e7a624..9dab975a 100644
--- a/src/Spectre.Console/Composition/Panel.cs
+++ b/src/Spectre.Console/Composition/Panel.cs
@@ -13,6 +13,7 @@ namespace Spectre.Console
private readonly IRenderable _child;
private readonly bool _fit;
private readonly Justify _content;
+ private readonly Border _border;
///
/// Initializes a new instance of the class.
@@ -20,11 +21,17 @@ namespace Spectre.Console
/// The child.
/// Whether or not to fit the panel to it's parent.
/// The justification of the panel content.
- public Panel(IRenderable child, bool fit = false, Justify content = Justify.Left)
+ /// The border to use.
+ public Panel(
+ IRenderable child,
+ bool fit = false,
+ Justify content = Justify.Left,
+ BorderKind border = BorderKind.Square)
{
- _child = child;
+ _child = child ?? throw new System.ArgumentNullException(nameof(child));
_fit = fit;
_content = content;
+ _border = Border.GetBorder(border);
}
///
@@ -46,9 +53,9 @@ namespace Spectre.Console
var result = new List();
var panelWidth = childWidth + 2;
- result.Add(new Segment("┌"));
- result.Add(new Segment(new string('─', panelWidth)));
- result.Add(new Segment("┐"));
+ result.Add(new Segment(_border.GetPart(BorderPart.HeaderTopLeft)));
+ result.Add(new Segment(_border.GetPart(BorderPart.HeaderTop, panelWidth)));
+ result.Add(new Segment(_border.GetPart(BorderPart.HeaderTopRight)));
result.Add(new Segment("\n"));
// Render the child.
@@ -58,13 +65,15 @@ namespace Spectre.Console
var lines = Segment.SplitLines(childSegments, childWidth);
foreach (var line in lines)
{
- result.Add(new Segment("│ "));
+ result.Add(new Segment(_border.GetPart(BorderPart.CellLeft)));
+ result.Add(new Segment(" ")); // Left padding
var content = new List();
var length = line.Sum(segment => segment.CellLength(encoding));
if (length < childWidth)
{
+ // Justify right side
if (_content == Justify.Right)
{
var diff = childWidth - length;
@@ -82,6 +91,7 @@ namespace Spectre.Console
content.Add(segment.StripLineEndings());
}
+ // Justify left side
if (length < childWidth)
{
if (_content == Justify.Left)
@@ -104,13 +114,14 @@ namespace Spectre.Console
result.AddRange(content);
- result.Add(new Segment(" │"));
+ result.Add(new Segment(" "));
+ result.Add(new Segment(_border.GetPart(BorderPart.CellRight)));
result.Add(new Segment("\n"));
}
- result.Add(new Segment("└"));
- result.Add(new Segment(new string('─', panelWidth)));
- result.Add(new Segment("┘"));
+ result.Add(new Segment(_border.GetPart(BorderPart.FooterBottomLeft)));
+ result.Add(new Segment(_border.GetPart(BorderPart.FooterBottom, panelWidth)));
+ result.Add(new Segment(_border.GetPart(BorderPart.FooterBottomRight)));
result.Add(new Segment("\n"));
return result;
diff --git a/src/Spectre.Console/Composition/Table.cs b/src/Spectre.Console/Composition/Table.cs
index 13c7f166..f0efbcca 100644
--- a/src/Spectre.Console/Composition/Table.cs
+++ b/src/Spectre.Console/Composition/Table.cs
@@ -224,7 +224,7 @@ namespace Spectre.Console
if (lastCell && showBorder)
{
// Add right column edge
- result.Add(new Segment(_border.GetPart(BorderPart.ColumnRight)));
+ result.Add(new Segment(_border.GetPart(BorderPart.CellRight)));
}
else if (showBorder || (hideBorder && !lastCell))
{