mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-06 04:28:15 +08:00
Change IAnsiConsole to render IRenderable
This makes it possible for encoders to output better representation of the actual objects instead of working with chopped up segments. * IAnsiConsole.Write now takes an IRenderable instead of segments * Calculating cell width does no longer require a render context * Removed RenderContext.LegacyConsole * Removed RenderContext.Encoding * Added Capabilities.Unicode
This commit is contained in:

committed by
Phil Scott

parent
2ba6da3514
commit
20650f1e7e
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Spectre.Console.Rendering;
|
||||
|
||||
@ -42,6 +41,7 @@ namespace Spectre.Console.Testing
|
||||
});
|
||||
|
||||
_console.Profile.Width = width;
|
||||
_console.Profile.Capabilities.Unicode = true;
|
||||
|
||||
Input = new FakeConsoleInput();
|
||||
}
|
||||
@ -56,17 +56,9 @@ namespace Spectre.Console.Testing
|
||||
_console.Clear(home);
|
||||
}
|
||||
|
||||
public void Write(IEnumerable<Segment> segments)
|
||||
public void Write(IRenderable renderable)
|
||||
{
|
||||
if (segments is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
_console.Write(segment);
|
||||
}
|
||||
_console.Write(renderable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
src/Spectre.Console.Testing/Fakes/FakeCapabilities.cs
Normal file
17
src/Spectre.Console.Testing/Fakes/FakeCapabilities.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Spectre.Console.Testing
|
||||
{
|
||||
public sealed class FakeCapabilities : IReadOnlyCapabilities
|
||||
{
|
||||
public bool Ansi { get; set; }
|
||||
|
||||
public bool Links { get; set; }
|
||||
|
||||
public bool Legacy { get; set; }
|
||||
|
||||
public bool Tty { get; set; }
|
||||
|
||||
public bool Interactive { get; set; }
|
||||
|
||||
public bool Unicode { get; set; }
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ namespace Spectre.Console.Testing
|
||||
Profile.Capabilities.Legacy = legacyConsole;
|
||||
Profile.Capabilities.Interactive = interactive;
|
||||
Profile.Capabilities.Links = true;
|
||||
Profile.Capabilities.Unicode = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -47,14 +48,9 @@ namespace Spectre.Console.Testing
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(IEnumerable<Segment> segments)
|
||||
public void Write(IRenderable renderable)
|
||||
{
|
||||
if (segments is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var segment in segments)
|
||||
foreach (var segment in renderable.GetSegments(this))
|
||||
{
|
||||
Profile.Out.Write(segment.Text);
|
||||
}
|
||||
|
Reference in New Issue
Block a user