Add option to show separator between table rows (#1304)

* Add option to show separator between table rows
* Panels should show header if borders are not shown

Closes #835
This commit is contained in:
Patrik Svensson
2023-09-16 18:49:12 +02:00
committed by GitHub
parent 037e109699
commit c82d8c4523
33 changed files with 272 additions and 43 deletions

View File

@ -114,4 +114,24 @@ public enum TableBorderPart
/// The bottom right part of a footer.
/// </summary>
FooterBottomRight,
/// <summary>
/// The left part of a row.
/// </summary>
RowLeft,
/// <summary>
/// The center part of a row.
/// </summary>
RowCenter,
/// <summary>
/// The separator part of a row.
/// </summary>
RowSeparator,
/// <summary>
/// The right part of a row.
/// </summary>
RowRight,
}

View File

@ -32,6 +32,10 @@ public sealed class Ascii2TableBorder : TableBorder
TableBorderPart.FooterBottom => "-",
TableBorderPart.FooterBottomSeparator => "+",
TableBorderPart.FooterBottomRight => "+",
TableBorderPart.RowLeft => "|",
TableBorderPart.RowCenter => "-",
TableBorderPart.RowSeparator => "+",
TableBorderPart.RowRight => "|",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class AsciiDoubleHeadTableBorder : TableBorder
TableBorderPart.FooterBottom => "-",
TableBorderPart.FooterBottomSeparator => "+",
TableBorderPart.FooterBottomRight => "+",
TableBorderPart.RowLeft => "|",
TableBorderPart.RowCenter => "-",
TableBorderPart.RowSeparator => "+",
TableBorderPart.RowRight => "|",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class AsciiTableBorder : TableBorder
TableBorderPart.FooterBottom => "-",
TableBorderPart.FooterBottomSeparator => "-",
TableBorderPart.FooterBottomRight => "+",
TableBorderPart.RowLeft => "|",
TableBorderPart.RowCenter => "-",
TableBorderPart.RowSeparator => "+",
TableBorderPart.RowRight => "|",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class DoubleEdgeTableBorder : TableBorder
TableBorderPart.FooterBottom => "═",
TableBorderPart.FooterBottomSeparator => "╧",
TableBorderPart.FooterBottomRight => "╝",
TableBorderPart.RowLeft => "╟",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => "╢",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class DoubleTableBorder : TableBorder
TableBorderPart.FooterBottom => "═",
TableBorderPart.FooterBottomSeparator => "╩",
TableBorderPart.FooterBottomRight => "╝",
TableBorderPart.RowLeft => "╠",
TableBorderPart.RowCenter => "═",
TableBorderPart.RowSeparator => "╬",
TableBorderPart.RowRight => "╣",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -35,6 +35,10 @@ public sealed class HeavyEdgeTableBorder : TableBorder
TableBorderPart.FooterBottom => "━",
TableBorderPart.FooterBottomSeparator => "┷",
TableBorderPart.FooterBottomRight => "┛",
TableBorderPart.RowLeft => "┠",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => "┨",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -35,6 +35,10 @@ public sealed class HeavyHeadTableBorder : TableBorder
TableBorderPart.FooterBottom => "─",
TableBorderPart.FooterBottomSeparator => "┴",
TableBorderPart.FooterBottomRight => "┘",
TableBorderPart.RowLeft => "├",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => "┤",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -35,6 +35,10 @@ public sealed class HeavyTableBorder : TableBorder
TableBorderPart.FooterBottom => "━",
TableBorderPart.FooterBottomSeparator => "┻",
TableBorderPart.FooterBottomRight => "┛",
TableBorderPart.RowLeft => "┣",
TableBorderPart.RowCenter => "━",
TableBorderPart.RowSeparator => "╋",
TableBorderPart.RowRight => "┫",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class HorizontalTableBorder : TableBorder
TableBorderPart.FooterBottom => "─",
TableBorderPart.FooterBottomSeparator => "─",
TableBorderPart.FooterBottomRight => "─",
TableBorderPart.RowLeft => "─",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "─",
TableBorderPart.RowRight => "─",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -5,6 +5,9 @@ namespace Spectre.Console.Rendering;
/// </summary>
public sealed class MarkdownTableBorder : TableBorder
{
/// <inheritdoc />
public override bool SupportsRowSeparator => false;
/// <inheritdoc/>
public override string GetPart(TableBorderPart part)
{
@ -32,6 +35,10 @@ public sealed class MarkdownTableBorder : TableBorder
TableBorderPart.FooterBottom => " ",
TableBorderPart.FooterBottomSeparator => " ",
TableBorderPart.FooterBottomRight => " ",
TableBorderPart.RowLeft => " ",
TableBorderPart.RowCenter => " ",
TableBorderPart.RowSeparator => " ",
TableBorderPart.RowRight => " ",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class MinimalDoubleHeadTableBorder : TableBorder
TableBorderPart.FooterBottom => " ",
TableBorderPart.FooterBottomSeparator => " ",
TableBorderPart.FooterBottomRight => " ",
TableBorderPart.RowLeft => " ",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => " ",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -35,6 +35,10 @@ public sealed class MinimalHeavyHeadTableBorder : TableBorder
TableBorderPart.FooterBottom => " ",
TableBorderPart.FooterBottomSeparator => " ",
TableBorderPart.FooterBottomRight => " ",
TableBorderPart.RowLeft => " ",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => " ",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class MinimalTableBorder : TableBorder
TableBorderPart.FooterBottom => " ",
TableBorderPart.FooterBottomSeparator => " ",
TableBorderPart.FooterBottomRight => " ",
TableBorderPart.RowLeft => " ",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => " ",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -8,6 +8,9 @@ public sealed class NoTableBorder : TableBorder
/// <inheritdoc/>
public override bool Visible => false;
/// <inheritdoc />
public override bool SupportsRowSeparator => false;
/// <inheritdoc/>
public override string GetPart(TableBorderPart part)
{

View File

@ -35,6 +35,10 @@ public sealed class RoundedTableBorder : TableBorder
TableBorderPart.FooterBottom => "─",
TableBorderPart.FooterBottomSeparator => "┴",
TableBorderPart.FooterBottomRight => "╯",
TableBorderPart.RowLeft => "├",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => "┤",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -35,6 +35,10 @@ public sealed class SimpleHeavyTableBorder : TableBorder
TableBorderPart.FooterBottom => " ",
TableBorderPart.FooterBottomSeparator => " ",
TableBorderPart.FooterBottomRight => " ",
TableBorderPart.RowLeft => "─",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "─",
TableBorderPart.RowRight => "─",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class SimpleTableBorder : TableBorder
TableBorderPart.FooterBottom => " ",
TableBorderPart.FooterBottomSeparator => " ",
TableBorderPart.FooterBottomRight => " ",
TableBorderPart.RowLeft => "─",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "─",
TableBorderPart.RowRight => "─",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -32,6 +32,10 @@ public sealed class SquareTableBorder : TableBorder
TableBorderPart.FooterBottom => "─",
TableBorderPart.FooterBottomSeparator => "┴",
TableBorderPart.FooterBottomRight => "┘",
TableBorderPart.RowLeft => "├",
TableBorderPart.RowCenter => "─",
TableBorderPart.RowSeparator => "┼",
TableBorderPart.RowRight => "┤",
_ => throw new InvalidOperationException("Unknown border part."),
};
}

View File

@ -15,6 +15,11 @@ public enum TablePart
/// </summary>
HeaderSeparator,
/// <summary>
/// The separator between the rows.
/// </summary>
RowSeparator,
/// <summary>
/// The separator between the footer and the cells.
/// </summary>