Class Application
A static, singleton class representing the application. This class is the entry point for the application.
public static class Application
- Inheritance
-
Application
- Inherited Members
Examples
Application.Init();
var win = new Window()
{
Title = $"Example App ({Application.QuitKey} to quit)"
};
Application.Run(win);
win.Dispose();
Application.Shutdown();
Fields
- DefaultMaximumIterationsPerSecond
Default value for MaximumIterationsPerSecond
- MaximumIterationsPerSecond
Maximum number of iterations of the main loop (and hence draws) to allow to occur per second. Defaults to DefaultMaximumIterationsPerSecond> which is a 40ms sleep after iteration (factoring in how long iteration took to run).
Note that not every iteration draws (see NeedsDraw). Only affects v2 drivers.
Properties
- ArrangeKey
Gets or sets the key to activate arranging views using the keyboard.
- Clipboard
Gets the clipboard for the application.
- Driver
Gets or sets the console driver being used.
- ForceDriver
Forces the use of the specified driver (one of "fake", "dotnet", "windows", or "unix"). If not specified, the driver is selected based on the platform.
- Initialized
Gets or sets whether the application has been initialized.
- Instance
Gets the singleton IApplication instance used by the legacy static Application model.
- IsMouseDisabled
Disable or enable the mouse. The mouse is enabled by default.
- KeyBindings
Gets the Application-scoped key bindings.
- Keyboard
Handles keyboard input and key bindings at the Application level.
- MainThreadId
Gets or sets the main thread ID for the application.
- Navigation
Gets the ApplicationNavigation instance for the current Application.
- NextTabGroupKey
Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.
- NextTabKey
Alternative key to navigate forwards through views. Tab is the primary key.
- PrevTabGroupKey
Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.
- PrevTabKey
Alternative key to navigate backwards through views. Shift+Tab is the primary key.
- QuitKey
Gets or sets the key to quit the application.
- Screen
Gets or sets the size of the screen. By default, this is the size of the screen as reported by the IDriver.
- StopAfterFirstIteration
Set to true to cause the session to stop running after first iteration.
- SupportedCultures
Gets all cultures supported by the application without the invariant language.
- TimedEvents
Handles recurring events. These are invoked on the main UI thread - allowing for safe updates to View instances.
- TopRunnable
The View that is on the top of the SessionStack.
- TopRunnableView
The View that is on the top of the SessionStack.
Methods
- AddTimeout(TimeSpan, Func<bool>)
Adds a timeout to the application.
- Begin(IRunnable)
Building block API: Creates a SessionToken and prepares the provided IRunnable for execution. Not usually called directly by applications. Use Run(IRunnable, Func<Exception, bool>?) instead.
- Create()
Creates a new IApplication instance.
- End(SessionToken)
Building block API: Ends the session associated with the token and completes the execution of an IRunnable. Not usually called directly by applications. Run(IRunnable, Func<Exception, bool>?) will automatically call this method when the session is stopped.
- GetDriverTypes()
Gets a list of IDriver types and type names that are available.
- GetSixels()
Gets the queue of sixel images to write out to screen when updating. If the terminal does not support Sixel, adding to this queue has no effect.
- Init(string?)
Initializes a new instance of Terminal.Gui Application.
- Invoke(Action)
Runs
actionon the main UI loop thread.
- Invoke(Action<IApplication>)
Runs
actionon the main UI loop thread.
- LayoutAndDraw(bool)
Causes any Runnables that need layout to be laid out, then draws any Runnables that need display. Only Views that need to be laid out (see NeedsLayout) will be laid out. Only Views that need to be drawn (see NeedsDraw) will be drawn.
- PositionCursor()
Calls PositionCursor() on the most focused view.
- RaiseKeyDownEvent(Key)
Called when the user presses a key (by the IDriver). Raises the cancelable KeyDown event, then calls NewKeyDownEvent(Key) on all top level views, and finally if the key was not handled, invokes any Application-scoped KeyBindings.
- RemoveTimeout(object)
Removes a previously scheduled timeout.
- RequestStop(IRunnable?)
Requests that the specified runnable session stop.
- Run(IRunnable, Func<Exception, bool>?)
Runs a new Session with the provided runnable view.
- Run<TRunnable>(Func<Exception, bool>?, string?)
Runs a new Session creating a IRunnable-derived object of type
TRunnableand calling Run(IRunnable, Func<Exception, bool>?). When the session is stopped, End(SessionToken) will be called.
- Shutdown()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Events
- ArrangeKeyChanged
Raised when ArrangeKey changes.
- ForceDriverChanged
Raised when ForceDriver changes.
- InitializedChanged
This event is raised after the Init(string?) and Dispose() methods have been called.
- IsMouseDisabledChanged
Raised when IsMouseDisabled changes.
- Iteration
This event is raised on each iteration of the main loop.
- KeyDown
Raised when the user presses a key.
Set Handled to true to indicate the key was handled and to prevent additional processing.
- KeyUp
Raised when the user releases a key.
Set Handled to true to indicate the key was handled and to prevent additional processing.
- MouseEvent
Raised when a mouse event occurs. Can be cancelled by setting Handled to true.
- NextTabGroupKeyChanged
Raised when NextTabGroupKey changes.
- NextTabKeyChanged
Raised when NextTabKey changes.
- PrevTabGroupKeyChanged
Raised when PrevTabGroupKey changes.
- PrevTabKeyChanged
Raised when PrevTabKey changes.
- QuitKeyChanged
Raised when QuitKey changes.
- SessionBegun
Raised when Begin(IRunnable) has been called and has created a new SessionToken.
- SessionEnded
Raised when End(SessionToken) was called and the session is stopping. The event args contain a reference to the IRunnable that was active during the session. This can be used to ensure the Runnable is disposed of properly.