Table of Contents

Method Initialize

Namespace
Terminal.Gui.App
Assembly
Terminal.Gui.dll

Initialize(ITimedEvents, ConcurrentQueue<TInputRecord>, IInputProcessor, IOutput, IComponentFactory<TInputRecord>, IApplication?)

Initializes the main loop with its required dependencies.

void Initialize(ITimedEvents timedEvents, ConcurrentQueue<TInputRecord> inputQueue, IInputProcessor inputProcessor, IOutput output, IComponentFactory<TInputRecord> componentFactory, IApplication? app)

Parameters

timedEvents ITimedEvents

The ITimedEvents implementation for managing user-defined timeouts and periodic callbacks (e.g., AddTimeout(TimeSpan, Func<bool>)).

inputQueue ConcurrentQueue<TInputRecord>

The thread-safe queue containing raw input events populated by IInput<TInputRecord> on the input thread. This queue is drained by InputProcessor during each Iteration().

inputProcessor IInputProcessor

The IInputProcessor that translates raw input records (e.g., ConsoleKeyInfo) into Terminal.Gui events (Key, MouseEventArgs) and raises them on the main UI thread.

output IOutput

The IOutput implementation responsible for rendering the OutputBuffer to the console using platform-specific methods (e.g., Win32 APIs, ANSI escape sequences).

componentFactory IComponentFactory<TInputRecord>

The factory for creating driver-specific components. Used here to create the ISizeMonitor that tracks terminal size changes.

app IApplication

Remarks

This method is called by Terminal.Gui.App.MainLoopCoordinator<TInputRecord> during application startup to wire up all the components needed for the main loop to function. It must be called before Iteration() can be invoked.

Initialization order:

  1. Store references to timedEvents, inputQueue, inputProcessor, and output
  2. Create AnsiRequestScheduler for managing ANSI requests/responses
  3. Initialize OutputBuffer size to match current console dimensions
  4. Create ISizeMonitor using the componentFactory

After initialization, the main loop is ready to process events via Iteration().