mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Use file scoped namespace declarations
This commit is contained in:

committed by
Phil Scott

parent
1dbaf50935
commit
ec1188b837
@ -1,48 +1,47 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the different parts of a box border.
|
||||
/// </summary>
|
||||
public enum BoxBorderPart
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the different parts of a box border.
|
||||
/// The top left part of a box.
|
||||
/// </summary>
|
||||
public enum BoxBorderPart
|
||||
{
|
||||
/// <summary>
|
||||
/// The top left part of a box.
|
||||
/// </summary>
|
||||
TopLeft,
|
||||
TopLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The top part of a box.
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// The top part of a box.
|
||||
/// </summary>
|
||||
Top,
|
||||
|
||||
/// <summary>
|
||||
/// The top right part of a box.
|
||||
/// </summary>
|
||||
TopRight,
|
||||
/// <summary>
|
||||
/// The top right part of a box.
|
||||
/// </summary>
|
||||
TopRight,
|
||||
|
||||
/// <summary>
|
||||
/// The left part of a box.
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// The left part of a box.
|
||||
/// </summary>
|
||||
Left,
|
||||
|
||||
/// <summary>
|
||||
/// The right part of a box.
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// The right part of a box.
|
||||
/// </summary>
|
||||
Right,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom left part of a box.
|
||||
/// </summary>
|
||||
BottomLeft,
|
||||
/// <summary>
|
||||
/// The bottom left part of a box.
|
||||
/// </summary>
|
||||
BottomLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom part of a box.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
/// <summary>
|
||||
/// The bottom part of a box.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom right part of a box.
|
||||
/// </summary>
|
||||
BottomRight,
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The bottom right part of a box.
|
||||
/// </summary>
|
||||
BottomRight,
|
||||
}
|
@ -1,27 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an old school ASCII border.
|
||||
/// </summary>
|
||||
public sealed class AsciiBoxBorder : BoxBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an old school ASCII border.
|
||||
/// </summary>
|
||||
public sealed class AsciiBoxBorder : BoxBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
BoxBorderPart.TopLeft => "+",
|
||||
BoxBorderPart.Top => "-",
|
||||
BoxBorderPart.TopRight => "+",
|
||||
BoxBorderPart.Left => "|",
|
||||
BoxBorderPart.Right => "|",
|
||||
BoxBorderPart.BottomLeft => "+",
|
||||
BoxBorderPart.Bottom => "-",
|
||||
BoxBorderPart.BottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
BoxBorderPart.TopLeft => "+",
|
||||
BoxBorderPart.Top => "-",
|
||||
BoxBorderPart.TopRight => "+",
|
||||
BoxBorderPart.Left => "|",
|
||||
BoxBorderPart.Right => "|",
|
||||
BoxBorderPart.BottomLeft => "+",
|
||||
BoxBorderPart.Bottom => "-",
|
||||
BoxBorderPart.BottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a double border.
|
||||
/// </summary>
|
||||
public sealed class DoubleBoxBorder : BoxBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a double border.
|
||||
/// </summary>
|
||||
public sealed class DoubleBoxBorder : BoxBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
BoxBorderPart.TopLeft => "╔",
|
||||
BoxBorderPart.Top => "═",
|
||||
BoxBorderPart.TopRight => "╗",
|
||||
BoxBorderPart.Left => "║",
|
||||
BoxBorderPart.Right => "║",
|
||||
BoxBorderPart.BottomLeft => "╚",
|
||||
BoxBorderPart.Bottom => "═",
|
||||
BoxBorderPart.BottomRight => "╝",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
BoxBorderPart.TopLeft => "╔",
|
||||
BoxBorderPart.Top => "═",
|
||||
BoxBorderPart.TopRight => "╗",
|
||||
BoxBorderPart.Left => "║",
|
||||
BoxBorderPart.Right => "║",
|
||||
BoxBorderPart.BottomLeft => "╚",
|
||||
BoxBorderPart.Bottom => "═",
|
||||
BoxBorderPart.BottomRight => "╝",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a heavy border.
|
||||
/// </summary>
|
||||
public sealed class HeavyBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override BoxBorder? SafeBorder => BoxBorder.Square;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a heavy border.
|
||||
/// </summary>
|
||||
public sealed class HeavyBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override BoxBorder? SafeBorder => BoxBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
BoxBorderPart.TopLeft => "┏",
|
||||
BoxBorderPart.Top => "━",
|
||||
BoxBorderPart.TopRight => "┓",
|
||||
BoxBorderPart.Left => "┃",
|
||||
BoxBorderPart.Right => "┃",
|
||||
BoxBorderPart.BottomLeft => "┗",
|
||||
BoxBorderPart.Bottom => "━",
|
||||
BoxBorderPart.BottomRight => "┛",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
BoxBorderPart.TopLeft => "┏",
|
||||
BoxBorderPart.Top => "━",
|
||||
BoxBorderPart.TopRight => "┓",
|
||||
BoxBorderPart.Left => "┃",
|
||||
BoxBorderPart.Right => "┃",
|
||||
BoxBorderPart.BottomLeft => "┗",
|
||||
BoxBorderPart.Bottom => "━",
|
||||
BoxBorderPart.BottomRight => "┛",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an invisible border.
|
||||
/// </summary>
|
||||
public sealed class NoBoxBorder : BoxBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an invisible border.
|
||||
/// </summary>
|
||||
public sealed class NoBoxBorder : BoxBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a rounded border.
|
||||
/// </summary>
|
||||
public sealed class RoundedBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override BoxBorder? SafeBorder => BoxBorder.Square;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a rounded border.
|
||||
/// </summary>
|
||||
public sealed class RoundedBoxBorder : BoxBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override BoxBorder? SafeBorder => BoxBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
BoxBorderPart.TopLeft => "╭",
|
||||
BoxBorderPart.Top => "─",
|
||||
BoxBorderPart.TopRight => "╮",
|
||||
BoxBorderPart.Left => "│",
|
||||
BoxBorderPart.Right => "│",
|
||||
BoxBorderPart.BottomLeft => "╰",
|
||||
BoxBorderPart.Bottom => "─",
|
||||
BoxBorderPart.BottomRight => "╯",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
BoxBorderPart.TopLeft => "╭",
|
||||
BoxBorderPart.Top => "─",
|
||||
BoxBorderPart.TopRight => "╮",
|
||||
BoxBorderPart.Left => "│",
|
||||
BoxBorderPart.Right => "│",
|
||||
BoxBorderPart.BottomLeft => "╰",
|
||||
BoxBorderPart.Bottom => "─",
|
||||
BoxBorderPart.BottomRight => "╯",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a square border.
|
||||
/// </summary>
|
||||
public sealed class SquareBoxBorder : BoxBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a square border.
|
||||
/// </summary>
|
||||
public sealed class SquareBoxBorder : BoxBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(BoxBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
BoxBorderPart.TopLeft => "┌",
|
||||
BoxBorderPart.Top => "─",
|
||||
BoxBorderPart.TopRight => "┐",
|
||||
BoxBorderPart.Left => "│",
|
||||
BoxBorderPart.Right => "│",
|
||||
BoxBorderPart.BottomLeft => "└",
|
||||
BoxBorderPart.Bottom => "─",
|
||||
BoxBorderPart.BottomRight => "┘",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
BoxBorderPart.TopLeft => "┌",
|
||||
BoxBorderPart.Top => "─",
|
||||
BoxBorderPart.TopRight => "┐",
|
||||
BoxBorderPart.Left => "│",
|
||||
BoxBorderPart.Right => "│",
|
||||
BoxBorderPart.BottomLeft => "└",
|
||||
BoxBorderPart.Bottom => "─",
|
||||
BoxBorderPart.BottomRight => "┘",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,118 +1,117 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the different parts of a table border.
|
||||
/// </summary>
|
||||
public enum TableBorderPart
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the different parts of a table border.
|
||||
/// The top left part of a header.
|
||||
/// </summary>
|
||||
public enum TableBorderPart
|
||||
{
|
||||
/// <summary>
|
||||
/// The top left part of a header.
|
||||
/// </summary>
|
||||
HeaderTopLeft,
|
||||
HeaderTopLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The top part of a header.
|
||||
/// </summary>
|
||||
HeaderTop,
|
||||
/// <summary>
|
||||
/// The top part of a header.
|
||||
/// </summary>
|
||||
HeaderTop,
|
||||
|
||||
/// <summary>
|
||||
/// The top separator part of a header.
|
||||
/// </summary>
|
||||
HeaderTopSeparator,
|
||||
/// <summary>
|
||||
/// The top separator part of a header.
|
||||
/// </summary>
|
||||
HeaderTopSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The top right part of a header.
|
||||
/// </summary>
|
||||
HeaderTopRight,
|
||||
/// <summary>
|
||||
/// The top right part of a header.
|
||||
/// </summary>
|
||||
HeaderTopRight,
|
||||
|
||||
/// <summary>
|
||||
/// The left part of a header.
|
||||
/// </summary>
|
||||
HeaderLeft,
|
||||
/// <summary>
|
||||
/// The left part of a header.
|
||||
/// </summary>
|
||||
HeaderLeft,
|
||||
|
||||
/// <summary>
|
||||
/// A header separator.
|
||||
/// </summary>
|
||||
HeaderSeparator,
|
||||
/// <summary>
|
||||
/// A header separator.
|
||||
/// </summary>
|
||||
HeaderSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The right part of a header.
|
||||
/// </summary>
|
||||
HeaderRight,
|
||||
/// <summary>
|
||||
/// The right part of a header.
|
||||
/// </summary>
|
||||
HeaderRight,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom left part of a header.
|
||||
/// </summary>
|
||||
HeaderBottomLeft,
|
||||
/// <summary>
|
||||
/// The bottom left part of a header.
|
||||
/// </summary>
|
||||
HeaderBottomLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom part of a header.
|
||||
/// </summary>
|
||||
HeaderBottom,
|
||||
/// <summary>
|
||||
/// The bottom part of a header.
|
||||
/// </summary>
|
||||
HeaderBottom,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom separator part of a header.
|
||||
/// </summary>
|
||||
HeaderBottomSeparator,
|
||||
/// <summary>
|
||||
/// The bottom separator part of a header.
|
||||
/// </summary>
|
||||
HeaderBottomSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom right part of a header.
|
||||
/// </summary>
|
||||
HeaderBottomRight,
|
||||
/// <summary>
|
||||
/// The bottom right part of a header.
|
||||
/// </summary>
|
||||
HeaderBottomRight,
|
||||
|
||||
/// <summary>
|
||||
/// The top left part of a footer.
|
||||
/// </summary>
|
||||
FooterTopLeft,
|
||||
/// <summary>
|
||||
/// The top left part of a footer.
|
||||
/// </summary>
|
||||
FooterTopLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The top part of a footer.
|
||||
/// </summary>
|
||||
FooterTop,
|
||||
/// <summary>
|
||||
/// The top part of a footer.
|
||||
/// </summary>
|
||||
FooterTop,
|
||||
|
||||
/// <summary>
|
||||
/// The top separator part of a footer.
|
||||
/// </summary>
|
||||
FooterTopSeparator,
|
||||
/// <summary>
|
||||
/// The top separator part of a footer.
|
||||
/// </summary>
|
||||
FooterTopSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The top right part of a footer.
|
||||
/// </summary>
|
||||
FooterTopRight,
|
||||
/// <summary>
|
||||
/// The top right part of a footer.
|
||||
/// </summary>
|
||||
FooterTopRight,
|
||||
|
||||
/// <summary>
|
||||
/// The left part of a cell.
|
||||
/// </summary>
|
||||
CellLeft,
|
||||
/// <summary>
|
||||
/// The left part of a cell.
|
||||
/// </summary>
|
||||
CellLeft,
|
||||
|
||||
/// <summary>
|
||||
/// A cell separator.
|
||||
/// </summary>
|
||||
CellSeparator,
|
||||
/// <summary>
|
||||
/// A cell separator.
|
||||
/// </summary>
|
||||
CellSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The right part of a cell.
|
||||
/// </summary>
|
||||
CellRight,
|
||||
/// <summary>
|
||||
/// The right part of a cell.
|
||||
/// </summary>
|
||||
CellRight,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom left part of a footer.
|
||||
/// </summary>
|
||||
FooterBottomLeft,
|
||||
/// <summary>
|
||||
/// The bottom left part of a footer.
|
||||
/// </summary>
|
||||
FooterBottomLeft,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom part of a footer.
|
||||
/// </summary>
|
||||
FooterBottom,
|
||||
/// <summary>
|
||||
/// The bottom part of a footer.
|
||||
/// </summary>
|
||||
FooterBottom,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom separator part of a footer.
|
||||
/// </summary>
|
||||
FooterBottomSeparator,
|
||||
/// <summary>
|
||||
/// The bottom separator part of a footer.
|
||||
/// </summary>
|
||||
FooterBottomSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom right part of a footer.
|
||||
/// </summary>
|
||||
FooterBottomRight,
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The bottom right part of a footer.
|
||||
/// </summary>
|
||||
FooterBottomRight,
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents another old school ASCII border.
|
||||
/// </summary>
|
||||
public sealed class Ascii2TableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents another old school ASCII border.
|
||||
/// </summary>
|
||||
public sealed class Ascii2TableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "+",
|
||||
TableBorderPart.HeaderTop => "-",
|
||||
TableBorderPart.HeaderTopSeparator => "+",
|
||||
TableBorderPart.HeaderTopRight => "+",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "-",
|
||||
TableBorderPart.HeaderBottomSeparator => "+",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => "|",
|
||||
TableBorderPart.FooterTop => "-",
|
||||
TableBorderPart.FooterTopSeparator => "+",
|
||||
TableBorderPart.FooterTopRight => "|",
|
||||
TableBorderPart.FooterBottomLeft => "+",
|
||||
TableBorderPart.FooterBottom => "-",
|
||||
TableBorderPart.FooterBottomSeparator => "+",
|
||||
TableBorderPart.FooterBottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "+",
|
||||
TableBorderPart.HeaderTop => "-",
|
||||
TableBorderPart.HeaderTopSeparator => "+",
|
||||
TableBorderPart.HeaderTopRight => "+",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "-",
|
||||
TableBorderPart.HeaderBottomSeparator => "+",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => "|",
|
||||
TableBorderPart.FooterTop => "-",
|
||||
TableBorderPart.FooterTopSeparator => "+",
|
||||
TableBorderPart.FooterTopRight => "|",
|
||||
TableBorderPart.FooterBottomLeft => "+",
|
||||
TableBorderPart.FooterBottom => "-",
|
||||
TableBorderPart.FooterBottomSeparator => "+",
|
||||
TableBorderPart.FooterBottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an old school ASCII border with a double header border.
|
||||
/// </summary>
|
||||
public sealed class AsciiDoubleHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an old school ASCII border with a double header border.
|
||||
/// </summary>
|
||||
public sealed class AsciiDoubleHeadTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "+",
|
||||
TableBorderPart.HeaderTop => "-",
|
||||
TableBorderPart.HeaderTopSeparator => "+",
|
||||
TableBorderPart.HeaderTopRight => "+",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "=",
|
||||
TableBorderPart.HeaderBottomSeparator => "+",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => "+",
|
||||
TableBorderPart.FooterTop => "-",
|
||||
TableBorderPart.FooterTopSeparator => "+",
|
||||
TableBorderPart.FooterTopRight => "+",
|
||||
TableBorderPart.FooterBottomLeft => "+",
|
||||
TableBorderPart.FooterBottom => "-",
|
||||
TableBorderPart.FooterBottomSeparator => "+",
|
||||
TableBorderPart.FooterBottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "+",
|
||||
TableBorderPart.HeaderTop => "-",
|
||||
TableBorderPart.HeaderTopSeparator => "+",
|
||||
TableBorderPart.HeaderTopRight => "+",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "=",
|
||||
TableBorderPart.HeaderBottomSeparator => "+",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => "+",
|
||||
TableBorderPart.FooterTop => "-",
|
||||
TableBorderPart.FooterTopSeparator => "+",
|
||||
TableBorderPart.FooterTopRight => "+",
|
||||
TableBorderPart.FooterBottomLeft => "+",
|
||||
TableBorderPart.FooterBottom => "-",
|
||||
TableBorderPart.FooterBottomSeparator => "+",
|
||||
TableBorderPart.FooterBottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an old school ASCII border.
|
||||
/// </summary>
|
||||
public sealed class AsciiTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an old school ASCII border.
|
||||
/// </summary>
|
||||
public sealed class AsciiTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "+",
|
||||
TableBorderPart.HeaderTop => "-",
|
||||
TableBorderPart.HeaderTopSeparator => "-",
|
||||
TableBorderPart.HeaderTopRight => "+",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "-",
|
||||
TableBorderPart.HeaderBottomSeparator => "+",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => "|",
|
||||
TableBorderPart.FooterTop => "-",
|
||||
TableBorderPart.FooterTopSeparator => "+",
|
||||
TableBorderPart.FooterTopRight => "|",
|
||||
TableBorderPart.FooterBottomLeft => "+",
|
||||
TableBorderPart.FooterBottom => "-",
|
||||
TableBorderPart.FooterBottomSeparator => "-",
|
||||
TableBorderPart.FooterBottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "+",
|
||||
TableBorderPart.HeaderTop => "-",
|
||||
TableBorderPart.HeaderTopSeparator => "-",
|
||||
TableBorderPart.HeaderTopRight => "+",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "-",
|
||||
TableBorderPart.HeaderBottomSeparator => "+",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => "|",
|
||||
TableBorderPart.FooterTop => "-",
|
||||
TableBorderPart.FooterTopSeparator => "+",
|
||||
TableBorderPart.FooterTopRight => "|",
|
||||
TableBorderPart.FooterBottomLeft => "+",
|
||||
TableBorderPart.FooterBottom => "-",
|
||||
TableBorderPart.FooterBottomSeparator => "-",
|
||||
TableBorderPart.FooterBottomRight => "+",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a border with a double edge.
|
||||
/// </summary>
|
||||
public sealed class DoubleEdgeTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a border with a double edge.
|
||||
/// </summary>
|
||||
public sealed class DoubleEdgeTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "╔",
|
||||
TableBorderPart.HeaderTop => "═",
|
||||
TableBorderPart.HeaderTopSeparator => "╤",
|
||||
TableBorderPart.HeaderTopRight => "╗",
|
||||
TableBorderPart.HeaderLeft => "║",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "║",
|
||||
TableBorderPart.HeaderBottomLeft => "╟",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "╢",
|
||||
TableBorderPart.CellLeft => "║",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "║",
|
||||
TableBorderPart.FooterTopLeft => "╟",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "╢",
|
||||
TableBorderPart.FooterBottomLeft => "╚",
|
||||
TableBorderPart.FooterBottom => "═",
|
||||
TableBorderPart.FooterBottomSeparator => "╧",
|
||||
TableBorderPart.FooterBottomRight => "╝",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "╔",
|
||||
TableBorderPart.HeaderTop => "═",
|
||||
TableBorderPart.HeaderTopSeparator => "╤",
|
||||
TableBorderPart.HeaderTopRight => "╗",
|
||||
TableBorderPart.HeaderLeft => "║",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "║",
|
||||
TableBorderPart.HeaderBottomLeft => "╟",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "╢",
|
||||
TableBorderPart.CellLeft => "║",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "║",
|
||||
TableBorderPart.FooterTopLeft => "╟",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "╢",
|
||||
TableBorderPart.FooterBottomLeft => "╚",
|
||||
TableBorderPart.FooterBottom => "═",
|
||||
TableBorderPart.FooterBottomSeparator => "╧",
|
||||
TableBorderPart.FooterBottomRight => "╝",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a double border.
|
||||
/// </summary>
|
||||
public sealed class DoubleTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a double border.
|
||||
/// </summary>
|
||||
public sealed class DoubleTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "╔",
|
||||
TableBorderPart.HeaderTop => "═",
|
||||
TableBorderPart.HeaderTopSeparator => "╦",
|
||||
TableBorderPart.HeaderTopRight => "╗",
|
||||
TableBorderPart.HeaderLeft => "║",
|
||||
TableBorderPart.HeaderSeparator => "║",
|
||||
TableBorderPart.HeaderRight => "║",
|
||||
TableBorderPart.HeaderBottomLeft => "╠",
|
||||
TableBorderPart.HeaderBottom => "═",
|
||||
TableBorderPart.HeaderBottomSeparator => "╬",
|
||||
TableBorderPart.HeaderBottomRight => "╣",
|
||||
TableBorderPart.CellLeft => "║",
|
||||
TableBorderPart.CellSeparator => "║",
|
||||
TableBorderPart.CellRight => "║",
|
||||
TableBorderPart.FooterTopLeft => "╠",
|
||||
TableBorderPart.FooterTop => "═",
|
||||
TableBorderPart.FooterTopSeparator => "╬",
|
||||
TableBorderPart.FooterTopRight => "╣",
|
||||
TableBorderPart.FooterBottomLeft => "╚",
|
||||
TableBorderPart.FooterBottom => "═",
|
||||
TableBorderPart.FooterBottomSeparator => "╩",
|
||||
TableBorderPart.FooterBottomRight => "╝",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "╔",
|
||||
TableBorderPart.HeaderTop => "═",
|
||||
TableBorderPart.HeaderTopSeparator => "╦",
|
||||
TableBorderPart.HeaderTopRight => "╗",
|
||||
TableBorderPart.HeaderLeft => "║",
|
||||
TableBorderPart.HeaderSeparator => "║",
|
||||
TableBorderPart.HeaderRight => "║",
|
||||
TableBorderPart.HeaderBottomLeft => "╠",
|
||||
TableBorderPart.HeaderBottom => "═",
|
||||
TableBorderPart.HeaderBottomSeparator => "╬",
|
||||
TableBorderPart.HeaderBottomRight => "╣",
|
||||
TableBorderPart.CellLeft => "║",
|
||||
TableBorderPart.CellSeparator => "║",
|
||||
TableBorderPart.CellRight => "║",
|
||||
TableBorderPart.FooterTopLeft => "╠",
|
||||
TableBorderPart.FooterTop => "═",
|
||||
TableBorderPart.FooterTopSeparator => "╬",
|
||||
TableBorderPart.FooterTopRight => "╣",
|
||||
TableBorderPart.FooterBottomLeft => "╚",
|
||||
TableBorderPart.FooterBottom => "═",
|
||||
TableBorderPart.FooterBottomSeparator => "╩",
|
||||
TableBorderPart.FooterBottomRight => "╝",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a border with a heavy edge.
|
||||
/// </summary>
|
||||
public sealed class HeavyEdgeTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a border with a heavy edge.
|
||||
/// </summary>
|
||||
public sealed class HeavyEdgeTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "┏",
|
||||
TableBorderPart.HeaderTop => "━",
|
||||
TableBorderPart.HeaderTopSeparator => "┯",
|
||||
TableBorderPart.HeaderTopRight => "┓",
|
||||
TableBorderPart.HeaderLeft => "┃",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "┃",
|
||||
TableBorderPart.HeaderBottomLeft => "┠",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "┨",
|
||||
TableBorderPart.CellLeft => "┃",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "┃",
|
||||
TableBorderPart.FooterTopLeft => "┠",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┨",
|
||||
TableBorderPart.FooterBottomLeft => "┗",
|
||||
TableBorderPart.FooterBottom => "━",
|
||||
TableBorderPart.FooterBottomSeparator => "┷",
|
||||
TableBorderPart.FooterBottomRight => "┛",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "┏",
|
||||
TableBorderPart.HeaderTop => "━",
|
||||
TableBorderPart.HeaderTopSeparator => "┯",
|
||||
TableBorderPart.HeaderTopRight => "┓",
|
||||
TableBorderPart.HeaderLeft => "┃",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "┃",
|
||||
TableBorderPart.HeaderBottomLeft => "┠",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "┨",
|
||||
TableBorderPart.CellLeft => "┃",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "┃",
|
||||
TableBorderPart.FooterTopLeft => "┠",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┨",
|
||||
TableBorderPart.FooterBottomLeft => "┗",
|
||||
TableBorderPart.FooterBottom => "━",
|
||||
TableBorderPart.FooterBottomSeparator => "┷",
|
||||
TableBorderPart.FooterBottomRight => "┛",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a border with a heavy header.
|
||||
/// </summary>
|
||||
public sealed class HeavyHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a border with a heavy header.
|
||||
/// </summary>
|
||||
public sealed class HeavyHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "┏",
|
||||
TableBorderPart.HeaderTop => "━",
|
||||
TableBorderPart.HeaderTopSeparator => "┳",
|
||||
TableBorderPart.HeaderTopRight => "┓",
|
||||
TableBorderPart.HeaderLeft => "┃",
|
||||
TableBorderPart.HeaderSeparator => "┃",
|
||||
TableBorderPart.HeaderRight => "┃",
|
||||
TableBorderPart.HeaderBottomLeft => "┡",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "╇",
|
||||
TableBorderPart.HeaderBottomRight => "┩",
|
||||
TableBorderPart.CellLeft => "│",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "│",
|
||||
TableBorderPart.FooterTopLeft => "├",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┤",
|
||||
TableBorderPart.FooterBottomLeft => "└",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "┴",
|
||||
TableBorderPart.FooterBottomRight => "┘",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "┏",
|
||||
TableBorderPart.HeaderTop => "━",
|
||||
TableBorderPart.HeaderTopSeparator => "┳",
|
||||
TableBorderPart.HeaderTopRight => "┓",
|
||||
TableBorderPart.HeaderLeft => "┃",
|
||||
TableBorderPart.HeaderSeparator => "┃",
|
||||
TableBorderPart.HeaderRight => "┃",
|
||||
TableBorderPart.HeaderBottomLeft => "┡",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "╇",
|
||||
TableBorderPart.HeaderBottomRight => "┩",
|
||||
TableBorderPart.CellLeft => "│",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "│",
|
||||
TableBorderPart.FooterTopLeft => "├",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┤",
|
||||
TableBorderPart.FooterBottomLeft => "└",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "┴",
|
||||
TableBorderPart.FooterBottomRight => "┘",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a heavy border.
|
||||
/// </summary>
|
||||
public sealed class HeavyTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a heavy border.
|
||||
/// </summary>
|
||||
public sealed class HeavyTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "┏",
|
||||
TableBorderPart.HeaderTop => "━",
|
||||
TableBorderPart.HeaderTopSeparator => "┳",
|
||||
TableBorderPart.HeaderTopRight => "┓",
|
||||
TableBorderPart.HeaderLeft => "┃",
|
||||
TableBorderPart.HeaderSeparator => "┃",
|
||||
TableBorderPart.HeaderRight => "┃",
|
||||
TableBorderPart.HeaderBottomLeft => "┣",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "╋",
|
||||
TableBorderPart.HeaderBottomRight => "┫",
|
||||
TableBorderPart.CellLeft => "┃",
|
||||
TableBorderPart.CellSeparator => "┃",
|
||||
TableBorderPart.CellRight => "┃",
|
||||
TableBorderPart.FooterTopLeft => "┣",
|
||||
TableBorderPart.FooterTop => "━",
|
||||
TableBorderPart.FooterTopSeparator => "╋",
|
||||
TableBorderPart.FooterTopRight => "┫",
|
||||
TableBorderPart.FooterBottomLeft => "┗",
|
||||
TableBorderPart.FooterBottom => "━",
|
||||
TableBorderPart.FooterBottomSeparator => "┻",
|
||||
TableBorderPart.FooterBottomRight => "┛",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "┏",
|
||||
TableBorderPart.HeaderTop => "━",
|
||||
TableBorderPart.HeaderTopSeparator => "┳",
|
||||
TableBorderPart.HeaderTopRight => "┓",
|
||||
TableBorderPart.HeaderLeft => "┃",
|
||||
TableBorderPart.HeaderSeparator => "┃",
|
||||
TableBorderPart.HeaderRight => "┃",
|
||||
TableBorderPart.HeaderBottomLeft => "┣",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "╋",
|
||||
TableBorderPart.HeaderBottomRight => "┫",
|
||||
TableBorderPart.CellLeft => "┃",
|
||||
TableBorderPart.CellSeparator => "┃",
|
||||
TableBorderPart.CellRight => "┃",
|
||||
TableBorderPart.FooterTopLeft => "┣",
|
||||
TableBorderPart.FooterTop => "━",
|
||||
TableBorderPart.FooterTopSeparator => "╋",
|
||||
TableBorderPart.FooterTopRight => "┫",
|
||||
TableBorderPart.FooterBottomLeft => "┗",
|
||||
TableBorderPart.FooterBottom => "━",
|
||||
TableBorderPart.FooterBottomSeparator => "┻",
|
||||
TableBorderPart.FooterBottomRight => "┛",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a horizontal border.
|
||||
/// </summary>
|
||||
public sealed class HorizontalTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a horizontal border.
|
||||
/// </summary>
|
||||
public sealed class HorizontalTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "─",
|
||||
TableBorderPart.HeaderTop => "─",
|
||||
TableBorderPart.HeaderTopSeparator => "─",
|
||||
TableBorderPart.HeaderTopRight => "─",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => " ",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => "─",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "─",
|
||||
TableBorderPart.HeaderBottomRight => "─",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => " ",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => "─",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "─",
|
||||
TableBorderPart.FooterTopRight => "─",
|
||||
TableBorderPart.FooterBottomLeft => "─",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "─",
|
||||
TableBorderPart.FooterBottomRight => "─",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "─",
|
||||
TableBorderPart.HeaderTop => "─",
|
||||
TableBorderPart.HeaderTopSeparator => "─",
|
||||
TableBorderPart.HeaderTopRight => "─",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => " ",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => "─",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "─",
|
||||
TableBorderPart.HeaderBottomRight => "─",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => " ",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => "─",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "─",
|
||||
TableBorderPart.FooterTopRight => "─",
|
||||
TableBorderPart.FooterBottomLeft => "─",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "─",
|
||||
TableBorderPart.FooterBottomRight => "─",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -2,112 +2,111 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a Markdown border.
|
||||
/// </summary>
|
||||
public sealed class MarkdownTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Markdown border.
|
||||
/// </summary>
|
||||
public sealed class MarkdownTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "-",
|
||||
TableBorderPart.HeaderBottomSeparator => "|",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => " ",
|
||||
TableBorderPart.FooterTopSeparator => " ",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetColumnRow(TablePart part, IReadOnlyList<int> widths, IReadOnlyList<IColumn> columns)
|
||||
{
|
||||
if (part == TablePart.FooterSeparator)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (part != TablePart.HeaderSeparator)
|
||||
{
|
||||
return base.GetColumnRow(part, widths, columns);
|
||||
}
|
||||
|
||||
var (left, center, separator, right) = GetTableParts(part);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append(left);
|
||||
|
||||
foreach (var (columnIndex, _, lastColumn, columnWidth) in widths.Enumerate())
|
||||
{
|
||||
var padding = columns[columnIndex].Padding;
|
||||
|
||||
if (padding != null && padding.Value.Left > 0)
|
||||
{
|
||||
// Left padding
|
||||
builder.Append(" ".Repeat(padding.Value.Left));
|
||||
}
|
||||
|
||||
var justification = columns[columnIndex].Alignment;
|
||||
if (justification == null)
|
||||
{
|
||||
// No alignment
|
||||
builder.Append(center.Repeat(columnWidth));
|
||||
}
|
||||
else if (justification.Value == Justify.Left)
|
||||
{
|
||||
// Left
|
||||
builder.Append(':');
|
||||
builder.Append(center.Repeat(columnWidth - 1));
|
||||
}
|
||||
else if (justification.Value == Justify.Center)
|
||||
{
|
||||
// Centered
|
||||
builder.Append(':');
|
||||
builder.Append(center.Repeat(columnWidth - 2));
|
||||
builder.Append(':');
|
||||
}
|
||||
else if (justification.Value == Justify.Right)
|
||||
{
|
||||
// Right
|
||||
builder.Append(center.Repeat(columnWidth - 1));
|
||||
builder.Append(':');
|
||||
}
|
||||
|
||||
// Right padding
|
||||
if (padding != null && padding.Value.Right > 0)
|
||||
{
|
||||
builder.Append(" ".Repeat(padding.Value.Right));
|
||||
}
|
||||
|
||||
if (!lastColumn)
|
||||
{
|
||||
builder.Append(separator);
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append(right);
|
||||
return builder.ToString();
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => "|",
|
||||
TableBorderPart.HeaderSeparator => "|",
|
||||
TableBorderPart.HeaderRight => "|",
|
||||
TableBorderPart.HeaderBottomLeft => "|",
|
||||
TableBorderPart.HeaderBottom => "-",
|
||||
TableBorderPart.HeaderBottomSeparator => "|",
|
||||
TableBorderPart.HeaderBottomRight => "|",
|
||||
TableBorderPart.CellLeft => "|",
|
||||
TableBorderPart.CellSeparator => "|",
|
||||
TableBorderPart.CellRight => "|",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => " ",
|
||||
TableBorderPart.FooterTopSeparator => " ",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetColumnRow(TablePart part, IReadOnlyList<int> widths, IReadOnlyList<IColumn> columns)
|
||||
{
|
||||
if (part == TablePart.FooterSeparator)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (part != TablePart.HeaderSeparator)
|
||||
{
|
||||
return base.GetColumnRow(part, widths, columns);
|
||||
}
|
||||
|
||||
var (left, center, separator, right) = GetTableParts(part);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append(left);
|
||||
|
||||
foreach (var (columnIndex, _, lastColumn, columnWidth) in widths.Enumerate())
|
||||
{
|
||||
var padding = columns[columnIndex].Padding;
|
||||
|
||||
if (padding != null && padding.Value.Left > 0)
|
||||
{
|
||||
// Left padding
|
||||
builder.Append(" ".Repeat(padding.Value.Left));
|
||||
}
|
||||
|
||||
var justification = columns[columnIndex].Alignment;
|
||||
if (justification == null)
|
||||
{
|
||||
// No alignment
|
||||
builder.Append(center.Repeat(columnWidth));
|
||||
}
|
||||
else if (justification.Value == Justify.Left)
|
||||
{
|
||||
// Left
|
||||
builder.Append(':');
|
||||
builder.Append(center.Repeat(columnWidth - 1));
|
||||
}
|
||||
else if (justification.Value == Justify.Center)
|
||||
{
|
||||
// Centered
|
||||
builder.Append(':');
|
||||
builder.Append(center.Repeat(columnWidth - 2));
|
||||
builder.Append(':');
|
||||
}
|
||||
else if (justification.Value == Justify.Right)
|
||||
{
|
||||
// Right
|
||||
builder.Append(center.Repeat(columnWidth - 1));
|
||||
builder.Append(':');
|
||||
}
|
||||
|
||||
// Right padding
|
||||
if (padding != null && padding.Value.Right > 0)
|
||||
{
|
||||
builder.Append(" ".Repeat(padding.Value.Right));
|
||||
}
|
||||
|
||||
if (!lastColumn)
|
||||
{
|
||||
builder.Append(separator);
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append(right);
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a minimal border with a double header border.
|
||||
/// </summary>
|
||||
public sealed class MinimalDoubleHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a minimal border with a double header border.
|
||||
/// </summary>
|
||||
public sealed class MinimalDoubleHeadTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => " ",
|
||||
TableBorderPart.HeaderBottom => "═",
|
||||
TableBorderPart.HeaderBottomSeparator => "╪",
|
||||
TableBorderPart.HeaderBottomRight => " ",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => "═",
|
||||
TableBorderPart.FooterTopSeparator => "╪",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => " ",
|
||||
TableBorderPart.HeaderBottom => "═",
|
||||
TableBorderPart.HeaderBottomSeparator => "╪",
|
||||
TableBorderPart.HeaderBottomRight => " ",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => "═",
|
||||
TableBorderPart.FooterTopSeparator => "╪",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a minimal border with a heavy header.
|
||||
/// </summary>
|
||||
public sealed class MinimalHeavyHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Minimal;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a minimal border with a heavy header.
|
||||
/// </summary>
|
||||
public sealed class MinimalHeavyHeadTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Minimal;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => " ",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "┿",
|
||||
TableBorderPart.HeaderBottomRight => " ",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => "━",
|
||||
TableBorderPart.FooterTopSeparator => "┿",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => " ",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "┿",
|
||||
TableBorderPart.HeaderBottomRight => " ",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => "━",
|
||||
TableBorderPart.FooterTopSeparator => "┿",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a minimal border.
|
||||
/// </summary>
|
||||
public sealed class MinimalTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a minimal border.
|
||||
/// </summary>
|
||||
public sealed class MinimalTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => " ",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => " ",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => " ",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => " ",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => " ",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => " ",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an invisible border.
|
||||
/// </summary>
|
||||
public sealed class NoTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool Visible => false;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
/// <summary>
|
||||
/// Represents an invisible border.
|
||||
/// </summary>
|
||||
public sealed class NoTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override bool Visible => false;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a rounded border.
|
||||
/// </summary>
|
||||
public sealed class RoundedTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a rounded border.
|
||||
/// </summary>
|
||||
public sealed class RoundedTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Square;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "╭",
|
||||
TableBorderPart.HeaderTop => "─",
|
||||
TableBorderPart.HeaderTopSeparator => "┬",
|
||||
TableBorderPart.HeaderTopRight => "╮",
|
||||
TableBorderPart.HeaderLeft => "│",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "│",
|
||||
TableBorderPart.HeaderBottomLeft => "├",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "┤",
|
||||
TableBorderPart.CellLeft => "│",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "│",
|
||||
TableBorderPart.FooterTopLeft => "├",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┤",
|
||||
TableBorderPart.FooterBottomLeft => "╰",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "┴",
|
||||
TableBorderPart.FooterBottomRight => "╯",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "╭",
|
||||
TableBorderPart.HeaderTop => "─",
|
||||
TableBorderPart.HeaderTopSeparator => "┬",
|
||||
TableBorderPart.HeaderTopRight => "╮",
|
||||
TableBorderPart.HeaderLeft => "│",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "│",
|
||||
TableBorderPart.HeaderBottomLeft => "├",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "┤",
|
||||
TableBorderPart.CellLeft => "│",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "│",
|
||||
TableBorderPart.FooterTopLeft => "├",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┤",
|
||||
TableBorderPart.FooterBottomLeft => "╰",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "┴",
|
||||
TableBorderPart.FooterBottomRight => "╯",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a simple border with heavy lines.
|
||||
/// </summary>
|
||||
public sealed class SimpleHeavyTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Simple;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
/// <summary>
|
||||
/// Represents a simple border with heavy lines.
|
||||
/// </summary>
|
||||
public sealed class SimpleHeavyTableBorder : TableBorder
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TableBorder? SafeBorder => TableBorder.Simple;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => " ",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => "━",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "━",
|
||||
TableBorderPart.HeaderBottomRight => "━",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => " ",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => "━",
|
||||
TableBorderPart.FooterTop => "━",
|
||||
TableBorderPart.FooterTopSeparator => "━",
|
||||
TableBorderPart.FooterTopRight => "━",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => " ",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => "━",
|
||||
TableBorderPart.HeaderBottom => "━",
|
||||
TableBorderPart.HeaderBottomSeparator => "━",
|
||||
TableBorderPart.HeaderBottomRight => "━",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => " ",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => "━",
|
||||
TableBorderPart.FooterTop => "━",
|
||||
TableBorderPart.FooterTopSeparator => "━",
|
||||
TableBorderPart.FooterTopRight => "━",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a simple border.
|
||||
/// </summary>
|
||||
public sealed class SimpleTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a simple border.
|
||||
/// </summary>
|
||||
public sealed class SimpleTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => " ",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => "─",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "─",
|
||||
TableBorderPart.HeaderBottomRight => "─",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => " ",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => "─",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "─",
|
||||
TableBorderPart.FooterTopRight => "─",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => " ",
|
||||
TableBorderPart.HeaderTop => " ",
|
||||
TableBorderPart.HeaderTopSeparator => " ",
|
||||
TableBorderPart.HeaderTopRight => " ",
|
||||
TableBorderPart.HeaderLeft => " ",
|
||||
TableBorderPart.HeaderSeparator => " ",
|
||||
TableBorderPart.HeaderRight => " ",
|
||||
TableBorderPart.HeaderBottomLeft => "─",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "─",
|
||||
TableBorderPart.HeaderBottomRight => "─",
|
||||
TableBorderPart.CellLeft => " ",
|
||||
TableBorderPart.CellSeparator => " ",
|
||||
TableBorderPart.CellRight => " ",
|
||||
TableBorderPart.FooterTopLeft => "─",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "─",
|
||||
TableBorderPart.FooterTopRight => "─",
|
||||
TableBorderPart.FooterBottomLeft => " ",
|
||||
TableBorderPart.FooterBottom => " ",
|
||||
TableBorderPart.FooterBottomSeparator => " ",
|
||||
TableBorderPart.FooterBottomRight => " ",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +1,40 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a square border.
|
||||
/// </summary>
|
||||
public sealed class SquareTableBorder : TableBorder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a square border.
|
||||
/// </summary>
|
||||
public sealed class SquareTableBorder : TableBorder
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TableBorderPart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TableBorderPart.HeaderTopLeft => "┌",
|
||||
TableBorderPart.HeaderTop => "─",
|
||||
TableBorderPart.HeaderTopSeparator => "┬",
|
||||
TableBorderPart.HeaderTopRight => "┐",
|
||||
TableBorderPart.HeaderLeft => "│",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "│",
|
||||
TableBorderPart.HeaderBottomLeft => "├",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "┤",
|
||||
TableBorderPart.CellLeft => "│",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "│",
|
||||
TableBorderPart.FooterTopLeft => "├",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┤",
|
||||
TableBorderPart.FooterBottomLeft => "└",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "┴",
|
||||
TableBorderPart.FooterBottomRight => "┘",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
TableBorderPart.HeaderTopLeft => "┌",
|
||||
TableBorderPart.HeaderTop => "─",
|
||||
TableBorderPart.HeaderTopSeparator => "┬",
|
||||
TableBorderPart.HeaderTopRight => "┐",
|
||||
TableBorderPart.HeaderLeft => "│",
|
||||
TableBorderPart.HeaderSeparator => "│",
|
||||
TableBorderPart.HeaderRight => "│",
|
||||
TableBorderPart.HeaderBottomLeft => "├",
|
||||
TableBorderPart.HeaderBottom => "─",
|
||||
TableBorderPart.HeaderBottomSeparator => "┼",
|
||||
TableBorderPart.HeaderBottomRight => "┤",
|
||||
TableBorderPart.CellLeft => "│",
|
||||
TableBorderPart.CellSeparator => "│",
|
||||
TableBorderPart.CellRight => "│",
|
||||
TableBorderPart.FooterTopLeft => "├",
|
||||
TableBorderPart.FooterTop => "─",
|
||||
TableBorderPart.FooterTopSeparator => "┼",
|
||||
TableBorderPart.FooterTopRight => "┤",
|
||||
TableBorderPart.FooterBottomLeft => "└",
|
||||
TableBorderPart.FooterBottom => "─",
|
||||
TableBorderPart.FooterBottomSeparator => "┴",
|
||||
TableBorderPart.FooterBottomRight => "┘",
|
||||
_ => throw new InvalidOperationException("Unknown border part."),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a console encoder that can encode
|
||||
/// recorded segments into a string.
|
||||
/// </summary>
|
||||
public interface IAnsiConsoleEncoder
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a console encoder that can encode
|
||||
/// recorded segments into a string.
|
||||
/// Encodes the specified <see cref="IRenderable"/> enumerator.
|
||||
/// </summary>
|
||||
public interface IAnsiConsoleEncoder
|
||||
{
|
||||
/// <summary>
|
||||
/// Encodes the specified <see cref="IRenderable"/> enumerator.
|
||||
/// </summary>
|
||||
/// <param name="console">The console to use when encoding.</param>
|
||||
/// <param name="renderable">The renderable objects to encode.</param>
|
||||
/// <returns>A string representing the encoded result.</returns>
|
||||
string Encode(IAnsiConsole console, IEnumerable<IRenderable> renderable);
|
||||
}
|
||||
}
|
||||
/// <param name="console">The console to use when encoding.</param>
|
||||
/// <param name="renderable">The renderable objects to encode.</param>
|
||||
/// <returns>A string representing the encoded result.</returns>
|
||||
string Encode(IAnsiConsole console, IEnumerable<IRenderable> renderable);
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents something that can be dirty.
|
||||
/// </summary>
|
||||
public interface IHasDirtyState
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents something that can be dirty.
|
||||
/// Gets a value indicating whether the object is dirty.
|
||||
/// </summary>
|
||||
public interface IHasDirtyState
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the object is dirty.
|
||||
/// </summary>
|
||||
bool IsDirty { get; }
|
||||
}
|
||||
}
|
||||
bool IsDirty { get; }
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a render hook.
|
||||
/// </summary>
|
||||
public interface IRenderHook
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a render hook.
|
||||
/// Processes the specified renderables.
|
||||
/// </summary>
|
||||
public interface IRenderHook
|
||||
{
|
||||
/// <summary>
|
||||
/// Processes the specified renderables.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="renderables">The renderables to process.</param>
|
||||
/// <returns>The processed renderables.</returns>
|
||||
IEnumerable<IRenderable> Process(RenderContext context, IEnumerable<IRenderable> renderables);
|
||||
}
|
||||
}
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="renderables">The renderables to process.</param>
|
||||
/// <returns>The processed renderables.</returns>
|
||||
IEnumerable<IRenderable> Process(RenderContext context, IEnumerable<IRenderable> renderables);
|
||||
}
|
@ -1,79 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents something renderable that's reconstructed
|
||||
/// when its state change in any way.
|
||||
/// </summary>
|
||||
public abstract class JustInTimeRenderable : Renderable
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents something renderable that's reconstructed
|
||||
/// when its state change in any way.
|
||||
/// </summary>
|
||||
public abstract class JustInTimeRenderable : Renderable
|
||||
private bool _dirty;
|
||||
private IRenderable? _rendered;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected sealed override Measurement Measure(RenderContext context, int maxWidth)
|
||||
{
|
||||
private bool _dirty;
|
||||
private IRenderable? _rendered;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected sealed override Measurement Measure(RenderContext context, int maxWidth)
|
||||
{
|
||||
return GetInner().Measure(context, maxWidth);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected sealed override IEnumerable<Segment> Render(RenderContext context, int width)
|
||||
{
|
||||
return GetInner().Render(context, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the inner renderable.
|
||||
/// </summary>
|
||||
/// <returns>A new inner renderable.</returns>
|
||||
protected abstract IRenderable Build();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if there are any children that has changed.
|
||||
/// If so, the underlying renderable needs rebuilding.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if the object needs rebuilding, otherwise <c>false</c>.</returns>
|
||||
protected virtual bool HasDirtyChildren()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this instance as dirty.
|
||||
/// </summary>
|
||||
protected void MarkAsDirty()
|
||||
{
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this instance as dirty.
|
||||
/// </summary>
|
||||
/// <param name="action">
|
||||
/// The action to execute before marking the instance as dirty.
|
||||
/// </param>
|
||||
protected void MarkAsDirty(Action action)
|
||||
{
|
||||
if (action is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
action();
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
private IRenderable GetInner()
|
||||
{
|
||||
if (_dirty || HasDirtyChildren() || _rendered == null)
|
||||
{
|
||||
_rendered = Build();
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
return _rendered;
|
||||
}
|
||||
return GetInner().Measure(context, maxWidth);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected sealed override IEnumerable<Segment> Render(RenderContext context, int width)
|
||||
{
|
||||
return GetInner().Render(context, width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the inner renderable.
|
||||
/// </summary>
|
||||
/// <returns>A new inner renderable.</returns>
|
||||
protected abstract IRenderable Build();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if there are any children that has changed.
|
||||
/// If so, the underlying renderable needs rebuilding.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if the object needs rebuilding, otherwise <c>false</c>.</returns>
|
||||
protected virtual bool HasDirtyChildren()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this instance as dirty.
|
||||
/// </summary>
|
||||
protected void MarkAsDirty()
|
||||
{
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks this instance as dirty.
|
||||
/// </summary>
|
||||
/// <param name="action">
|
||||
/// The action to execute before marking the instance as dirty.
|
||||
/// </param>
|
||||
protected void MarkAsDirty(Action action)
|
||||
{
|
||||
if (action is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
action();
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
private IRenderable GetInner()
|
||||
{
|
||||
if (_dirty || HasDirtyChildren() || _rendered == null)
|
||||
{
|
||||
_rendered = Build();
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
return _rendered;
|
||||
}
|
||||
}
|
@ -1,77 +1,76 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a measurement.
|
||||
/// </summary>
|
||||
public struct Measurement : IEquatable<Measurement>
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a measurement.
|
||||
/// Gets the minimum width.
|
||||
/// </summary>
|
||||
public struct Measurement : IEquatable<Measurement>
|
||||
public int Min { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum width.
|
||||
/// </summary>
|
||||
public int Max { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Measurement"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum width.</param>
|
||||
/// <param name="max">The maximum width.</param>
|
||||
public Measurement(int min, int max)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the minimum width.
|
||||
/// </summary>
|
||||
public int Min { get; }
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum width.
|
||||
/// </summary>
|
||||
public int Max { get; }
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Measurement measurement && Equals(measurement);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Measurement"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum width.</param>
|
||||
/// <param name="max">The maximum width.</param>
|
||||
public Measurement(int min, int max)
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Measurement measurement && Equals(measurement);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
var hash = (int)2166136261;
|
||||
hash = (hash * 16777619) ^ Min.GetHashCode();
|
||||
hash = (hash * 16777619) ^ Max.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Measurement other)
|
||||
{
|
||||
return Min == other.Min && Max == other.Max;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Measurement"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first measurement instance to compare.</param>
|
||||
/// <param name="right">The second measurement instance to compare.</param>
|
||||
/// <returns><c>true</c> if the two measurements are equal, otherwise <c>false</c>.</returns>
|
||||
public static bool operator ==(Measurement left, Measurement right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Measurement"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first measurement instance to compare.</param>
|
||||
/// <param name="right">The second measurement instance to compare.</param>
|
||||
/// <returns><c>true</c> if the two measurements are not equal, otherwise <c>false</c>.</returns>
|
||||
public static bool operator !=(Measurement left, Measurement right)
|
||||
{
|
||||
return !(left == right);
|
||||
var hash = (int)2166136261;
|
||||
hash = (hash * 16777619) ^ Min.GetHashCode();
|
||||
hash = (hash * 16777619) ^ Max.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Measurement other)
|
||||
{
|
||||
return Min == other.Min && Max == other.Max;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Measurement"/> instances are equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first measurement instance to compare.</param>
|
||||
/// <param name="right">The second measurement instance to compare.</param>
|
||||
/// <returns><c>true</c> if the two measurements are equal, otherwise <c>false</c>.</returns>
|
||||
public static bool operator ==(Measurement left, Measurement right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Measurement"/> instances are not equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first measurement instance to compare.</param>
|
||||
/// <param name="right">The second measurement instance to compare.</param>
|
||||
/// <returns><c>true</c> if the two measurements are not equal, otherwise <c>false</c>.</returns>
|
||||
public static bool operator !=(Measurement left, Measurement right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
@ -1,81 +1,80 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a render context.
|
||||
/// </summary>
|
||||
public sealed class RenderContext
|
||||
{
|
||||
private readonly IReadOnlyCapabilities _capabilities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a render context.
|
||||
/// Gets the current color system.
|
||||
/// </summary>
|
||||
public sealed class RenderContext
|
||||
public ColorSystem ColorSystem => _capabilities.ColorSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not VT/Ansi codes are supported.
|
||||
/// </summary>
|
||||
public bool Ansi => _capabilities.Ansi;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not unicode is supported.
|
||||
/// </summary>
|
||||
public bool Unicode => _capabilities.Unicode;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current justification.
|
||||
/// </summary>
|
||||
public Justify? Justification { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the context want items to render without
|
||||
/// line breaks and return a single line where applicable.
|
||||
/// </summary>
|
||||
internal bool SingleLine { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RenderContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="capabilities">The capabilities.</param>
|
||||
/// <param name="justification">The justification.</param>
|
||||
public RenderContext(IReadOnlyCapabilities capabilities, Justify? justification = null)
|
||||
: this(capabilities, justification, false)
|
||||
{
|
||||
private readonly IReadOnlyCapabilities _capabilities;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current color system.
|
||||
/// </summary>
|
||||
public ColorSystem ColorSystem => _capabilities.ColorSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not VT/Ansi codes are supported.
|
||||
/// </summary>
|
||||
public bool Ansi => _capabilities.Ansi;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not unicode is supported.
|
||||
/// </summary>
|
||||
public bool Unicode => _capabilities.Unicode;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current justification.
|
||||
/// </summary>
|
||||
public Justify? Justification { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the context want items to render without
|
||||
/// line breaks and return a single line where applicable.
|
||||
/// </summary>
|
||||
internal bool SingleLine { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RenderContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="capabilities">The capabilities.</param>
|
||||
/// <param name="justification">The justification.</param>
|
||||
public RenderContext(IReadOnlyCapabilities capabilities, Justify? justification = null)
|
||||
: this(capabilities, justification, false)
|
||||
{
|
||||
}
|
||||
|
||||
private RenderContext(IReadOnlyCapabilities capabilities, Justify? justification = null, bool singleLine = false)
|
||||
{
|
||||
_capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));
|
||||
|
||||
Justification = justification;
|
||||
SingleLine = singleLine;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context with the specified justification.
|
||||
/// </summary>
|
||||
/// <param name="justification">The justification.</param>
|
||||
/// <returns>A new <see cref="RenderContext"/> instance.</returns>
|
||||
public RenderContext WithJustification(Justify? justification)
|
||||
{
|
||||
return new RenderContext(_capabilities, justification, SingleLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context that tell <see cref="IRenderable"/> instances
|
||||
/// to not care about splitting things in new lines. Whether or not to
|
||||
/// comply to the request is up to the item being rendered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use with care since this has the potential to mess things up.
|
||||
/// Only use this kind of context with items that you know about.
|
||||
/// </remarks>
|
||||
/// <returns>A new <see cref="RenderContext"/> instance.</returns>
|
||||
internal RenderContext WithSingleLine()
|
||||
{
|
||||
return new RenderContext(_capabilities, Justification, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RenderContext(IReadOnlyCapabilities capabilities, Justify? justification = null, bool singleLine = false)
|
||||
{
|
||||
_capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));
|
||||
|
||||
Justification = justification;
|
||||
SingleLine = singleLine;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context with the specified justification.
|
||||
/// </summary>
|
||||
/// <param name="justification">The justification.</param>
|
||||
/// <returns>A new <see cref="RenderContext"/> instance.</returns>
|
||||
public RenderContext WithJustification(Justify? justification)
|
||||
{
|
||||
return new RenderContext(_capabilities, justification, SingleLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new context that tell <see cref="IRenderable"/> instances
|
||||
/// to not care about splitting things in new lines. Whether or not to
|
||||
/// comply to the request is up to the item being rendered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use with care since this has the potential to mess things up.
|
||||
/// Only use this kind of context with items that you know about.
|
||||
/// </remarks>
|
||||
/// <returns>A new <see cref="RenderContext"/> instance.</returns>
|
||||
internal RenderContext WithSingleLine()
|
||||
{
|
||||
return new RenderContext(_capabilities, Justification, true);
|
||||
}
|
||||
}
|
@ -1,32 +1,31 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a render hook scope.
|
||||
/// </summary>
|
||||
public sealed class RenderHookScope : IDisposable
|
||||
{
|
||||
private readonly IAnsiConsole _console;
|
||||
private readonly IRenderHook _hook;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a render hook scope.
|
||||
/// Initializes a new instance of the <see cref="RenderHookScope"/> class.
|
||||
/// </summary>
|
||||
public sealed class RenderHookScope : IDisposable
|
||||
/// <param name="console">The console to attach the render hook to.</param>
|
||||
/// <param name="hook">The render hook.</param>
|
||||
public RenderHookScope(IAnsiConsole console, IRenderHook hook)
|
||||
{
|
||||
private readonly IAnsiConsole _console;
|
||||
private readonly IRenderHook _hook;
|
||||
_console = console ?? throw new ArgumentNullException(nameof(console));
|
||||
_hook = hook ?? throw new ArgumentNullException(nameof(hook));
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RenderHookScope"/> class.
|
||||
/// </summary>
|
||||
/// <param name="console">The console to attach the render hook to.</param>
|
||||
/// <param name="hook">The render hook.</param>
|
||||
public RenderHookScope(IAnsiConsole console, IRenderHook hook)
|
||||
{
|
||||
_console = console ?? throw new ArgumentNullException(nameof(console));
|
||||
_hook = hook ?? throw new ArgumentNullException(nameof(hook));
|
||||
|
||||
_console.Pipeline.Attach(_hook);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
_console.Pipeline.Detach(_hook);
|
||||
}
|
||||
_console.Pipeline.Attach(_hook);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
_console.Pipeline.Detach(_hook);
|
||||
}
|
||||
}
|
@ -1,66 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the render pipeline.
|
||||
/// </summary>
|
||||
public sealed class RenderPipeline
|
||||
{
|
||||
private readonly List<IRenderHook> _hooks;
|
||||
private readonly object _lock;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the render pipeline.
|
||||
/// Initializes a new instance of the <see cref="RenderPipeline"/> class.
|
||||
/// </summary>
|
||||
public sealed class RenderPipeline
|
||||
public RenderPipeline()
|
||||
{
|
||||
private readonly List<IRenderHook> _hooks;
|
||||
private readonly object _lock;
|
||||
_hooks = new List<IRenderHook>();
|
||||
_lock = new object();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RenderPipeline"/> class.
|
||||
/// </summary>
|
||||
public RenderPipeline()
|
||||
/// <summary>
|
||||
/// Attaches a new render hook onto the pipeline.
|
||||
/// </summary>
|
||||
/// <param name="hook">The render hook to attach.</param>
|
||||
public void Attach(IRenderHook hook)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_hooks = new List<IRenderHook>();
|
||||
_lock = new object();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches a new render hook onto the pipeline.
|
||||
/// </summary>
|
||||
/// <param name="hook">The render hook to attach.</param>
|
||||
public void Attach(IRenderHook hook)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_hooks.Add(hook);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches a render hook from the pipeline.
|
||||
/// </summary>
|
||||
/// <param name="hook">The render hook to detach.</param>
|
||||
public void Detach(IRenderHook hook)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_hooks.Remove(hook);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the specified renderables.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="renderables">The renderables to process.</param>
|
||||
/// <returns>The processed renderables.</returns>
|
||||
public IEnumerable<IRenderable> Process(RenderContext context, IEnumerable<IRenderable> renderables)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
var current = renderables;
|
||||
for (var index = _hooks.Count - 1; index >= 0; index--)
|
||||
{
|
||||
current = _hooks[index].Process(context, current);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
_hooks.Add(hook);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches a render hook from the pipeline.
|
||||
/// </summary>
|
||||
/// <param name="hook">The render hook to detach.</param>
|
||||
public void Detach(IRenderHook hook)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_hooks.Remove(hook);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the specified renderables.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="renderables">The renderables to process.</param>
|
||||
/// <returns>The processed renderables.</returns>
|
||||
public IEnumerable<IRenderable> Process(RenderContext context, IEnumerable<IRenderable> renderables)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
var current = renderables;
|
||||
for (var index = _hooks.Count - 1; index >= 0; index--)
|
||||
{
|
||||
current = _hooks[index].Process(context, current);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,44 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for a renderable object implementing <see cref="IRenderable"/>.
|
||||
/// </summary>
|
||||
public abstract class Renderable : IRenderable
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for a renderable object implementing <see cref="IRenderable"/>.
|
||||
/// </summary>
|
||||
public abstract class Renderable : IRenderable
|
||||
/// <inheritdoc/>
|
||||
[DebuggerStepThrough]
|
||||
Measurement IRenderable.Measure(RenderContext context, int maxWidth)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
[DebuggerStepThrough]
|
||||
Measurement IRenderable.Measure(RenderContext context, int maxWidth)
|
||||
{
|
||||
return Measure(context, maxWidth);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DebuggerStepThrough]
|
||||
IEnumerable<Segment> IRenderable.Render(RenderContext context, int maxWidth)
|
||||
{
|
||||
return Render(context, maxWidth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures the renderable object.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="maxWidth">The maximum allowed width.</param>
|
||||
/// <returns>The minimum and maximum width of the object.</returns>
|
||||
protected virtual Measurement Measure(RenderContext context, int maxWidth)
|
||||
{
|
||||
return new Measurement(maxWidth, maxWidth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the object.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="maxWidth">The maximum allowed width.</param>
|
||||
/// <returns>A collection of segments.</returns>
|
||||
protected abstract IEnumerable<Segment> Render(RenderContext context, int maxWidth);
|
||||
return Measure(context, maxWidth);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DebuggerStepThrough]
|
||||
IEnumerable<Segment> IRenderable.Render(RenderContext context, int maxWidth)
|
||||
{
|
||||
return Render(context, maxWidth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures the renderable object.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="maxWidth">The maximum allowed width.</param>
|
||||
/// <returns>The minimum and maximum width of the object.</returns>
|
||||
protected virtual Measurement Measure(RenderContext context, int maxWidth)
|
||||
{
|
||||
return new Measurement(maxWidth, maxWidth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the object.
|
||||
/// </summary>
|
||||
/// <param name="context">The render context.</param>
|
||||
/// <param name="maxWidth">The maximum allowed width.</param>
|
||||
/// <returns>A collection of segments.</returns>
|
||||
protected abstract IEnumerable<Segment> Render(RenderContext context, int maxWidth);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,55 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of segments.
|
||||
/// </summary>
|
||||
public sealed class SegmentLine : List<Segment>
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of segments.
|
||||
/// Gets the width of the line.
|
||||
/// </summary>
|
||||
public sealed class SegmentLine : List<Segment>
|
||||
public int Length => this.Sum(line => line.Text.Length);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLine"/> class.
|
||||
/// </summary>
|
||||
public SegmentLine()
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the width of the line.
|
||||
/// </summary>
|
||||
public int Length => this.Sum(line => line.Text.Length);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLine"/> class.
|
||||
/// </summary>
|
||||
public SegmentLine()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLine"/> class.
|
||||
/// </summary>
|
||||
/// <param name="segments">The segments.</param>
|
||||
public SegmentLine(IEnumerable<Segment> segments)
|
||||
: base(segments)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of cells the segment line occupies.
|
||||
/// </summary>
|
||||
/// <returns>The cell width of the segment line.</returns>
|
||||
public int CellCount()
|
||||
{
|
||||
return Segment.CellCount(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preprends a segment to the line.
|
||||
/// </summary>
|
||||
/// <param name="segment">The segment to prepend.</param>
|
||||
public void Prepend(Segment segment)
|
||||
{
|
||||
if (segment is null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(segment));
|
||||
}
|
||||
|
||||
Insert(0, segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLine"/> class.
|
||||
/// </summary>
|
||||
/// <param name="segments">The segments.</param>
|
||||
public SegmentLine(IEnumerable<Segment> segments)
|
||||
: base(segments)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of cells the segment line occupies.
|
||||
/// </summary>
|
||||
/// <returns>The cell width of the segment line.</returns>
|
||||
public int CellCount()
|
||||
{
|
||||
return Segment.CellCount(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preprends a segment to the line.
|
||||
/// </summary>
|
||||
/// <param name="segment">The segment to prepend.</param>
|
||||
public void Prepend(Segment segment)
|
||||
{
|
||||
if (segment is null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(segment));
|
||||
}
|
||||
|
||||
Insert(0, segment);
|
||||
}
|
||||
}
|
@ -1,39 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// An enumerator for <see cref="SegmentLine"/> collections.
|
||||
/// </summary>
|
||||
public sealed class SegmentLineEnumerator : IEnumerable<Segment>
|
||||
{
|
||||
private readonly List<SegmentLine> _lines;
|
||||
|
||||
/// <summary>
|
||||
/// An enumerator for <see cref="SegmentLine"/> collections.
|
||||
/// Initializes a new instance of the <see cref="SegmentLineEnumerator"/> class.
|
||||
/// </summary>
|
||||
public sealed class SegmentLineEnumerator : IEnumerable<Segment>
|
||||
/// <param name="lines">The lines to enumerate.</param>
|
||||
public SegmentLineEnumerator(IEnumerable<SegmentLine> lines)
|
||||
{
|
||||
private readonly List<SegmentLine> _lines;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLineEnumerator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="lines">The lines to enumerate.</param>
|
||||
public SegmentLineEnumerator(IEnumerable<SegmentLine> lines)
|
||||
if (lines is null)
|
||||
{
|
||||
if (lines is null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(lines));
|
||||
}
|
||||
|
||||
_lines = new List<SegmentLine>(lines);
|
||||
throw new System.ArgumentNullException(nameof(lines));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerator<Segment> GetEnumerator()
|
||||
{
|
||||
return new SegmentLineIterator(_lines);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
_lines = new List<SegmentLine>(lines);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerator<Segment> GetEnumerator()
|
||||
{
|
||||
return new SegmentLineIterator(_lines);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
@ -1,119 +1,118 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// An iterator for <see cref="SegmentLine"/> collections.
|
||||
/// </summary>
|
||||
public sealed class SegmentLineIterator : IEnumerator<Segment>
|
||||
{
|
||||
private readonly List<SegmentLine> _lines;
|
||||
private int _currentLine;
|
||||
private int _currentIndex;
|
||||
private bool _lineBreakEmitted;
|
||||
|
||||
/// <summary>
|
||||
/// An iterator for <see cref="SegmentLine"/> collections.
|
||||
/// Gets the current segment.
|
||||
/// </summary>
|
||||
public sealed class SegmentLineIterator : IEnumerator<Segment>
|
||||
public Segment Current { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
object? IEnumerator.Current => Current;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLineIterator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="lines">The lines to iterate.</param>
|
||||
public SegmentLineIterator(IEnumerable<SegmentLine> lines)
|
||||
{
|
||||
private readonly List<SegmentLine> _lines;
|
||||
private int _currentLine;
|
||||
private int _currentIndex;
|
||||
private bool _lineBreakEmitted;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current segment.
|
||||
/// </summary>
|
||||
public Segment Current { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
object? IEnumerator.Current => Current;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SegmentLineIterator"/> class.
|
||||
/// </summary>
|
||||
/// <param name="lines">The lines to iterate.</param>
|
||||
public SegmentLineIterator(IEnumerable<SegmentLine> lines)
|
||||
if (lines is null)
|
||||
{
|
||||
if (lines is null)
|
||||
throw new System.ArgumentNullException(nameof(lines));
|
||||
}
|
||||
|
||||
_currentLine = 0;
|
||||
_currentIndex = -1;
|
||||
_lines = new List<SegmentLine>(lines);
|
||||
|
||||
Current = Segment.Empty;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (_currentLine > _lines.Count - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_currentIndex++;
|
||||
|
||||
// Did we go past the end of the line?
|
||||
if (_currentIndex > _lines[_currentLine].Count - 1)
|
||||
{
|
||||
// We haven't just emitted a line break?
|
||||
if (!_lineBreakEmitted)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(lines));
|
||||
// Got any more lines?
|
||||
if (_currentIndex + 1 > _lines[_currentLine].Count - 1)
|
||||
{
|
||||
// Only emit a line break if the next one isn't a line break.
|
||||
if ((_currentLine + 1 <= _lines.Count - 1)
|
||||
&& _lines[_currentLine + 1].Count > 0
|
||||
&& !_lines[_currentLine + 1][0].IsLineBreak)
|
||||
{
|
||||
_lineBreakEmitted = true;
|
||||
Current = Segment.LineBreak;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_currentLine = 0;
|
||||
_currentIndex = -1;
|
||||
_lines = new List<SegmentLine>(lines);
|
||||
// Increase the line and reset the index.
|
||||
_currentLine++;
|
||||
_currentIndex = 0;
|
||||
|
||||
Current = Segment.Empty;
|
||||
}
|
||||
_lineBreakEmitted = false;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool MoveNext()
|
||||
{
|
||||
// No more lines?
|
||||
if (_currentLine > _lines.Count - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_currentIndex++;
|
||||
|
||||
// Did we go past the end of the line?
|
||||
if (_currentIndex > _lines[_currentLine].Count - 1)
|
||||
// Nothing on the line?
|
||||
while (_currentIndex > _lines[_currentLine].Count - 1)
|
||||
{
|
||||
// We haven't just emitted a line break?
|
||||
if (!_lineBreakEmitted)
|
||||
{
|
||||
// Got any more lines?
|
||||
if (_currentIndex + 1 > _lines[_currentLine].Count - 1)
|
||||
{
|
||||
// Only emit a line break if the next one isn't a line break.
|
||||
if ((_currentLine + 1 <= _lines.Count - 1)
|
||||
&& _lines[_currentLine + 1].Count > 0
|
||||
&& !_lines[_currentLine + 1][0].IsLineBreak)
|
||||
{
|
||||
_lineBreakEmitted = true;
|
||||
Current = Segment.LineBreak;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Increase the line and reset the index.
|
||||
_currentLine++;
|
||||
_currentIndex = 0;
|
||||
|
||||
_lineBreakEmitted = false;
|
||||
|
||||
// No more lines?
|
||||
if (_currentLine > _lines.Count - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Nothing on the line?
|
||||
while (_currentIndex > _lines[_currentLine].Count - 1)
|
||||
{
|
||||
_currentLine++;
|
||||
_currentIndex = 0;
|
||||
|
||||
if (_currentLine > _lines.Count - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the flag
|
||||
_lineBreakEmitted = false;
|
||||
|
||||
Current = _lines[_currentLine][_currentIndex];
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Reset()
|
||||
{
|
||||
_currentLine = 0;
|
||||
_currentIndex = -1;
|
||||
// Reset the flag
|
||||
_lineBreakEmitted = false;
|
||||
|
||||
Current = Segment.Empty;
|
||||
}
|
||||
Current = _lines[_currentLine][_currentIndex];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Reset()
|
||||
{
|
||||
_currentLine = 0;
|
||||
_currentIndex = -1;
|
||||
|
||||
Current = Segment.Empty;
|
||||
}
|
||||
}
|
@ -2,67 +2,66 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
internal readonly struct SegmentShape
|
||||
{
|
||||
internal readonly struct SegmentShape
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
|
||||
public SegmentShape(int width, int height)
|
||||
{
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public SegmentShape(int width, int height)
|
||||
public static SegmentShape Calculate(RenderContext context, List<SegmentLine> lines)
|
||||
{
|
||||
if (context is null)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
public static SegmentShape Calculate(RenderContext context, List<SegmentLine> lines)
|
||||
if (lines is null)
|
||||
{
|
||||
if (context is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
if (lines is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(lines));
|
||||
}
|
||||
|
||||
var height = lines.Count;
|
||||
var width = lines.Max(l => Segment.CellCount(l));
|
||||
|
||||
return new SegmentShape(width, height);
|
||||
throw new ArgumentNullException(nameof(lines));
|
||||
}
|
||||
|
||||
public SegmentShape Inflate(SegmentShape other)
|
||||
var height = lines.Count;
|
||||
var width = lines.Max(l => Segment.CellCount(l));
|
||||
|
||||
return new SegmentShape(width, height);
|
||||
}
|
||||
|
||||
public SegmentShape Inflate(SegmentShape other)
|
||||
{
|
||||
return new SegmentShape(
|
||||
Math.Max(Width, other.Width),
|
||||
Math.Max(Height, other.Height));
|
||||
}
|
||||
|
||||
public void Apply(RenderContext context, ref List<SegmentLine> lines)
|
||||
{
|
||||
foreach (var line in lines)
|
||||
{
|
||||
return new SegmentShape(
|
||||
Math.Max(Width, other.Width),
|
||||
Math.Max(Height, other.Height));
|
||||
var length = Segment.CellCount(line);
|
||||
var missing = Width - length;
|
||||
if (missing > 0)
|
||||
{
|
||||
line.Add(Segment.Padding(missing));
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(RenderContext context, ref List<SegmentLine> lines)
|
||||
if (lines.Count < Height && Width > 0)
|
||||
{
|
||||
foreach (var line in lines)
|
||||
var missing = Height - lines.Count;
|
||||
for (var i = 0; i < missing; i++)
|
||||
{
|
||||
var length = Segment.CellCount(line);
|
||||
var missing = Width - length;
|
||||
if (missing > 0)
|
||||
{
|
||||
line.Add(Segment.Padding(missing));
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.Count < Height && Width > 0)
|
||||
{
|
||||
var missing = Height - lines.Count;
|
||||
for (var i = 0; i < missing; i++)
|
||||
{
|
||||
lines.Add(new SegmentLine
|
||||
lines.Add(new SegmentLine
|
||||
{
|
||||
Segment.Padding(Width),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +1,27 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Represents different parts of a table.
|
||||
/// </summary>
|
||||
public enum TablePart
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents different parts of a table.
|
||||
/// The top of a table.
|
||||
/// </summary>
|
||||
public enum TablePart
|
||||
{
|
||||
/// <summary>
|
||||
/// The top of a table.
|
||||
/// </summary>
|
||||
Top,
|
||||
Top,
|
||||
|
||||
/// <summary>
|
||||
/// The separator between the header and the cells.
|
||||
/// </summary>
|
||||
HeaderSeparator,
|
||||
/// <summary>
|
||||
/// The separator between the header and the cells.
|
||||
/// </summary>
|
||||
HeaderSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The separator between the footer and the cells.
|
||||
/// </summary>
|
||||
FooterSeparator,
|
||||
/// <summary>
|
||||
/// The separator between the footer and the cells.
|
||||
/// </summary>
|
||||
FooterSeparator,
|
||||
|
||||
/// <summary>
|
||||
/// The bottom of a table.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The bottom of a table.
|
||||
/// </summary>
|
||||
Bottom,
|
||||
}
|
@ -1,23 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// An ASCII tree guide.
|
||||
/// </summary>
|
||||
public sealed class AsciiTreeGuide : TreeGuide
|
||||
{
|
||||
/// <summary>
|
||||
/// An ASCII tree guide.
|
||||
/// </summary>
|
||||
public sealed class AsciiTreeGuide : TreeGuide
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "| ",
|
||||
TreeGuidePart.Fork => "|-- ",
|
||||
TreeGuidePart.End => "`-- ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "| ",
|
||||
TreeGuidePart.Fork => "|-- ",
|
||||
TreeGuidePart.End => "`-- ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
}
|
@ -1,26 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// A tree guide made up of bold lines.
|
||||
/// </summary>
|
||||
public sealed class BoldLineTreeGuide : TreeGuide
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TreeGuide? SafeTreeGuide => Ascii;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
/// <summary>
|
||||
/// A tree guide made up of bold lines.
|
||||
/// </summary>
|
||||
public sealed class BoldLineTreeGuide : TreeGuide
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TreeGuide? SafeTreeGuide => Ascii;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "┃ ",
|
||||
TreeGuidePart.Fork => "┣━━ ",
|
||||
TreeGuidePart.End => "┗━━ ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "┃ ",
|
||||
TreeGuidePart.Fork => "┣━━ ",
|
||||
TreeGuidePart.End => "┗━━ ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
}
|
@ -1,26 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// A tree guide made up of double lines.
|
||||
/// </summary>
|
||||
public sealed class DoubleLineTreeGuide : TreeGuide
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TreeGuide? SafeTreeGuide => Ascii;
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
/// <summary>
|
||||
/// A tree guide made up of double lines.
|
||||
/// </summary>
|
||||
public sealed class DoubleLineTreeGuide : TreeGuide
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override TreeGuide? SafeTreeGuide => Ascii;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "║ ",
|
||||
TreeGuidePart.Fork => "╠══ ",
|
||||
TreeGuidePart.End => "╚══ ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "║ ",
|
||||
TreeGuidePart.Fork => "╠══ ",
|
||||
TreeGuidePart.End => "╚══ ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
}
|
@ -1,23 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// A tree guide made up of lines.
|
||||
/// </summary>
|
||||
public sealed class LineTreeGuide : TreeGuide
|
||||
{
|
||||
/// <summary>
|
||||
/// A tree guide made up of lines.
|
||||
/// </summary>
|
||||
public sealed class LineTreeGuide : TreeGuide
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreeGuidePart part)
|
||||
return part switch
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "│ ",
|
||||
TreeGuidePart.Fork => "├── ",
|
||||
TreeGuidePart.End => "└── ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
TreeGuidePart.Space => " ",
|
||||
TreeGuidePart.Continue => "│ ",
|
||||
TreeGuidePart.Fork => "├── ",
|
||||
TreeGuidePart.End => "└── ",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
}
|
@ -1,28 +1,27 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
namespace Spectre.Console.Rendering;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the different rendering parts of a <see cref="Tree"/>.
|
||||
/// </summary>
|
||||
public enum TreeGuidePart
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the different rendering parts of a <see cref="Tree"/>.
|
||||
/// Represents a space.
|
||||
/// </summary>
|
||||
public enum TreeGuidePart
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a space.
|
||||
/// </summary>
|
||||
Space,
|
||||
Space,
|
||||
|
||||
/// <summary>
|
||||
/// Connection between siblings.
|
||||
/// </summary>
|
||||
Continue,
|
||||
/// <summary>
|
||||
/// Connection between siblings.
|
||||
/// </summary>
|
||||
Continue,
|
||||
|
||||
/// <summary>
|
||||
/// Branch from parent to child.
|
||||
/// </summary>
|
||||
Fork,
|
||||
/// <summary>
|
||||
/// Branch from parent to child.
|
||||
/// </summary>
|
||||
Fork,
|
||||
|
||||
/// <summary>
|
||||
/// Branch from parent to child for the last child in a set.
|
||||
/// </summary>
|
||||
End,
|
||||
}
|
||||
/// <summary>
|
||||
/// Branch from parent to child for the last child in a set.
|
||||
/// </summary>
|
||||
End,
|
||||
}
|
Reference in New Issue
Block a user