A console capable of writing ANSI escape sequences.
Properties
Console
: IAnsiConsoleGets or sets the underlying IAnsiConsole.
Cursor
: IAnsiConsoleCursorGets the IAnsiConsoleCursor.
Profile
: ProfileGets the console profile.
Methods
public static void AlternateScreen(Action action)
Switches to an alternate screen buffer if the terminal supports it.
Parameters:
action (Action)public static T Ask<T>(string prompt)
Displays a prompt to the user.
Parameters:
prompt (string)Returns:
The prompt input result.
public static T Ask<T>(string prompt, T defaultValue)
Displays a prompt to the user with a given default.
Parameters:
prompt (string)defaultValue (T)Returns:
The prompt input result.
public static Task<T> AskAsync<T>(string prompt, CancellationToken cancellationToken = default)
Displays a prompt to the user.
Parameters:
prompt (string)cancellationToken (CancellationToken)Returns:
The prompt input result.
public static Task<T> AskAsync<T>(string prompt, T defaultValue, CancellationToken cancellationToken = default)
Displays a prompt to the user with a given default.
Parameters:
prompt (string)defaultValue (T)cancellationToken (CancellationToken)Returns:
The prompt input result.
public static void Clear()
Clears the console.
public static bool Confirm(string prompt, bool defaultValue = true)
Displays a prompt with two choices, yes or no.
Parameters:
prompt (string)defaultValue (bool)Returns:
true if the user selected "yes", otherwise false.
public static Task<bool> ConfirmAsync(string prompt, bool defaultValue = true, CancellationToken cancellationToken = default)
Displays a prompt with two choices, yes or no.
Parameters:
prompt (string)defaultValue (bool)cancellationToken (CancellationToken)Returns:
true if the user selected "yes", otherwise false.
public static IAnsiConsole Create(AnsiConsoleSettings settings)
Creates a new IAnsiConsole instance from the provided settings.
Parameters:
settings (AnsiConsoleSettings)Returns:
An IAnsiConsole instance.
public static string ExportCustom(IAnsiConsoleEncoder encoder)
Exports all recorded console output using a custom encoder.
Parameters:
encoder (IAnsiConsoleEncoder)Returns:
The recorded output.
public static string ExportHtml()
Exports all recorded console output as HTML text.
Returns:
The recorded output as HTML text.
public static string ExportText()
Exports all recorded console output as text.
Returns:
The recorded output as text.
public static LiveDisplay Live(IRenderable target)
Creates a new LiveDisplay instance.
Parameters:
target (IRenderable)Returns:
A LiveDisplay instance.
public static void Markup(string value)
Writes the specified markup to the console.
Parameters:
value (string)public static void Markup(string format, object[] args)
Writes the specified markup to the console.
Parameters:
format (string)args (object[])public static void Markup(IFormatProvider provider, string format, object[] args)
Writes the specified markup to the console.
Parameters:
provider (IFormatProvider)format (string)args (object[])public static void MarkupInterpolated(FormattableString value)
Writes the specified markup to the console. All interpolation holes which contain a string are automatically escaped.
Parameters:
value (FormattableString)public static void MarkupInterpolated(IFormatProvider provider, FormattableString value)
Writes the specified markup to the console. All interpolation holes which contain a string are automatically escaped.
Parameters:
provider (IFormatProvider)value (FormattableString)public static void MarkupLine(string value)
Writes the specified markup, followed by the current line terminator, to the console.
Parameters:
value (string)public static void MarkupLine(string format, object[] args)
Writes the specified markup, followed by the current line terminator, to the console.
Parameters:
format (string)args (object[])public static void MarkupLine(IFormatProvider provider, string format, object[] args)
Writes the specified markup, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)format (string)args (object[])public static void MarkupLineInterpolated(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:
value (FormattableString)public static void MarkupLineInterpolated(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:
provider (IFormatProvider)value (FormattableString)public static Progress Progress()
Creates a new Progress instance.
Returns:
A Progress instance.
public static T Prompt<T>(IPrompt<T> prompt)
Displays a prompt to the user.
Parameters:
prompt (IPrompt<T>)Returns:
The prompt input result.
public static Task<T> PromptAsync<T>(IPrompt<T> prompt, CancellationToken cancellationToken = default)
Displays a prompt to the user.
Parameters:
prompt (IPrompt<T>)cancellationToken (CancellationToken)Returns:
The prompt input result.
public static void Record()
Starts recording the console output.
public static void Reset()
Resets colors and text decorations.
public static void ResetColors()
Resets the current applied foreground and background colors.
public static void ResetDecoration()
Resets the current applied text decorations.
public static Status Status()
Creates a new Status instance.
Returns:
A Status instance.
public static void Write(IRenderable renderable)
Renders the specified IRenderable to the console.
Parameters:
renderable (IRenderable)public static void Write(string value)
Writes the specified string value to the console.
Parameters:
value (string)public static void Write(int value)
Writes the text representation of the specified 32-bit signed integer value to the console.
Parameters:
value (int)public static void Write(IFormatProvider provider, int value)
Writes the text representation of the specified 32-bit signed integer value to the console.
Parameters:
provider (IFormatProvider)value (int)public static void Write(uint value)
Writes the text representation of the specified 32-bit unsigned integer value to the console.
Parameters:
value (uint)public static void Write(IFormatProvider provider, uint value)
Writes the text representation of the specified 32-bit unsigned integer value to the console.
Parameters:
provider (IFormatProvider)value (uint)public static void Write(long value)
Writes the text representation of the specified 64-bit signed integer value to the console.
Parameters:
value (long)public static void Write(IFormatProvider provider, long value)
Writes the text representation of the specified 64-bit signed integer value to the console.
Parameters:
provider (IFormatProvider)value (long)public static void Write(ulong value)
Writes the text representation of the specified 64-bit unsigned integer value to the console.
Parameters:
value (ulong)public static void Write(IFormatProvider provider, ulong value)
Writes the text representation of the specified 64-bit unsigned integer value to the console.
Parameters:
provider (IFormatProvider)value (ulong)public static void Write(float value)
Writes the text representation of the specified single-precision floating-point value to the console.
Parameters:
value (float)public static void Write(IFormatProvider provider, float value)
Writes the text representation of the specified single-precision floating-point value to the console.
Parameters:
provider (IFormatProvider)value (float)public static void Write(double value)
Writes the text representation of the specified double-precision floating-point value to the console.
Parameters:
value (double)public static void Write(IFormatProvider provider, double value)
Writes the text representation of the specified double-precision floating-point value to the console.
Parameters:
provider (IFormatProvider)value (double)public static void Write(decimal value)
Writes the text representation of the specified decimal value, to the console.
Parameters:
value (decimal)public static void Write(IFormatProvider provider, decimal value)
Writes the text representation of the specified decimal value, to the console.
Parameters:
provider (IFormatProvider)value (decimal)public static void Write(bool value)
Writes the text representation of the specified boolean value to the console.
Parameters:
value (bool)public static void Write(IFormatProvider provider, bool value)
Writes the text representation of the specified boolean value to the console.
Parameters:
provider (IFormatProvider)value (bool)public static void Write(char value)
Writes the specified Unicode character to the console.
Parameters:
value (char)public static void Write(IFormatProvider provider, char value)
Writes the specified Unicode character to the console.
Parameters:
provider (IFormatProvider)value (char)public static void Write(char[] value)
Writes the specified array of Unicode characters to the console.
Parameters:
value (char[])public static void Write(IFormatProvider provider, char[] value)
Writes the specified array of Unicode characters to the console.
Parameters:
provider (IFormatProvider)value (char[])public static void Write(string format, object[] args)
Writes the text representation of the specified array of objects, to the console using the specified format information.
Parameters:
format (string)args (object[])public static void Write(IFormatProvider provider, string format, object[] args)
Writes the text representation of the specified array of objects, to the console using the specified format information.
Parameters:
provider (IFormatProvider)format (string)args (object[])public static void WriteException(Exception exception, ExceptionFormats format = 0)
Writes an exception to the console.
Parameters:
exception (Exception)format (ExceptionFormats)public static void WriteException(Exception exception, ExceptionSettings settings)
Writes an exception to the console.
Parameters:
exception (Exception)settings (ExceptionSettings)public static void WriteLine()
Writes an empty line to the console.
public static void WriteLine(string value)
Writes the specified string value, followed by the current line terminator, to the console.
Parameters:
value (string)public static void WriteLine(int value)
Writes the text representation of the specified 32-bit signed integer value, followed by the current line terminator, to the console.
Parameters:
value (int)public static void WriteLine(IFormatProvider provider, int value)
Writes the text representation of the specified 32-bit signed integer value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (int)public static void WriteLine(uint value)
Writes the text representation of the specified 32-bit unsigned integer value, followed by the current line terminator, to the console.
Parameters:
value (uint)public static void WriteLine(IFormatProvider provider, uint value)
Writes the text representation of the specified 32-bit unsigned integer value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (uint)public static void WriteLine(long value)
Writes the text representation of the specified 64-bit signed integer value, followed by the current line terminator, to the console.
Parameters:
value (long)public static void WriteLine(IFormatProvider provider, long value)
Writes the text representation of the specified 64-bit signed integer value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (long)public static void WriteLine(ulong value)
Writes the text representation of the specified 64-bit unsigned integer value, followed by the current line terminator, to the console.
Parameters:
value (ulong)public static void WriteLine(IFormatProvider provider, ulong value)
Writes the text representation of the specified 64-bit unsigned integer value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (ulong)public static void WriteLine(float value)
Writes the text representation of the specified single-precision floating-point value, followed by the current line terminator, to the console.
Parameters:
value (float)public static void WriteLine(IFormatProvider provider, float value)
Writes the text representation of the specified single-precision floating-point value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (float)public static void WriteLine(double value)
Writes the text representation of the specified double-precision floating-point value, followed by the current line terminator, to the console.
Parameters:
value (double)public static void WriteLine(IFormatProvider provider, double value)
Writes the text representation of the specified double-precision floating-point value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (double)public static void WriteLine(decimal value)
Writes the text representation of the specified decimal value, followed by the current line terminator, to the console.
Parameters:
value (decimal)public static void WriteLine(IFormatProvider provider, decimal value)
Writes the text representation of the specified decimal value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (decimal)public static void WriteLine(bool value)
Writes the text representation of the specified boolean value, followed by the current line terminator, to the console.
Parameters:
value (bool)public static void WriteLine(IFormatProvider provider, bool value)
Writes the text representation of the specified boolean value, followed by the current line terminator, to the console.
Parameters:
provider (IFormatProvider)value (bool)public static void WriteLine(char value)
Writes the specified Unicode character, followed by the current line terminator, value to the console.
Parameters:
value (char)public static void WriteLine(IFormatProvider provider, char value)
Writes the specified Unicode character, followed by the current line terminator, value to the console.
Parameters:
provider (IFormatProvider)value (char)public static void WriteLine(char[] value)
Writes the specified array of Unicode characters, followed by the current line terminator, value to the console.
Parameters:
value (char[])public static void WriteLine(IFormatProvider provider, char[] value)
Writes the specified array of Unicode characters, followed by the current line terminator, value to the console.
Parameters:
provider (IFormatProvider)value (char[])public static void WriteLine(string format, object[] args)
Writes the text representation of the specified array of objects, followed by the current line terminator, to the console using the specified format information.
Parameters:
format (string)args (object[])public static void WriteLine(IFormatProvider provider, string format, object[] args)
Writes the text representation of the specified array of objects, followed by the current line terminator, to the console using the specified format information.
Parameters:
provider (IFormatProvider)format (string)args (object[])