Table of Contents

Class Application

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

A static, singleton class providing the main application driver for Terminal.Gui apps.

public static class Application
Inheritance
Application
Inherited Members

Examples

// A simple Terminal.Gui app that creates a window with a frame and title with 
// 5 rows/columns of padding.
Application.Init();
var win = new Window ("Hello World - CTRL-Q to quit") {
    X = 5,
    Y = 5,
    Width = Dim.Fill (5),
    Height = Dim.Fill (5)
};
Application.Top.Add(win);
Application.Run();
Application.Shutdown();

Remarks

Creates a instance of MainLoop to process input events, handle timers and other sources of data. It is accessible via the MainLoop property.

You can hook up to the Iteration event to have your method invoked on each iteration of the MainLoop.

When invoked sets the SynchronizationContext to one that is tied to the mainloop, allowing user code to use async/await.

Fields

Driver

The current ConsoleDriver in use.

Iteration

This event is raised on each iteration of the MainLoop.

Resized

Invoked when the terminal was resized. The new size of the terminal is provided.

RootKeyEvent

Called for new KeyPress events before any processing is performed or views evaluate. Use for global key handling and/or debugging.

Return true to suppress the KeyPress event

RootMouseEvent

Merely a debugging aid to see the raw mouse events

Properties

AlternateBackwardKey

Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.

AlternateForwardKey

Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.

Current

The current Toplevel object. This is updated when Run(Func<Exception, bool>) enters and leaves to point to the current Toplevel .

EnableConsoleScrolling

The current EnableConsoleScrolling used in the terminal.

ExitRunLoopAfterFirstIteration

Set to true to cause the RunLoop method to exit after the first iterations. Set to false (the default) to cause the RunLoop to continue running until Application.RequestStop() is called.

HeightAsBuffer

This API is deprecated; use EnableConsoleScrolling instead.

IsMouseDisabled

Disable or enable the mouse. The mouse is enabled by default.

MainLoop

The MainLoop driver for the application

MdiChildes

Gets all the Mdi childes which represent all the not modal Toplevel from the MdiTop.

MdiTop

The Toplevel object used for the application on startup which IsMdiContainer is true.

MouseGrabView

The view that grabbed the mouse, to where will be routed all the mouse events.

QuitKey

Gets or sets the key to quit the application.

SupportedCultures

Gets all supported cultures by the application without the invariant language.

Top

The Toplevel object used for the application on startup (Top)

UseSystemConsole

If true, forces the use of the System.Console-based (see NetDriver) driver. The default is false.

WantContinuousButtonPressedView

The current View object that wants continuous mouse button pressed events.

Methods

Begin(Toplevel)

Building block API: Prepares the provided Toplevel for execution.

DoEvents()

Wakes up the mainloop that might be waiting on input, must be thread safe.

End(RunState)

Building block API: completes the execution of a Toplevel that was started with Begin(Toplevel) .

EnsuresTopOnFront()

Ensures that the superview of the most focused view is on front.

GrabMouse(View)

Grabs the mouse, forcing all mouse events to be routed to the specified view until UngrabMouse is called.

Init(ConsoleDriver, IMainLoopDriver)

Initializes a new instance of Terminal.Gui Application.

MakeCenteredRect(Size)

Returns a rectangle that is centered in the screen for the provided size.

MoveNext()

Move to the next Mdi child from the MdiTop.

MovePrevious()

Move to the previous Mdi child from the MdiTop.

Refresh()

Triggers a refresh of the entire display.

RequestStop(Toplevel)

Stops running the most recent Toplevel or the top if provided.

Run(Func<Exception, bool>)

Runs the application by calling Run(Toplevel, Func<Exception, bool>) with the value of Top.

Run(Toplevel, Func<Exception, bool>)

Runs the main loop on the given Toplevel container.

RunLoop(RunState, bool)

Building block API: Runs the MainLoop for the created Toplevel.

RunMainLoopIteration(ref RunState, bool, ref bool)

Run one iteration of the MainLoop.

Run<T>(Func<Exception, bool>, ConsoleDriver, IMainLoopDriver)

Runs the application by calling Run(Toplevel, Func<Exception, bool>) with a new instance of the specified Toplevel-derived class.

Calling Init(ConsoleDriver, IMainLoopDriver) first is not needed as this function will initialze the application.

Shutdown() must be called when the application is closing (typically after Run> has returned) to ensure resources are cleaned up and terminal settings restored.

Shutdown()

Shutdown an application initialized with Init(ConsoleDriver, IMainLoopDriver).

UngrabMouse()

Releases the mouse grab, so mouse events will be routed to the view on which the mouse is.

Events

GrabbedMouse

Event to be invoked when a view grab the mouse.

GrabbingMouse

Invoked when a view wants to grab the mouse; can be canceled.

NotifyNewRunState

Notify that a new Application.RunState was created (Begin(Toplevel) was called). The token is created in Begin(Toplevel) and this event will be fired before that function exits.

NotifyStopRunState

Notify that a existent Application.RunState is stopping (End(RunState) was called).

UnGrabbedMouse

Event to be invoked when a view ungrab the mouse.

UnGrabbingMouse

Invoked when a view wants ungrab the mouse; can be canceled.