Table of Contents

Class ApplicationMainLoop<TInputRecord>

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

The main application loop that runs Terminal.Gui's UI rendering and event processing.

public class ApplicationMainLoop<TInputRecord> : IApplicationMainLoop<TInputRecord>, IDisposable where TInputRecord : struct

Type Parameters

TInputRecord

Type of raw input events, e.g. ConsoleKeyInfo for .NET driver

Inheritance
ApplicationMainLoop<TInputRecord>
Implements
IApplicationMainLoop<TInputRecord>
Inherited Members

Remarks

This class coordinates the Terminal.Gui application lifecycle by:

  • Processing buffered input events and translating them to UI events
  • Executing user timeout callbacks at scheduled intervals
  • Detecting which views need redrawing or layout updates
  • Rendering UI changes to the console output buffer
  • Managing cursor position and visibility
  • Throttling iterations to respect MaximumIterationsPerSecond

Properties

AnsiRequestScheduler

Gets the class responsible for sending ANSI escape requests which expect a response from the remote terminal e.g. Device Attribute Request

App

The Application this loop is associated with.

InputProcessor

Gets InputProcessor implementation that processes the mouse and keyboard input populated by IInput<TInputRecord> implementations on the input thread and translating to events on the UI thread.

InputQueue

The input events thread-safe collection. This is populated on separate thread by a IInput<TInputRecord>. Is drained as part of each Iteration() on the main loop thread.

Output

Gets the IOutput implementation responsible for rendering the OutputBuffer to the console using platform specific methods.

OutputBuffer

Gets the IOutputBuffer representing the desired screen state for console rendering.

SizeMonitor

Gets the ISizeMonitor implementation that tracks terminal size changes.

TimedEvents

Gets the ITimedEvents implementation that manages user-defined timeouts and periodic events.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

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

Initializes the class with the provided subcomponents

Iteration()

Perform a single iteration of the main loop then blocks for a fixed length of time, this method is designed to be run in a loop.