Table of Contents

Method IsAttachedToTerminal

Namespace
Terminal.Gui.Drivers
Assembly
Terminal.Gui.dll

IsAttachedToTerminal(out bool, out bool)

Determines whether the process has a controlling terminal usable for TUI rendering and input. Returns true when either:

  • stdin/stdout are connected to a console device, or
  • stdin/stdout are redirected (e.g. via a shell pipeline such as result=$(myapp) or myapp | jq) but a controlling terminal is available via /dev/tty on Unix or CONIN$/CONOUT$ on Windows.

Set the environment variable DisableRealDriverIO=1 to skip real terminal detection and force this method to return false, which is required for running in test harnesses that do not have a real terminal attached.

public static bool IsAttachedToTerminal(out bool inputAttached, out bool outputAttached)

Parameters

inputAttached bool

When this method returns, true if a terminal device is available for input (either stdin or the controlling terminal); otherwise false.

outputAttached bool

When this method returns, true if a terminal device is available for output (either stdout or the controlling terminal); otherwise false.

Returns

bool

true if both input and output are attached to a terminal; otherwise false.