Skip to content
ConsoleMonster
Interface

IWidget

ConsoleMonster.Layout

Namespace
ConsoleMonster.Layout
Assembly
ConsoleMonster
Modifiers
abstract
Attributes
Fluent

The widget contract. A widget is a pure function of its definition, its state, the capabilities and the theme: the same inputs always produce the same cells. Implement it to get theming, glyph tiers, layout, live updates and every output mode for free.

Usage

Explore 310 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.

Returned or exposed by 106

Accepted by parameters 204

Methods

public abstract Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public abstract void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Extension Methods

CreateSession 2 overloads
public static LiveSession CreateSession(IWidget widget, LiveSessionOptions? options = null) #

Creates an owned live-session lifetime over a configured widget; dispose it after running.

Parameters

widget ConsoleMonster.Layout.IWidget required
The session root.
options ConsoleMonster.Live.LiveSessionOptions? = null optional
The session options.

Returns

LiveSession The new session.
public static LiveSession CreateSession(IWidget widget, Action<LiveSessionOptions> configure) #

Creates a session with freshly configured options.

Parameters

widget ConsoleMonster.Layout.IWidget required
The root.
configure System.Action<ConsoleMonster.Live.LiveSessionOptions> required
Session settings.

Returns

LiveSession The owned session.
public static Sized Fill(IWidget widget, double weight = 1) #

Lets the widget take a share of the remaining row height or column width.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
weight double = 1 optional
Its relative share.

Returns

Sized The sized widget.
public static Sized Fixed(IWidget widget, int cells) #

Reserves a fixed number of cells for the widget.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
cells int required
The reserved cells.

Returns

Sized The sized widget.
public static RenderedOutput Render(IWidget widget, OutputFormat format, ExportOptions? options = null, IFrameExportProvider? provider = null) #

Renders the widget in a format and returns the output with its media type.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
format ConsoleMonster.Export.OutputFormat required
The format.
options ConsoleMonster.Export.ExportOptions? = null optional
Frame size, theme and typography.
provider ConsoleMonster.Export.IFrameExportProvider? = null optional
Optional typed add-on provider.

Returns

RenderedOutput The rendered output.
Save 6 overloads
public static void Save(IWidget widget, string path, ExportOptions? options = null, IFrameExportProvider? provider = null) #

Writes the widget to a file in the format its extension implies (.html, .svg, .txt, .md, .png...).

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
path string required
The output file.
options ConsoleMonster.Export.ExportOptions? = null optional
Frame size, theme and typography.
provider ConsoleMonster.Export.IFrameExportProvider? = null optional
Optional typed add-on provider; a registered provider is used when omitted.
public static void Save(IWidget widget, string path, OutputFormat format, ExportOptions? options = null, IFrameExportProvider? provider = null) #

Writes the widget to a file in an explicit format.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
path string required
The output file.
format ConsoleMonster.Export.OutputFormat required
The format.
options ConsoleMonster.Export.ExportOptions? = null optional
Frame size, theme and typography.
provider ConsoleMonster.Export.IFrameExportProvider? = null optional
Optional typed add-on provider.
public static void Save(IWidget widget, string path, Action<ExportOptions> configure) #

Writes the widget to a file with freshly configured output options.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
path string required
The output file; its extension picks the format.
configure System.Action<ConsoleMonster.Export.ExportOptions> required
Frame size, theme and typography.
public static void Save(IWidget widget, Stream stream, OutputFormat format, ExportOptions? options = null, IFrameExportProvider? provider = null) #

Writes the widget to a stream in a format.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
stream System.IO.Stream required
The stream; it stays open.
format ConsoleMonster.Export.OutputFormat required
The format.
options ConsoleMonster.Export.ExportOptions? = null optional
Frame size, theme and typography.
provider ConsoleMonster.Export.IFrameExportProvider? = null optional
Optional typed add-on provider.
public static void Save(IWidget widget, string path, GraphicsExportOptions options) #

Renders a widget and saves PNG.

Parameters

widget ConsoleMonster.Layout.IWidget required
path string required
options ConsoleMonster.Graphics.GraphicsExportOptions required
public static void Save(IWidget dashboard, IEnumerable<LiveEvent> events, string path, GraphicsFormat format, GraphicsExportOptions? options = null, CancellationToken cancellationToken = default) #

Encodes recorded dashboard events through the existing widget replay engine.

Parameters

dashboard ConsoleMonster.Layout.IWidget required
events System.Collections.Generic.IEnumerable<ConsoleMonster.Live.LiveEvent> required
path string required
format ConsoleMonster.Graphics.GraphicsFormat required
options ConsoleMonster.Graphics.GraphicsExportOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public static void Show(IWidget widget, TerminalProfile? profile = null, ITerminalWriter? writer = null) #

Displays a widget, just as piping it to Show-Console does.

Parameters

widget ConsoleMonster.Layout.IWidget required
The configured widget.
profile ConsoleMonster.Capabilities.TerminalProfile? = null optional
Optional terminal profile.
writer ConsoleMonster.Output.ITerminalWriter? = null optional
Optional embedding writer.
public static string ToHtml(IWidget widget, ExportOptions? options = null) #

Exports a widget as an HTML page.

Parameters

widget ConsoleMonster.Layout.IWidget required
The widget.
options ConsoleMonster.Export.ExportOptions? = null optional
Size, theme, font and window frame.

Returns

string The HTML.
public static string ToMarkdown(IWidget widget, ExportOptions? options = null, bool fenced = false) #

Exports tables, records and trees semantically, or preserves the rendered frame when fenced is true.

Parameters

widget ConsoleMonster.Layout.IWidget required
The widget or layout.
options ConsoleMonster.Export.ExportOptions? = null optional
Size, culture, glyphs and theme.
fenced bool = false optional
Preserves the exact terminal layout in a code block instead of exporting semantic data.

Returns

string The Markdown document.
public static byte[] ToPng(IWidget widget, GraphicsExportOptions? options = null) #

Renders a widget and encodes PNG.

Parameters

widget ConsoleMonster.Layout.IWidget required
options ConsoleMonster.Graphics.GraphicsExportOptions? = null optional

Returns

byte[]
public static string ToSvg(IWidget widget, ExportOptions? options = null) #

Exports a widget as an SVG image.

Parameters

widget ConsoleMonster.Layout.IWidget required
The widget.
options ConsoleMonster.Export.ExportOptions? = null optional
Size, theme, font and window frame.

Returns

string The SVG.
public static string ToText(IWidget widget, ExportOptions? options = null) #

Exports a widget as plain text (trailing spaces and empty last lines trimmed).

Parameters

widget ConsoleMonster.Layout.IWidget required
The widget.
options ConsoleMonster.Export.ExportOptions? = null optional
Size and glyph tier.

Returns

string The text.