API Reference
ITerminalTarget
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 22 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 4
- Property InteractiveOptions.Target
- Property LiveSessionOptions.Target
- Property Terminal.DefaultTarget
- Property Terminal.Target
Accepted by parameters 18
- Extension method ITerminalTarget.CreateContext
- Extension method ITerminalTarget.Status
- Extension method ITerminalTarget.StatusAsync
- Extension method ITerminalTarget.Write
- Extension method ITerminalTarget.WriteLines
- Extension method ITerminalTarget.WriteMarkup
- Extension method ITerminalTarget.WriteMarkupLine
- Extension method ITerminalTarget.WriteRich
- Method TerminalTargetExtensions.CreateContext
- Method TerminalTargetExtensions.Status
- Method TerminalTargetExtensions.StatusAsync
- Method TerminalTargetExtensions.Write
- Method TerminalTargetExtensions.WriteLines
- Method TerminalTargetExtensions.WriteMarkup
- Method TerminalTargetExtensions.WriteMarkupLine
- Method TerminalTargetExtensions.WriteRich
- Method Terminal.IsConsole
- Method Terminal.Use
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) #RenderContextA render context for the target's profile and theme (for measuring or rendering by hand).
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
Returns
The context.
public static Void Status(ITerminalTarget target, String markup, Action<StatusContext> action) #VoidRuns work under a status (see Terminal.Status).
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- markup System.String
- The first status text.
- action System.Action<ConsoleMonster.Output.StatusContext>
- The work.
public static async Task StatusAsync(ITerminalTarget target, String markup, Func<StatusContext, Task> action) #TaskRuns asynchronous work under a status.
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- markup System.String
- The first status text.
- action System.Func<ConsoleMonster.Output.StatusContext, System.Threading.Tasks.Task>
- The work.
Returns
A task that completes when the work has finished.
public static Void Write(ITerminalTarget target, IWidget widget) #VoidWrites a widget once.
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- widget ConsoleMonster.Layout.IWidget
- The widget.
public static Void WriteLines(ITerminalTarget target, IReadOnlyList<StyledLine> lines, Boolean newLine = true) #VoidWrites styled lines; with newLine false the last line is left open.
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- lines System.Collections.Generic.IReadOnlyList<ConsoleMonster.Text.StyledLine>
- The lines.
- newLine System.Boolean = true
- Whether to end the last line.
public static Void WriteMarkup(ITerminalTarget target, String markup) #VoidWrites markup without ending the line.
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- markup System.String
- The markup.
public static Void WriteMarkupLine(ITerminalTarget target, String markup) #VoidWrites one line of markup.
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- markup System.String
- The markup.
public static Void WriteRich(ITerminalTarget target, RichText text, Boolean newLine = true) #VoidWrites rich text as lines; with newLine false the last line is left open.
Parameters
- target ConsoleMonster.Output.ITerminalTarget
- The target.
- text ConsoleMonster.Text.RichText
- The rich text.
- newLine System.Boolean = true
- Whether to end the last line.