AnsiConsoleExtensions

Contains extension methods for .

Contains extension methods for IAnsiConsole.

Methods

public static void AlternateScreen(IAnsiConsole console, Action action)

Switches to an alternate screen buffer if the terminal supports it.

Parameters:

console (IAnsiConsole)
The console.
action (Action)
The action to execute within the alternate screen buffer.
public static T Ask<T>(IAnsiConsole console, string prompt)

Displays a prompt to the user.

Parameters:

console (IAnsiConsole)
The console.
prompt (string)
The prompt markup text.

Returns:

The prompt input result.

public static T Ask<T>(IAnsiConsole console, string prompt, CultureInfo culture)

Displays a prompt to the user.

Parameters:

console (IAnsiConsole)
The console.
prompt (string)
The prompt markup text.
culture (CultureInfo)
Specific CultureInfo to use when converting input.

Returns:

The prompt input result.

public static Task<T> AskAsync<T>(IAnsiConsole console, string prompt, CancellationToken cancellationToken = default)

Displays a prompt to the user.

Parameters:

console (IAnsiConsole)
The console.
prompt (string)
The prompt markup text.
cancellationToken (CancellationToken)
The token to monitor for cancellation requests.

Returns:

The prompt input result.

public static Task<T> AskAsync<T>(IAnsiConsole console, string prompt, CultureInfo culture, CancellationToken cancellationToken = default)

Displays a prompt to the user.

Parameters:

console (IAnsiConsole)
The console.
prompt (string)
The prompt markup text.
culture (CultureInfo)
Specific CultureInfo to use when converting input.
cancellationToken (CancellationToken)
The token to monitor for cancellation requests.

Returns:

The prompt input result.

public static void Clear(IAnsiConsole console)

Clears the console.

Parameters:

console (IAnsiConsole)
The console to clear.
public static bool Confirm(IAnsiConsole console, string prompt, bool defaultValue = true)

Displays a prompt with two choices, yes or no.

Parameters:

console (IAnsiConsole)
The console.
prompt (string)
The prompt markup text.
defaultValue (bool)
Specifies the default answer.

Returns:

true if the user selected "yes", otherwise false.

public static Task<bool> ConfirmAsync(IAnsiConsole console, string prompt, bool defaultValue = true, CancellationToken cancellationToken = default)

Displays a prompt with two choices, yes or no.

Parameters:

console (IAnsiConsole)
The console.
prompt (string)
The prompt markup text.
defaultValue (bool)
Specifies the default answer.
cancellationToken (CancellationToken)
The token to monitor for cancellation requests.

Returns:

true if the user selected "yes", otherwise false.

public static Recorder CreateRecorder(IAnsiConsole console)

Creates a recorder for the specified console.

Parameters:

console (IAnsiConsole)
The console to record.

Returns:

A recorder for the specified console.

public static LiveDisplay Live(IAnsiConsole console, IRenderable target)

Creates a new LiveDisplay instance for the console.

Parameters:

console (IAnsiConsole)
The console.
target (IRenderable)
The target renderable to update.

Returns:

A LiveDisplay instance.

public static void Markup(IAnsiConsole console, string format, object[] args)

Writes the specified markup to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
format (string)
A composite format string.
args (object[])
An array of objects to write.
public static void Markup(IAnsiConsole console, IFormatProvider provider, string format, object[] args)

Writes the specified markup to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
provider (IFormatProvider)
An object that supplies culture-specific formatting information.
format (string)
A composite format string.
args (object[])
An array of objects to write.
public static void Markup(IAnsiConsole console, string value)

Writes the specified markup to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
value (string)
The value to write.
public static void MarkupInterpolated(IAnsiConsole console, FormattableString value)

Writes the specified markup to the console. All interpolation holes which contain a string are automatically escaped.

Parameters:

console (IAnsiConsole)
The console to write to.
value (FormattableString)
The interpolated string value to write.
public static void MarkupInterpolated(IAnsiConsole console, IFormatProvider provider, FormattableString value)

Writes the specified markup to the console. All interpolation holes which contain a string are automatically escaped.

Parameters:

console (IAnsiConsole)
The console to write to.
provider (IFormatProvider)
An object that supplies culture-specific formatting information.
value (FormattableString)
The interpolated string value to write.
public static void MarkupLine(IAnsiConsole console, string format, object[] args)

