Method Init
Init(string?)
Initializes a new instance of Terminal.Gui Application.
[RequiresUnreferencedCode("AOT")]
[RequiresDynamicCode("AOT")]
IApplication Init(string? driverName = null)
Parameters
driverNamestringThe short name (e.g. "dotnet", "windows", "unix", or "fake") of the IDriver to use. If not specified the default driver for the platform will be used.
Returns
- IApplication
This instance for fluent API chaining.
Remarks
Call this method once per instance (or after Dispose() has been called).
This function loads the right IDriver for the platform, creates a main loop coordinator, initializes keyboard and mouse handlers, and subscribes to driver events.
Dispose() must be called when the application is closing (typically after Run<TRunnable>(Func<Exception, bool>?, string?) has returned) to ensure all resources are cleaned up (disposed) and terminal settings are restored.
Supports fluent API with automatic resource management:
Recommended pattern (using statement):
using (var app = Application.Create().Init())
{
app.Run<MyDialog>();
var result = app.GetResult<MyResultType>();
} // app.Dispose() called automatically
Alternative pattern (manual disposal):
var app = Application.Create().Init();
app.Run<MyDialog>();
var result = app.GetResult<MyResultType>();
app.Dispose(); // Must call explicitly
Note: Runnables created by Run<TRunnable>(Func<Exception, bool>?, string?) are automatically disposed when that method returns. Runnables passed to Run(IRunnable, Func<Exception, bool>?) must be disposed by the caller.