Table of Contents

Interface IConsoleShellFrame

Namespace
RDCore.SDK.ConsoleIO
Assembly
RDCore.SDK.dll

Owns the console's frame: the background and foreground the whole shell is painted on, for as long as the process owns the terminal.

public interface IConsoleShellFrame

Remarks

Setting BackgroundColor and clearing is not enough on its own. Every renderer that emits SGR sequences — Spectre.Console among them — ends a styled span with a reset (ESC[0m), which returns the cell colours to the terminal's defaults, not to whatever BackgroundColor currently holds; .NET will not re-emit an attribute it believes is already set, so from the first styled write onwards the frame is silently gone, and every line that scrolls in afterwards is painted in the terminal's own background. Changing the terminal's default colours instead (OSC 10/OSC 11) makes the reset land back on the frame's colours, so the shell stays one solid colour through styled output, scrolling and screen clears alike.

A terminal that cannot do this gets the nearest-16 ConsoleColor frame instead, which is what the frame did before; Restore() puts the terminal back the way it was found, and must run before the process exits.

Properties

IsAnsiEnabled

Whether the console accepts ANSI escape sequences — false when output is redirected or the terminal could not be switched into virtual-terminal mode. The frame degrades to the legacy 16-colour console attributes when this is false.

bool IsAnsiEnabled { get; }

Property Value

bool

Methods

Apply(ConsoleRgbColor, ConsoleRgbColor)

Paints the frame: makes background/foreground the console's default colours and clears the screen.

void Apply(ConsoleRgbColor background, ConsoleRgbColor foreground)

Parameters

background ConsoleRgbColor

The shell background.

foreground ConsoleRgbColor

The shell foreground.

Restore()

Restores the console colours this frame replaced. Safe to call more than once, and a no-op if Apply(ConsoleRgbColor, ConsoleRgbColor) never ran.

void Restore()

WriteArt(string, ConsoleRgbColor)

Writes pre-formatted art (a splash banner, a program listing) one line at a time in color, without any layout, wrapping or re-flowing, and fills the rest of each line with the frame's background so a short line does not leave a differently-coloured tail behind.

void WriteArt(string art, ConsoleRgbColor color)

Parameters

art string

The pre-formatted text; every line is written as-is.

color ConsoleRgbColor

The foreground colour to write it in.