Skip to content
ConsoleMonster

Capability detection

ConsoleMonster detects VT support, colour depth, the glyphs the font can draw, size, redirection, CI and the background, and records why.

Detection runs once and produces a TerminalProfile: the output mode, the colour depth, the glyph tier, the window size, the theme preference and the culture. Every value carries the reason it was chosen, which Get-ConsoleCapability (and Terminal.Profile.Decisions in C#) lists. The frames below run the script shown under the first one with different environments. Each terminal names its capture platform; colour and glyph detection can differ while the cell-width policy stays pinned.

detected terminal profile PowerShell 7100 columnsWindows
PowerShellprofile.ps1
# What ConsoleMonster detected about this console, and why.
$capability = Get-ConsoleCapability
$capability |
    Show-Console -View List -Title 'This console' -Property Mode, ColorDepth, Glyphs, Width, Height,
        ThemeMode, Palette, FontFace
$capability.Decisions | ForEach-Object { "  $_" }
Full program
Import-Module ConsoleMonster

# What ConsoleMonster detected about this console, and why.
$capability = Get-ConsoleCapability
$capability |
    Show-Console -View List -Title 'This console' -Property Mode, ColorDepth, Glyphs, Width, Height,
        ThemeMode, Palette, FontFace
$capability.Decisions | ForEach-Object { "  $_" }
Windows: colour, glyph tier and theme are detected; the capture fixes Unicode cell widths.
detected terminal profile PowerShell 7100 columnsmacOS
macOS: the same script in a UTF-8 pseudo terminal, with the same cell-width policy.

What is detected

  • Mode. Interactive on a VT console, Stream when output is redirected or a CI system is detected, Plain when asked for. Stream and Plain write lines instead of redrawing.
  • Colour depth. 24-bit, 256, 16 or none. NO_COLOR turns colour off.
  • Glyph tier. Full, Basic or ASCII. On conhost the console font is read to choose; in stream and CI output the tier is Basic. The tier changes only ConsoleMonster's own borders, markers and spinners; your text keeps its emoji and symbols on every tier.
  • Size. The visible window, not the screen buffer, so nothing is written past the window or into its bottom-right cell.
  • Widths. Display widths come from Unicode 17 tables, with emoji and ambiguous widths that can be overridden. A width probe reads the console screen buffer and never reads input.
  • Links. Clickable OSC 8 links for URLs and file paths in Windows Terminal, VS Code, iTerm2, WezTerm, Kitty and Ghostty (outside tmux, screen and Zellij panes), VTE terminals and Konsole; never in redirected, CI, stream or plain output, where a link prints its target after the text as text (url). CONSOLEMONSTER_HYPERLINKS overrides it (see Environment overrides).
  • Background. In conhost, auto reads the console background colour to choose the light or dark theme. Windows Terminal does not expose its colour scheme to console programs, so there CONSOLEMONSTER_THEME=light selects the light theme.
CI=true, NO_COLOR=1 PowerShell 7100 columnsWindows
With CI=true and NO_COLOR=1: stream mode, no colour, Basic glyphs and no width probing.

In C#, Terminal.Profile holds the same values and Decisions the same reasons. This program prints a shorter list than the script above:

using ConsoleMonster;
using ConsoleMonster.Capabilities;
using ConsoleMonster.Widgets;

// What ConsoleMonster detected about this console, and why.
TerminalProfile profile = Terminal.Profile;
KeyValueList facts = new KeyValueList()
    .Add("Mode", profile.Mode.ToString())
    .Add("ColorDepth", profile.ColorDepth.ToString())
    .Add("Glyphs", profile.Glyphs.ToString())
    .Add("Size", profile.Width + " × " + profile.Height);
Terminal.Write(facts);
foreach (string decision in profile.Decisions) {
    Terminal.WriteMarkupLine("  " + ConsoleMonster.Text.Markup.Escape(decision));
}

Overriding detection

Any decision can be pinned with an environment variable (see Environment overrides). The site pins the colour depth, glyph tier, theme, culture and language for its captures, and the same script then reports each of them as pinned:

pinned with CONSOLEMONSTER_* PowerShell 7100 columnsWindows
The profile the site uses for its captures: CONSOLEMONSTER_COLOR, _GLYPHS, _THEME, _CULTURE and _LANGUAGE pinned.

In code, TerminalProfile.Fixed(width, height, colors, glyphs) builds a profile without detection, and TerminalProfile.WithCulture, WithThemeMode, WithPalette and WithSize change one value. Terminal.Write(widget, profile) renders with it:

using ConsoleMonster;
using ConsoleMonster.Capabilities;
using ConsoleMonster.Widgets;

Rule rule = new Rule("[bold]Release notes[/]");
Terminal.Write(rule);                                                          // as detected
Terminal.Write(rule, Terminal.Profile.WithColorDepth(ColorDepth.None));       // the same console, no colour
Terminal.Write(rule, TerminalProfile.Fixed(40, 10, ColorDepth.Ansi16, GlyphTier.Ascii));  // a fixed profile

Fonts and resizing during a session

In conhost, the console font is polled about once a second; a new face or size re-derives the glyph tier and the emoji and ambiguous widths. In Windows Terminal, widths are measured again after every resize, which also covers zooming with Ctrl+= and Ctrl+0. Print-once output reads the window size on every write, so output printed after a resize uses the new width.

Next

Edit this page on GitHub