Writes the specified markup, followed by the current line terminator, to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
format (string)
A composite format string.
args (object[])
An array of objects to write.
public static void MarkupLine(IAnsiConsole console, string value)

Writes the specified markup, followed by the current line terminator, to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
value (string)
The value to write.
public static void MarkupLine(IAnsiConsole console, IFormatProvider provider, string format, object[] args)

Writes the specified markup, followed by the current line terminator, to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
provider (IFormatProvider)
An object that supplies culture-specific formatting information.
format (string)
A composite format string.
args (object[])
An array of objects to write.
public static void MarkupLineInterpolated(IAnsiConsole console, FormattableString value)

Writes the specified markup, followed by the current line terminator, to the console. All interpolation holes which contain a string are automatically escaped.

Parameters:

console (IAnsiConsole)
The console to write to.
value (FormattableString)
The interpolated string value to write.
public static void MarkupLineInterpolated(IAnsiConsole console, IFormatProvider provider, FormattableString value)

Writes the specified markup, followed by the current line terminator, to the console. All interpolation holes which contain a string are automatically escaped.

Parameters:

console (IAnsiConsole)
The console to write to.
provider (IFormatProvider)
An object that supplies culture-specific formatting information.
value (FormattableString)
The interpolated string value to write.
public static Progress Progress(IAnsiConsole console)

Creates a new Progress instance for the console.

Parameters:

console (IAnsiConsole)
The console.

Returns:

A Progress instance.

public static T Prompt<T>(IAnsiConsole console, IPrompt<T> prompt)

Displays a prompt to the user.

Parameters:

console (IAnsiConsole)
The console.
prompt (IPrompt<T>)
The prompt to display.

Returns:

The prompt input result.

public static Task<T> PromptAsync<T>(IAnsiConsole console, IPrompt<T> prompt, CancellationToken cancellationToken = default)

Displays a prompt to the user.

Parameters:

console (IAnsiConsole)
The console.
prompt (IPrompt<T>)
The prompt to display.
cancellationToken (CancellationToken)
The token to monitor for cancellation requests.

Returns:

The prompt input result.

public static T RunExclusive<T>(IAnsiConsole console, Func<T> func)

Runs the specified function in exclusive mode.

Parameters:

console (IAnsiConsole)
The console.
func (Func<T>)
The func to run in exclusive mode.

Returns:

The result of the function.

public static Task<T> RunExclusive<T>(IAnsiConsole console, Func<Task<T>> func)

Runs the specified function in exclusive mode asynchronously.

Parameters:

console (IAnsiConsole)
The console.
func (Func<Task<T>>)
The func to run in exclusive mode.

Returns:

The result of the function.

public static Status Status(IAnsiConsole console)

Creates a new Status instance for the console.

Parameters:

console (IAnsiConsole)
The console.

Returns:

A Status instance.

public static string ToAnsi(IAnsiConsole console, IRenderable renderable)

Gets the VT/ANSI control code sequence for a IRenderable.

Parameters:

console (IAnsiConsole)
The console.
renderable (IRenderable)
The renderable to the VT/ANSI control code sequence for.

Returns:

The VT/ANSI control code sequence.

public static void Write(IAnsiConsole console, string text)

Writes the specified string value to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
text (string)
The text to write.
public static void WriteAnsi(IAnsiConsole console, string sequence)

Writes a VT/Ansi control code sequence to the console (if supported).

Parameters:

console (IAnsiConsole)
The console to write to.
sequence (string)
The VT/Ansi control code sequence to write.
public static void WriteException(IAnsiConsole console, Exception exception, ExceptionFormats format = 0)

Writes an exception to the console.

Parameters:

console (IAnsiConsole)
The console.
exception (Exception)
The exception to write to the console.
format (ExceptionFormats)
The exception format options.
public static void WriteException(IAnsiConsole console, Exception exception, ExceptionSettings settings)

Writes an exception to the console.

Parameters:

console (IAnsiConsole)
The console.
exception (Exception)
The exception to write to the console.
settings (ExceptionSettings)
The exception settings.
public static void WriteLine(IAnsiConsole console)

Writes an empty line to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
public static void WriteLine(IAnsiConsole console, string text)

Writes the specified string value, followed by the current line terminator, to the console.

Parameters:

console (IAnsiConsole)
The console to write to.
text (string)
The text to write.