Add word wrapping for text

Closes #18
This commit is contained in:
Patrik Svensson
2020-08-13 21:12:45 +02:00
committed by Patrik Svensson
parent 0119364728
commit d7bbaf4a85
31 changed files with 646 additions and 643 deletions

View File

@@ -28,17 +28,24 @@ namespace Spectre.Console
var options = new RenderContext(console.Encoding, console.Capabilities.LegacyConsole);
foreach (var segment in renderable.Render(options, console.Width))
using (console.PushStyle(Style.Plain))
{
if (!segment.Style.Equals(Style.Plain))
var current = Style.Plain;
foreach (var segment in renderable.Render(options, console.Width))
{
using (var style = console.PushStyle(segment.Style))
if (string.IsNullOrEmpty(segment.Text))
{
console.Write(segment.Text);
continue;
}
}
else
{
if (!segment.Style.Equals(current))
{
console.Foreground = segment.Style.Foreground;
console.Background = segment.Style.Background;
console.Decoration = segment.Style.Decoration;
current = segment.Style;
}
console.Write(segment.Text);
}
}