#nullable enable
namespace Terminal.Gui.App;
public static partial class Application // Screen related stuff; intended to hide Driver details
{
///
/// Gets or sets the size of the screen. By default, this is the size of the screen as reported by the .
///
///
///
/// If the has not been initialized, this will return a default size of 2048x2048; useful for unit tests.
///
///
public static Rectangle Screen
{
get => ApplicationImpl.Instance.Screen;
set => ApplicationImpl.Instance.Screen = value;
}
/// Invoked when the terminal's size changed. The new size of the terminal is provided.
public static event EventHandler>? ScreenChanged;
///
/// Called when the application's size has changed. Sets the size of all s and fires the
/// event.
///
/// The new screen size and position.
public static void RaiseScreenChangedEvent (Rectangle screen)
{
Screen = new (Point.Empty, screen.Size);
ScreenChanged?.Invoke (ApplicationImpl.Instance, new (screen));
foreach (Toplevel t in TopLevels)
{
t.OnSizeChanging (new (screen.Size));
t.SetNeedsLayout ();
}
LayoutAndDraw (true);
}
///
/// Gets or sets whether the screen will be cleared, and all Views redrawn, during the next Application iteration.
///
///
/// This is typical set to true when a View's changes and that view has no
/// SuperView (e.g. when is moved or resized.
///
internal static bool ClearScreenNextIteration
{
get => ApplicationImpl.Instance.ClearScreenNextIteration;
set => ApplicationImpl.Instance.ClearScreenNextIteration = value;
}
}