Skip to content
ConsoleMonster
Class

TerminalProfile

ConsoleMonster.Capabilities

Namespace
ConsoleMonster.Capabilities
Assembly
ConsoleMonster
Modifiers
sealed

An immutable description of what the current terminal can do. Produced by an ICapabilityProvider, overridable by code, environment variables (CONSOLEMONSTER_COLOR, CONSOLEMONSTER_GLYPHS, CONSOLEMONSTER_MODE, CONSOLEMONSTER_THEME, CONSOLEMONSTER_HYPERLINKS, NO_COLOR) and configuration. Rendering is a pure function of the widget, its state, this profile and the theme.

Inheritance

  • object
  • TerminalProfile

Usage

Explore 79 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 39

Constructors

TerminalProfile 2 overloads
public TerminalProfile(ColorDepth colorDepth, GlyphTier glyphs, OutputMode mode, int width, int height, TerminalKind kind, bool supportsVirtualTerminal, bool isOutputRedirected, bool isConsoleHandle, bool isContinuousIntegration, string? fontFace, IReadOnlyList<string>? decisions, TerminalWidthProfile? widthProfile, bool probeWidths, ThemeMode themeMode, CultureInfo? culture) #

Creates a profile through the original constructor signature, retained for compiled consumers.

Parameters

colorDepth ConsoleMonster.Capabilities.ColorDepth required
Colour fidelity.
glyphs ConsoleMonster.Capabilities.GlyphTier required
Glyph tier.
mode ConsoleMonster.Capabilities.OutputMode required
Output mode.
width int required
Width in cells.
height int required
Height in cells.
kind ConsoleMonster.Capabilities.TerminalKind required
Detected terminal kind.
supportsVirtualTerminal bool required
Whether VT sequences are understood.
isOutputRedirected bool required
Whether standard output is redirected.
isConsoleHandle bool required
Whether output goes to a real Windows console handle.
isContinuousIntegration bool required
Whether a CI environment was detected.
fontFace string? required
The console font face, when known.
decisions System.Collections.Generic.IReadOnlyList<string>? required
Notes explaining the capability decisions.
widthProfile ConsoleMonster.Text.TerminalWidthProfile? required
Display width assumptions.
probeWidths bool required
Whether a live width probe is permitted.
themeMode ConsoleMonster.ThemeMode required
Requested light, dark or automatic theme mode.
culture System.Globalization.CultureInfo? required
Culture for numbers and dates, or null for the current culture.
public TerminalProfile(ColorDepth colorDepth, GlyphTier glyphs, OutputMode mode, int width = 100, int height = 40, TerminalKind kind = Unknown, bool supportsVirtualTerminal = false, bool isOutputRedirected = false, bool isConsoleHandle = false, bool isContinuousIntegration = false, string? fontFace = null, IReadOnlyList<string>? decisions = null, TerminalWidthProfile? widthProfile = null, bool probeWidths = false, ThemeMode themeMode = Auto, CultureInfo? culture = null, bool? supportsHyperlinks = null) #

Creates a profile with explicit values. Tests and fixed-output scenarios use this directly.

Parameters

colorDepth ConsoleMonster.Capabilities.ColorDepth required
Colour fidelity.
glyphs ConsoleMonster.Capabilities.GlyphTier required
Glyph tier.
mode ConsoleMonster.Capabilities.OutputMode required
Output mode.
width int = 100 optional
Width in cells; values below 1 fall back to TerminalProfile.DefaultWidth.
height int = 40 optional
Height in cells; values below 1 fall back to TerminalProfile.DefaultHeight.
kind ConsoleMonster.Capabilities.TerminalKind = Unknown optional
Detected terminal kind.
supportsVirtualTerminal bool = false optional
Whether VT sequences are understood.
isOutputRedirected bool = false optional
Whether standard output is redirected.
isConsoleHandle bool = false optional
Whether output goes to a real Windows console handle (written with WriteConsoleW).
isContinuousIntegration bool = false optional
Whether a CI environment was detected.
fontFace string? = null optional
The console font face, when known.
decisions System.Collections.Generic.IReadOnlyList<string>? = null optional
Human-readable notes explaining how each value was chosen.
widthProfile ConsoleMonster.Text.TerminalWidthProfile? = null optional
Configured or derived display width assumptions.
probeWidths bool = false optional
Whether a live width probe is permitted.
themeMode ConsoleMonster.ThemeMode = Auto optional
Requested light, dark or automatic theme mode.
culture System.Globalization.CultureInfo? = null optional
The culture for numbers and dates in rendered output, or null for the current culture.
supportsHyperlinks bool? = null optional
OSC 8 support, or null to infer it from the terminal kind. Redirected, CI, noninteractive and non-VT output always disable links.

Methods

public static TerminalProfile Fixed(int width, int height, ColorDepth colorDepth = TrueColor, GlyphTier glyphs = Full, OutputMode mode = Interactive) #

