mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2026-01-02 01:03:32 +01:00
36 lines
1004 B
C#
36 lines
1004 B
C#
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Spectre.Console.Internal
|
|
{
|
|
[SuppressMessage("Performance", "CA1812:Avoid uninstantiated internal classes", Justification = "Not used (yet)")]
|
|
internal sealed class ForegroundElement : IRenderable
|
|
{
|
|
private readonly Color _color;
|
|
private readonly IRenderable _element;
|
|
|
|
/// <inheritdoc/>
|
|
public int Length => _element.Length;
|
|
|
|
public ForegroundElement(Color color, IRenderable element)
|
|
{
|
|
_color = color;
|
|
_element = element ?? throw new ArgumentNullException(nameof(element));
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void Render(IAnsiConsole renderer)
|
|
{
|
|
if (renderer is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(renderer));
|
|
}
|
|
|
|
using (renderer.PushColor(_color, foreground: true))
|
|
{
|
|
_element.Render(renderer);
|
|
}
|
|
}
|
|
}
|
|
}
|