Table of Contents

Namespace Terminal.Gui.App

The App namespace holds @Terminal.Gui.Application and associated classes.

@Terminal.Gui.Application provides the main entry point and core application logic for Terminal.Gui applications. This static singleton class is responsible for initializing and shutting down the Terminal.Gui environment, managing the main event loop, handling input and output, and providing access to global application state.

Typical usage involves calling Application.Init() to initialize the application, creating and running a Window, and then calling Application.Shutdown() to clean up resources. The class also provides methods for culture support, idle handlers, and rendering the application state as a string.

Example Usage

Application.Init();
var win = new Window()
{
    Title = $"Example App ({Application.QuitKey} to quit)"
};
Application.Run(win);
win.Dispose();
Application.Shutdown();

See Also

Classes

Application

A static, singleton class representing the application. This class is the entry point for the application.

ApplicationImpl

Implementation of core Application methods using the modern main loop architecture with component factories for different platforms.

ApplicationMainLoop<T>

The main application loop that runs Terminal.Gui's UI rendering and event processing.

ApplicationNavigation

Helper class for Application navigation. Held by Navigation

ApplicationPopover

Helper class for support of IPopover views for Application. Held by Popover

CWPEventHelper

Provides helper methods for executing event-driven workflows in the Cancellable Work Pattern (CWP).

CWPPropertyHelper

Provides helper methods for executing property change workflows in the Cancellable Work Pattern (CWP).

CWPWorkflowHelper

Provides helper methods for executing single-phase and result-producing workflows in the Cancellable Work Pattern (CWP).

CancelEventArgs<T>

Provides data for events that can be cancelled without a changeable result in a cancellable workflow in the Cancellable Work Pattern (CWP).

Clipboard

Provides cut, copy, and paste support for the OS clipboard.

ClipboardBase

Shared abstract class to enforce rules from the implementation of the IClipboard interface.

EventArgs<T>

Provides data for events that convey the current value of a property or other value in a cancellable workflow (CWP).

GlobalResources

Provide static access to the ResourceManagerWrapper

IterationEventArgs

Event arguments for the Iteration event.

LogarithmicTimeout

Implements a logarithmic increasing timeout.

Logging

Singleton logging instance class. Do not use console loggers with this class as it will interfere with Terminal.Gui screen output (i.e. use a file logger).

MainLoop

The main event loop of legacy v1 driver based applications.

NotInitializedException

Thrown when user code attempts to access a property or perform a method Exception type thrown when trying to use a property or method that is only supported after initialization, e.g. of an IApplicationMainLoop<T>

PopoverBaseImpl

Abstract base class for popover views in Terminal.Gui.

ResultEventArgs<T>

Provides data for events that produce a result in a cancellable workflow in the Cancellable Work Pattern (CWP).

RunState

The execution state for a Toplevel view.

RunStateEventArgs

Event arguments for events about RunState

SmoothAcceleratingTimeout

Timeout which accelerates slowly at first then fast up to a maximum speed. Use AdvanceStage() to increment the stage of the timer (e.g. in your timer callback code).

TimedEvents

Manages scheduled timeouts (timed callbacks) for the application.

Allows scheduling of callbacks to be invoked after a specified delay, with optional repetition. Timeouts are stored in a sorted list by their scheduled execution time (UTC ticks). Thread-safe for concurrent access.

Typical usage:

  1. Call Add(TimeSpan, Func<bool>) to schedule a callback.
  2. Call RunTimers() periodically (e.g., from the main loop) to execute due callbacks.
  3. Call Remove(object) to cancel a scheduled timeout.
Timeout

Represents a scheduled timeout for use with timer management APIs.

Encapsulates a callback function to be invoked after a specified time interval. The callback can optionally indicate whether the timeout should repeat.

Used by ITimedEvents and related timer systems to manage timed operations in the application.

TimeoutEventArgs

EventArgs for timeout events (e.g. Added)

ToplevelTransitionManager

Handles bespoke behaviours that occur when application top level changes.

ValueChangedEventArgs<T>

Provides data for events that notify of a completed property change in the Cancellable Work Pattern (CWP).

ValueChangingEventArgs<T>

Provides data for events that allow modification or cancellation of a property change in the Cancellable Work Pattern (CWP).

Interfaces

IApplication

Interface for instances that provide backing functionality to static gateway class Application.

IApplicationMainLoop<T>

Interface for the main application loop that runs the core Terminal.Gui UI rendering and event processing.

IClipboard

Definition to interact with the OS clipboard.

IMainLoopCoordinator

Interface for the main loop coordinator that manages UI loop initialization and threading.

IMouseGrabHandler

Defines a contract for tracking which View (if any) has 'grabbed' the mouse, giving it exclusive priority for mouse events such as movement, button presses, and release.

This is typically used for scenarios like dragging, scrolling, or any interaction where a view needs to receive all mouse events until the operation completes (e.g., a scrollbar thumb being dragged).

Usage pattern:

  1. Call GrabMouse(View?) to route all mouse events to a specific view.
  2. Call UngrabMouse() to release the grab and restore normal mouse routing.
  3. Listen to GrabbingMouse, GrabbedMouse, UnGrabbingMouse, and UnGrabbedMouse for grab lifecycle events.
IPopover

Defines the contract for a popover view in Terminal.Gui.

ITimedEvents

Manages timers.

IToplevelTransitionManager

Interface for class that handles bespoke behaviours that occur when application top level changes.