Skip to content
ConsoleMonster
Class

RenderContext

ConsoleMonster.Canvas

Namespace
ConsoleMonster.Canvas
Assembly
ConsoleMonster
Modifiers
sealed

Everything a widget needs besides its own state: the terminal profile, the theme, the glyph set and the animation clock. Resolved theme styles and parsed markup are cached per context.

Inheritance

  • object
  • RenderContext

Usage

Explore 288 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 280

Constructors

public RenderContext(TerminalProfile profile, ITheme theme, IGlyphSet? glyphs = null, long tick = 0, TimeSpan elapsed = default) #

Creates a context.

Parameters

profile ConsoleMonster.Capabilities.TerminalProfile required
The terminal profile.
theme ConsoleMonster.Styling.ITheme required
The theme.
glyphs ConsoleMonster.Glyphs.IGlyphSet? = null optional
The glyph set; defaults to the built-in set for the profile's tier.
tick long = 0 optional
Animation frame counter (spinners advance with it).
elapsed System.TimeSpan = default optional
Time since the session started (for clocks).

Methods

public StyledText Markup(string markup) #

Parses markup with this context's theme, colour depth and glyph repertoire (cached). Where the output cannot carry a hyperlink, a link whose text differs from its target is followed by the target, as text (url).

Parameters

markup string required
The markup.

Returns

StyledText The styled text.
public Style Series(int index) #

Returns the chart series style for an index (wraps after six).

Parameters

index int required
Zero-based series index.

Returns

Style The style.
Style 2 overloads
public Style Style(ThemeToken token) #

Returns the resolved style of a theme token.

Parameters

token ConsoleMonster.Styling.ThemeToken required
The token.

Returns

Style The style for the current colour depth.
public Style Style(StatusKind status) #

Returns the style for a status.

Parameters

status ConsoleMonster.Styling.StatusKind required
The status.

Returns

Style The style.
public RenderContext WithClock(long tick, TimeSpan elapsed) #

Returns a context for the next animation frame, keeping the caches.

Parameters

tick long required
The new tick.
elapsed System.TimeSpan required
The new elapsed time.

Returns

RenderContext A context sharing profile, theme and glyphs.

Properties

public TerminalProfile Profile { get; } #

The terminal profile.

public ITheme Theme { get; } #

The theme.

public IGlyphSet Glyphs { get; } #

The glyph set.

public ThemeDensity Density { get; } #

The profile's spacing override, or the theme's density.

public ColorDepth Depth { get; } #

The colour depth being rendered.

public bool HasColor { get; } #

Whether any colour is available.

public CultureInfo Culture { get; } #

The culture for numbers and dates: TerminalProfile.Culture, or the current culture when that is null.

public WidgetLabels Labels { get; } #

The built-in widget words for TerminalProfile.Language (or the default language).

public long Tick { get; } #

Animation frame counter.

public bool ReducedMotion { get; } #

Whether animated glyphs and motion must remain static.

public TimeSpan Elapsed { get; } #

Time since the session started.

public string Ellipsis { get; } #

The ellipsis for this glyph tier.

Extension Methods

public static string Spinner(RenderContext context, long offset = 0) #

The running symbol for this frame: the tier's spinner, advanced by the session's tick (offset so neighbouring rows do not spin in step), or the static running glyph when the tier has no spinner. Every widget that shows running work (lanes, phases, status lists, activities, spinners) uses this one.

Parameters

context ConsoleMonster.Canvas.RenderContext required
The render context.
offset long = 0 optional
A per-row offset.

Returns

string The symbol.