Class Application
A static, singelton class provding the main application driver for Terminal.Gui apps.
Inheritance
System.Object
Application
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Terminal.Gui.dll
Syntax
public static class Application
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();
Fields
Driver
Declaration
public static ConsoleDriver Driver
Field Value
Iteration
This event is raised on each iteration of the
MainLoop
Declaration
public static Action Iteration
Field Value
Type |
Description |
System.Action |
|
Resized
Invoked when the terminal was resized. The new size of the terminal is provided.
Declaration
public static Action<Application.ResizedEventArgs> Resized
Field Value
RootMouseEvent
Merely a debugging aid to see the raw mouse events
Declaration
public static Action<MouseEvent> RootMouseEvent
Field Value
UseSystemConsole
If set, it forces the use of the System.Console-based driver.
Declaration
public static bool UseSystemConsole
Field Value
Type |
Description |
System.Boolean |
|
Properties
AlwaysSetPosition
Used only by Terminal.Gui.NetDriver to forcing always moving the cursor position when writing to the screen.
Declaration
public static bool AlwaysSetPosition { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Current
Declaration
public static Toplevel Current { get; }
Property Value
HeightAsBuffer
Declaration
public static bool HeightAsBuffer { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
MainLoop
Declaration
public static MainLoop MainLoop { get; }
Property Value
Type |
Description |
MainLoop |
The main loop. |
Top
The
Toplevel object used for the application on startup (
Top)
Declaration
public static Toplevel Top { get; }
Property Value
Methods
Begin(Toplevel)
Building block API: Prepares the provided
Toplevel for execution.
Declaration
public static Application.RunState Begin(Toplevel toplevel)
Parameters
Type |
Name |
Description |
Toplevel |
toplevel |
Toplevel to prepare execution for. |
Returns
End(Application.RunState)
Declaration
public static void End(Application.RunState runState)
Parameters
GrabMouse(View)
Grabs the mouse, forcing all mouse events to be routed to the specified view until UngrabMouse is called.
Declaration
public static void GrabMouse(View view)
Parameters
Type |
Name |
Description |
View |
view |
View that will receive all mouse events until UngrabMouse is invoked. |
Init(ConsoleDriver, IMainLoopDriver)
Declaration
public static void Init(ConsoleDriver driver = null, IMainLoopDriver mainLoopDriver = null)
Parameters
Remarks
MakeCenteredRect(Size)
Returns a rectangle that is centered in the screen for the provided size.
Declaration
public static Rect MakeCenteredRect(Size size)
Parameters
Type |
Name |
Description |
Size |
size |
Size for the rectangle. |
Returns
Type |
Description |
Rect |
The centered rect. |
Refresh()
Triggers a refresh of the entire display.
Declaration
public static void Refresh()
RequestStop()
Declaration
public static void RequestStop()
Run(Func<Exception, Boolean>)
Declaration
public static void Run(Func<Exception, bool> errorHandler = null)
Parameters
Type |
Name |
Description |
System.Func<System.Exception, System.Boolean> |
errorHandler |
|
Run(Toplevel, Func<Exception, Boolean>)
Runs the main loop on the given
Toplevel container.
Declaration
public static void Run(Toplevel view, Func<Exception, bool> errorHandler = null)
Parameters
Type |
Name |
Description |
Toplevel |
view |
The Toplevel tu run modally. |
System.Func<System.Exception, System.Boolean> |
errorHandler |
Handler for any unhandled exceptions (resumes when returns true, rethrows when null). |
Run<T>(Func<Exception, Boolean>)
Declaration
public static void Run<T>(Func<Exception, bool> errorHandler = null)
where T : Toplevel, new()
Parameters
Type |
Name |
Description |
System.Func<System.Exception, System.Boolean> |
errorHandler |
|
Type Parameters
RunLoop(Application.RunState, Boolean)
Building block API: Runs the main loop for the created dialog
Declaration
public static void RunLoop(Application.RunState state, bool wait = true)
Parameters
Type |
Name |
Description |
Application.RunState |
state |
The state returned by the Begin method. |
System.Boolean |
wait |
By default this is true which will execute the runloop waiting for events, if you pass false, you can use this method to run a single iteration of the events. |
Shutdown()
Declaration
public static void Shutdown()
UngrabMouse()
Releases the mouse grab, so mouse events will be routed to the view on which the mouse is.
Declaration
public static void UngrabMouse()