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.
- Driver
Gets or sets the console driver being used.
- Force16Colors
Gets or sets whether Driver will be forced to output only the 16 colors defined in ColorName16. The default is false, meaning 24-bit (TrueColor) colors will be output as long as the selected IDriver supports TrueColor.
- 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.
- 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.
- SessionStack
Gets the stack of all active Toplevel sessions.
- Sixel
Collection of sixel images to write out to screen when updating. Only add to this collection if you are sure terminal supports sixel format.
- 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 Toplevel that is on the top of the SessionStack.
Methods
- AddTimeout(TimeSpan, Func<bool>)
Adds a timeout to the application.
- Begin(Toplevel)
Building block API: Creates a RunnableSessionToken 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.
- 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 Toplevels that need layout to be laid out, then draws any Toplevels 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(Toplevel?)
Requests that the currently running Session stop. The Session will stop after the current iteration completes.
- Run(Func<Exception, bool>?, string?)
Runs a new Session creating a Toplevel and calling Begin(Toplevel). When the session is stopped, End(SessionToken) will be called.
- Run(Toplevel, Func<Exception, bool>?)
Runs a new Session using the provided Toplevel view and calling Run(Toplevel, Func<Exception, bool>?). When the session is stopped, End(SessionToken) will be called..
- Run<TView>(Func<Exception, bool>?, string?)
Runs a new Session creating a Toplevel-derived object of type
TViewand calling Run(Toplevel, Func<Exception, bool>?). When the session is stopped, End(SessionToken) will be called.
- Shutdown()
Shutdown an application initialized with Init(string?).
Events
- InitializedChanged
This event is raised after the Init(string?) and Shutdown() methods have been called.
- 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.
- ScreenChanged
Raised when the terminal's size changed. The new size of the terminal is provided.
- SessionBegun
Raised when Begin(Toplevel) 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 Toplevel that was active during the session. This can be used to ensure the Toplevel is disposed of properly.