Class Application
The application driver for gui.cs
Inheritance
Namespace: Terminal.Gui
Assembly: Terminal.Gui.dll
Syntax
public static class Application
Remarks
You can hook up to the Iteration event to have your method invoked on each iteration of the mainloop.
Creates a mainloop to process input events, handle timers and other sources of data. It is accessible via the MainLoop property.
When invoked sets the SynchronizationContext to one that is tied to the mainloop, allowing user code to use async/await.
Fields
Driver
The current Console Driver in use.
Declaration
public static Terminal.Gui.ConsoleDriver Driver;
Field Value
Type | Description |
---|---|
ConsoleDriver | To be added. |
RootMouseEvent
Merely a debugging aid to see the raw mouse events
Declaration
public static Action<Terminal.Gui.MouseEvent> RootMouseEvent;
Field Value
Type | Description |
---|---|
System.Action<MouseEvent> | To be added. |
UseSystemConsole
If set, it forces the use of the System.Console-based driver.
Declaration
public static bool UseSystemConsole;
Field Value
Type | Description |
---|---|
System.Boolean | To be added. |
Properties
Current
The current toplevel object. This is updated when Application.Run enters and leaves and points to the current toplevel.
Declaration
public static Terminal.Gui.Toplevel Current { get; }
Property Value
Type | Description |
---|---|
Toplevel | The current. |
MainLoop
The mainloop driver for the applicaiton
Declaration
public static Mono.Terminal.MainLoop MainLoop { get; }
Property Value
Type | Description |
---|---|
MainLoop | The main loop. |
Top
The Toplevel object used for the application on startup.
Declaration
public static Terminal.Gui.Toplevel Top { get; }
Property Value
Type | Description |
---|---|
Toplevel | The top. |
Methods
Begin(Toplevel)
Building block API: Prepares the provided toplevel for execution.
Declaration
public static Terminal.Gui.Application.RunState Begin (Terminal.Gui.Toplevel toplevel);
Parameters
Type | Name | Description |
---|---|---|
Toplevel | toplevel | Toplevel to prepare execution for. |
Returns
Type | Description |
---|---|
The runstate handle that needs to be passed to the End() method upon completion. |
Remarks
This method prepares the provided toplevel for running with the focus, it adds this to the list of toplevels, sets up the mainloop to process the event, lays out the subviews, focuses the first element, and draws the toplevel in the screen. This is usually followed by executing the RunLoop(Application+RunState, Boolean) method, and then the End(Application+RunState) method upon termination which will undo these changes.
End(Application+RunState)
Building block API: completes the exection of a Toplevel that was started with Begin.
Declaration
public static void End (Terminal.Gui.Application.RunState runState);
Parameters
Type | Name | Description |
---|---|---|
runState | The runstate returned by the Begin(Toplevel) method. |
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 (Terminal.Gui.View view);
Parameters
Type | Name | Description |
---|---|---|
View | view | View that will receive all mouse events until UngrabMouse is invoked. |
Init()
Initializes the Application
Declaration
public static void Init ();
MakeCenteredRect(Size)
Returns a rectangle that is centered in the screen for the provided size.
Declaration
public static Terminal.Gui.Rect MakeCenteredRect (Terminal.Gui.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()
Stops running the most recent toplevel
Declaration
public static void RequestStop ();
Run()
Runs the application with the built-in toplevel view
Declaration
public static void Run ();
Run(Toplevel)
Runs the main loop on the given container.
Declaration
public static void Run (Terminal.Gui.Toplevel view);
Parameters
Type | Name | Description |
---|---|---|
Toplevel | view | To be added. |
Remarks
This method is used to start processing events for the main application, but it is also used to run modal dialog boxes.
To make a toplevel stop execution, set the "Running" property to false.
This is equivalent to calling Begin on the toplevel view, followed by RunLoop with the returned value, and then calling end on the return value.
Alternatively, if your program needs to control the main loop and needs to process events manually, you can invoke Begin to set things up manually and then repeatedly call RunLoop with the wait parameter set to false. By doing this the RunLoop method will only process any pending events, timers, idle handlers and then return control immediately.
RunLoop(Application+RunState, Boolean)
Building block API: Runs the main loop for the created dialog
Declaration
public static void RunLoop (Terminal.Gui.Application.RunState state, bool wait = true);
Parameters
Type | Name | Description |
---|---|---|
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. |
Remarks
Use the wait parameter to control whether this is a blocking or non-blocking call.
UngrabMouse()
Releases the mouse grab, so mouse events will be routed to the view on which the mouse is.
Declaration
public static void UngrabMouse ();
Events
Iteration
This event is raised on each iteration of the main loop.
Declaration
public static event EventHandler Iteration;
Event Type
Type | Description |
---|---|
System.EventHandler | To be added. |
Remarks
See also System.Threading.Timeout