Skip to content
ConsoleMonster
Interface

ITerminalTarget

ConsoleMonster.Output

Namespace
ConsoleMonster.Output
Assembly
ConsoleMonster
Modifiers
abstract

Where console output goes and where input comes from: the capability profile (size, colour depth, glyph tier, culture and language), the theme, the writer and the input source. Every write, live session, prompt and status helper resolves one: an explicit target (LiveSessionOptions, InteractiveOptions, the TerminalTargetExtensions methods) or the ambient Terminal.Target.

Remarks

Built-ins: ConsoleTarget (the process console, the default), RecordingTarget (in memory, for tests; see TestTerminal.Target), WriterTarget (a TextWriter with a chosen tier and width) and NullTarget (discards everything). Implement it to host ConsoleMonster output elsewhere, for example in a log window.

Usage

Explore 27 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 22

Properties

public abstract string Name { get; } #

A short description for diagnostics, for example console or recording 80x24.

public abstract TerminalProfile Profile { get; } #

The capability profile for a write happening now (the console's refreshes its size on every call).

public abstract ITheme? Theme { get; } #

The theme, or null to choose one from the profile (see Terminal.ResolveTheme).

public abstract ITerminalWriter? Writer { get; } #

The writer that receives the output, or null for the process console. The target owns it: callers write and flush but never dispose it.

public abstract IInputSource? Input { get; } #

The input for prompts, menus and forms, or null. On the console null means the keyboard; on any other target it means nobody can answer, so prompts use their defaults or explain what is missing.

Extension Methods

public static RenderContext CreateContext(ITerminalTarget target) #

A render context for the target's profile and theme (for measuring or rendering by hand).

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.

Returns

RenderContext The context.
public static void Status(ITerminalTarget target, string markup, Action<StatusContext> action) #

Runs work under a status (see Terminal.Status).

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
markup string required
The first status text.
action System.Action<ConsoleMonster.Output.StatusContext> required
The work.
public static async Task StatusAsync(ITerminalTarget target, string markup, Func<StatusContext, Task> action) #

Runs asynchronous work under a status.

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
markup string required
The first status text.
action System.Func<ConsoleMonster.Output.StatusContext, System.Threading.Tasks.Task> required
The work.

Returns

Task A task that completes when the work has finished.
public static void Write(ITerminalTarget target, IWidget widget) #

Writes a widget once.

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
widget ConsoleMonster.Layout.IWidget required
The widget.
public static void WriteLines(ITerminalTarget target, IReadOnlyList<StyledLine> lines, bool newLine = true) #

Writes styled lines; with newLine false the last line is left open.

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
lines System.Collections.Generic.IReadOnlyList<ConsoleMonster.Text.StyledLine> required
The lines.
newLine bool = true optional
Whether to end the last line.
public static void WriteMarkup(ITerminalTarget target, string markup) #

Writes markup without ending the line.

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
markup string required
The markup.
public static void WriteMarkupLine(ITerminalTarget target, string markup) #

Writes one line of markup.

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
markup string required
The markup.
public static void WriteRich(ITerminalTarget target, RichText text, bool newLine = true) #

Writes rich text as lines; with newLine false the last line is left open.

Parameters

target ConsoleMonster.Output.ITerminalTarget required
The target.
text ConsoleMonster.Text.RichText required
The rich text.
newLine bool = true optional
Whether to end the last line.