A fixed profile for tests, snapshots and HTML-free documentation captures.

Parameters

width int required
Width in cells.
height int required
Height in cells.
colorDepth ConsoleMonster.Capabilities.ColorDepth = TrueColor optional
Colour fidelity.
glyphs ConsoleMonster.Capabilities.GlyphTier = Full optional
Glyph tier.
mode ConsoleMonster.Capabilities.OutputMode = Interactive optional
Output mode.

Returns

TerminalProfile A profile with VT support when the mode is interactive.
public override string ToString() #

Returns a string that represents the current object.

Returns

string A string that represents the current object.
public TerminalProfile WithBorder(BoxStyle? border) #

Returns a copy that draws default frames with this style, whatever the theme says.

Parameters

border ConsoleMonster.Glyphs.BoxStyle? required
The frame, or null to follow the theme. BoxStyle None is not a frame style.

Returns

TerminalProfile The copy.
public TerminalProfile WithColorDepth(ColorDepth colorDepth) #

Returns a copy with a different colour depth.

Parameters

colorDepth ConsoleMonster.Capabilities.ColorDepth required
The new colour depth.

Returns

TerminalProfile A new profile.
public TerminalProfile WithCulture(CultureInfo? culture) #

Returns a copy that renders numbers and dates with the given culture.

Parameters

culture System.Globalization.CultureInfo? required
The culture, or null to follow the current culture.

Returns

TerminalProfile The copy.
public TerminalProfile WithDecision(string decision) #

Returns a copy with an extra decision note appended.

Parameters

decision string required
The note.

Returns

TerminalProfile A new profile.
public TerminalProfile WithDefaultColors(Color foreground, Color background) #

Returns a copy with explicit default colors for this rendering, including style and output resets.

Parameters

foreground ConsoleMonster.Styling.Color required
The supplied host foreground, or Color.Default to keep VT defaults.
background ConsoleMonster.Styling.Color required
The supplied host background, or Color.Default to keep VT defaults.

Returns

TerminalProfile A new profile. Explicit style colors still take precedence; Plain and color-disabled output emit no SGR.
public TerminalProfile WithDensity(ThemeDensity? density) #

Returns a copy with a density override, or null to use the theme.

Parameters

density ConsoleMonster.Styling.ThemeDensity? required
The spacing density.

Returns

TerminalProfile A new profile.
public TerminalProfile WithGlyphs(GlyphTier glyphs) #

Returns a copy with a different glyph tier.

Parameters

glyphs ConsoleMonster.Capabilities.GlyphTier required
The new glyph tier.

Returns

TerminalProfile A new profile.
public TerminalProfile WithImageProtocol(ImageProtocol protocol) #

Returns a copy that draws images with a chosen protocol, for a terminal detection does not recognise or to opt down to half blocks or the placeholder. Output, CI, mode, VT and colour guards still apply (see TerminalProfile.ImageProtocol).

Parameters

protocol ConsoleMonster.Capabilities.ImageProtocol required
The protocol the terminal supports.

Returns

TerminalProfile A new profile.
public TerminalProfile WithLanguage(CultureInfo? language) #

Returns a copy whose built-in labels use the given language (see TerminalProfile.Language).

Parameters

language System.Globalization.CultureInfo? required
The language, or null to follow the current UI culture.

Returns

TerminalProfile The copy.
public TerminalProfile WithMode(OutputMode mode) #

Returns a copy with a different output mode.

Parameters

mode ConsoleMonster.Capabilities.OutputMode required
The new mode.

Returns

TerminalProfile A new profile.
public TerminalProfile WithPalette(ThemePalette palette) #

Returns a copy with a different palette.

Parameters

palette ConsoleMonster.Capabilities.ThemePalette required
The palette.

Returns

TerminalProfile A new profile.
public TerminalProfile WithPlainOutput() #

Returns this profile in plain mode, as CONSOLEMONSTER_MODE=plain gives: append-only ASCII lines without colour or escape sequences.

Returns

TerminalProfile The copy.
public TerminalProfile WithRedirectedOutput() #

Returns this profile as detection would see it with standard output redirected to a file, pipe or log: append-only stream output (plain stays plain), no colour, no VT sequences or links, the Basic glyph tier at most, and a width that is only the layout default (TerminalProfile.IsWidthKnown is false). Hosts use it for a second destination, such as standard error, instead of building a profile by hand.

Returns

TerminalProfile The copy.
public TerminalProfile WithSize(int width, int height) #

Returns a copy with a different size (used on resize).

Parameters

width int required
Width in cells.
height int required
Height in cells.

Returns

TerminalProfile A new profile.
public TerminalProfile WithStatusMarkers(StatusMarkerStyle? markers) #

Returns a copy that marks statuses this way, whatever the theme says.

Parameters

markers ConsoleMonster.Styling.StatusMarkerStyle? required
The markers, or null to follow the theme.

Returns

