mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add support for rendering exceptions
This commit is contained in:

committed by
Patrik Svensson

parent
971f9032ba
commit
3c3afe7439
@ -94,8 +94,15 @@ namespace Spectre.Console
|
||||
|
||||
// Split the child segments into lines.
|
||||
var childSegments = ((IRenderable)child).Render(context, childWidth);
|
||||
foreach (var line in Segment.SplitLines(childSegments, panelWidth))
|
||||
foreach (var line in Segment.SplitLines(childSegments, childWidth))
|
||||
{
|
||||
if (line.Count == 1 && line[0].IsWhiteSpace)
|
||||
{
|
||||
// NOTE: This check might impact other things.
|
||||
// Hopefully not, but there is a chance.
|
||||
continue;
|
||||
}
|
||||
|
||||
result.Add(new Segment(border.GetPart(BoxBorderPart.Left), borderStyle));
|
||||
|
||||
var content = new List<Segment>();
|
||||
|
@ -227,17 +227,10 @@ namespace Spectre.Console
|
||||
throw new InvalidOperationException("Iterator returned empty segment.");
|
||||
}
|
||||
|
||||
if (newLine && current.IsWhiteSpace && !current.IsLineBreak)
|
||||
{
|
||||
newLine = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
newLine = false;
|
||||
|
||||
if (current.IsLineBreak)
|
||||
{
|
||||
line.Add(current);
|
||||
lines.Add(line);
|
||||
line = new SegmentLine();
|
||||
newLine = true;
|
||||
|
@ -44,22 +44,26 @@ namespace Spectre.Console
|
||||
/// <inheritdoc/>
|
||||
protected override IEnumerable<Segment> Render(RenderContext context, int maxWidth)
|
||||
{
|
||||
var result = new List<Segment>();
|
||||
|
||||
foreach (var child in _children)
|
||||
{
|
||||
var segments = child.Render(context, maxWidth);
|
||||
foreach (var (_, _, last, segment) in segments.Enumerate())
|
||||
{
|
||||
yield return segment;
|
||||
result.Add(segment);
|
||||
|
||||
if (last)
|
||||
{
|
||||
if (!segment.IsLineBreak)
|
||||
{
|
||||
yield return Segment.LineBreak;
|
||||
result.Add(Segment.LineBreak);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,6 @@ namespace Spectre.Console
|
||||
var widths = width_ranges.Select(range => range.Max).ToList();
|
||||
|
||||
var tableWidth = widths.Sum();
|
||||
|
||||
if (tableWidth > maxWidth)
|
||||
{
|
||||
var wrappable = _columns.Select(c => !c.NoWrap).ToList();
|
||||
|
Reference in New Issue
Block a user