mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Clean up border code
Removed caching that really didn't do anything anymore.
This commit is contained in:

committed by
Patrik Svensson

parent
a2f8652575
commit
b1db8a9403
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class AsciiBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(BoxBorderPart part)
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class DoubleBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(BoxBorderPart part)
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override BoxBorder? SafeBorder => BoxBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(BoxBorderPart part)
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class NoBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(BoxBorderPart part)
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override BoxBorder? SafeBorder => BoxBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(BoxBorderPart part)
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class SquareBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(BoxBorderPart part)
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class Ascii2TableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class AsciiDoubleHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class AsciiTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class DoubleEdgeTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class DoubleTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class HorizontalTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class MarkdownTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
@ -57,39 +57,39 @@ namespace Spectre.Console.Rendering
|
||||
if (padding.Left > 0)
|
||||
{
|
||||
// Left padding
|
||||
builder.Append(" ".Multiply(padding.Left));
|
||||
builder.Append(" ".Repeat(padding.Left));
|
||||
}
|
||||
|
||||
var justification = columns[columnIndex].Alignment;
|
||||
if (justification == null)
|
||||
{
|
||||
// No alignment
|
||||
builder.Append(center.Multiply(columnWidth));
|
||||
builder.Append(center.Repeat(columnWidth));
|
||||
}
|
||||
else if (justification.Value == Justify.Left)
|
||||
{
|
||||
// Left
|
||||
builder.Append(':');
|
||||
builder.Append(center.Multiply(columnWidth - 1));
|
||||
builder.Append(center.Repeat(columnWidth - 1));
|
||||
}
|
||||
else if (justification.Value == Justify.Center)
|
||||
{
|
||||
// Centered
|
||||
builder.Append(':');
|
||||
builder.Append(center.Multiply(columnWidth - 2));
|
||||
builder.Append(center.Repeat(columnWidth - 2));
|
||||
builder.Append(':');
|
||||
}
|
||||
else if (justification.Value == Justify.Right)
|
||||
{
|
||||
// Right
|
||||
builder.Append(center.Multiply(columnWidth - 1));
|
||||
builder.Append(center.Repeat(columnWidth - 1));
|
||||
builder.Append(':');
|
||||
}
|
||||
|
||||
// Right padding
|
||||
if (padding.Right > 0)
|
||||
{
|
||||
builder.Append(" ".Multiply(padding.Right));
|
||||
builder.Append(" ".Repeat(padding.Right));
|
||||
}
|
||||
|
||||
if (!lastColumn)
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class MinimalDoubleHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override TableBorder? SafeBorder => TableBorder.Minimal;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class MinimalTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ namespace Spectre.Console.Rendering
|
||||
public override bool Visible => false;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ namespace Spectre.Console.Rendering
|
||||
public override TableBorder? SafeBorder => TableBorder.Simple;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class SimpleTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace Spectre.Console.Rendering
|
||||
public sealed class SquareTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override string GetBorderPart(TableBorderPart part)
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
|
Reference in New Issue
Block a user