namespace Spectre.Console; /// /// Contains extension methods for . /// public static class RenderableExtensions { /// /// Gets the segments for a renderable using the specified console. /// /// The renderable. /// The console. /// An enumerable containing segments representing the specified . public static IEnumerable GetSegments(this IRenderable renderable, IAnsiConsole console) { if (console is null) { throw new ArgumentNullException(nameof(console)); } if (renderable is null) { throw new ArgumentNullException(nameof(renderable)); } var context = RenderOptions.Create(console, console.Profile.Capabilities); var renderables = console.Pipeline.Process(context, new[] { renderable }); return GetSegments(console, context, renderables); } private static IEnumerable GetSegments(IAnsiConsole console, RenderOptions options, IEnumerable renderables) { var result = new List(); foreach (var renderable in renderables) { result.AddRange(renderable.Render(options, console.Profile.Width)); } return Segment.Merge(result); } }