TerminalProfile The copy.
public TerminalProfile WithThemeMode(ThemeMode themeMode) #

Returns a copy with a different theme mode.

Parameters

themeMode ConsoleMonster.ThemeMode required
Light, dark or automatic.

Returns

TerminalProfile A new profile.
public TerminalProfile WithWidthProfile(TerminalWidthProfile profile) #

Returns a copy with a different terminal width profile.

Parameters

profile ConsoleMonster.Text.TerminalWidthProfile required

Properties

public ColorDepth ColorDepth { get; } #

Colour fidelity.

public Color DefaultForeground { get; private set; } #

The per-render foreground used when a style requests the terminal default. Defaults to Color.Default; the profile never reads or changes host colors itself.

public Color DefaultBackground { get; private set; } #

The per-render background used when a style requests the terminal default. Defaults to Color.Default; color-disabled output ignores this baseline.

public GlyphTier Glyphs { get; } #

Glyph tier.

public OutputMode Mode { get; } #

Output mode.

public int Width { get; } #

Width in cells.

public int Height { get; } #

Height in cells.

public TerminalKind Kind { get; } #

Detected terminal kind.

public bool SupportsVirtualTerminal { get; } #

Whether VT escape sequences are understood.

public ImageProtocol ImageProtocol { get; } #

How this output may draw an inline image: the detected or configured protocol (TerminalProfile.WithImageProtocol) on interactive VT output with 256 colours or more, and half blocks on other line output with those colours. Redirected, CI, plain, no-colour and 16-colour output always get ImageProtocol.None, a text placeholder, so image sequences never reach logs or files.

public bool IsOutputRedirected { get; } #

Whether standard output is redirected to a file, pipe or log.

public bool IsWidthKnown { get; } #

Whether TerminalProfile.Width is the destination's real width: a terminal window, COLUMNS or a size the caller chose. It is false for redirected output without COLUMNS, where TerminalProfile.Width is only the layout default (TerminalProfile.DefaultWidth): line output (status lists, text, facts) is then not wrapped or cut at that width, while tables, panels and charts still lay out at it.

public bool IsConsoleHandle { get; } #

Whether output goes to a real Windows console handle (UTF-16 through WriteConsoleW).

public bool IsContinuousIntegration { get; } #

Whether a CI environment was detected.

public string? FontFace { get; } #

The console font face, when known (conhost through GetCurrentConsoleFontEx).

public IReadOnlyList<string> Decisions { get; } #

Human-readable notes explaining how each value was chosen (shown by Get-ConsoleCapability). The images: note describes the final TerminalProfile.ImageProtocol of this profile, including its output guards.

public TerminalWidthProfile WidthProfile { get; } #

The configured or derived Unicode display width profile.

public bool ProbeWidths { get; } #

Whether an interactive session may probe terminal widths.

public ThemeMode ThemeMode { get; } #

The requested light or dark mode, or automatic detection from the terminal background.

public ThemePalette Palette { get; private set; } #

The requested palette (standard, high contrast, colour-blind-safe or the terminal's own). Set with TerminalProfile.WithPalette.

public CultureInfo? Culture { get; } #

The culture for numbers and dates in rendered output (thousand and decimal separators, date formats), or null to follow the current culture at render time, as PowerShell does. Set by CONSOLEMONSTER_CULTURE or TerminalProfile.WithCulture. Built-in labels follow TerminalProfile.Language.

public CultureInfo? Language { get; private set; } #

The language of built-in labels (prompt keys, status words, "Showing 5 of 20"), or null for the current UI culture ($PSUICulture in PowerShell), unless CONSOLEMONSTER_LANGUAGE names one. English, Polish, German, Spanish, French and Italian are built in; other languages fall back to English. Set with TerminalProfile.WithLanguage.

public BoxStyle? Border { get; private set; } #

The frame for panels, tables and inputs that use the default frame, chosen with CONSOLEMONSTER_BORDER or the Border setting; null uses the theme's (ThemeAppearance.Border). Set with TerminalProfile.WithBorder.

public StatusMarkerStyle? StatusMarkers { get; private set; } #

How statuses are marked, chosen with CONSOLEMONSTER_STATUS_MARKERS or the StatusMarkers setting; null uses the theme's (ThemeAppearance.StatusMarkers). Set with TerminalProfile.WithStatusMarkers.

public ThemeDensity? Density { get; private set; } #

Widget spacing chosen by CONSOLEMONSTER_DENSITY or the Density setting; null uses the theme.

public bool IsAccessible { get; private set; } #

Whether accessible interaction and append-only live narration were requested.

public bool ReducedMotion { get; private set; } #

Whether animation is disabled and live redraws are limited to once a second.

public bool IsLive { get; } #

Whether this profile permits live cursor-based rendering.

Fields

public const int DefaultWidth #

The default width used when the real width cannot be determined (redirected output).

Value: 100
public const int DefaultHeight #

The default height used when the real height cannot be determined.

Value: 40