mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Changes before error encountered
Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
@@ -398,7 +398,11 @@ public static partial class Application // Run (Begin -> Run -> Layout/Draw -> E
|
|||||||
/// Set to true to cause <see cref="End"/> to be called after the first iteration. Set to false (the default) to
|
/// Set to true to cause <see cref="End"/> to be called after the first iteration. Set to false (the default) to
|
||||||
/// cause the application to continue running until Application.RequestStop () is called.
|
/// cause the application to continue running until Application.RequestStop () is called.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool EndAfterFirstIteration { get; set; }
|
public static bool EndAfterFirstIteration
|
||||||
|
{
|
||||||
|
get => ApplicationImpl.Instance.EndAfterFirstIteration;
|
||||||
|
set => ApplicationImpl.Instance.EndAfterFirstIteration = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Building block API: Runs the main loop for the created <see cref="Toplevel"/>.</summary>
|
/// <summary>Building block API: Runs the main loop for the created <see cref="Toplevel"/>.</summary>
|
||||||
/// <param name="state">The state returned by the <see cref="Begin(Toplevel)"/> method.</param>
|
/// <param name="state">The state returned by the <see cref="Begin(Toplevel)"/> method.</param>
|
||||||
|
|||||||
@@ -23,12 +23,31 @@ public static partial class Application // Screen related stuff; intended to hid
|
|||||||
/// Event handlers can set <see cref="SizeChangedEventArgs.Cancel"/> to <see langword="true"/> to prevent
|
/// Event handlers can set <see cref="SizeChangedEventArgs.Cancel"/> to <see langword="true"/> to prevent
|
||||||
/// <see cref="Application"/> from changing it's size to match the new terminal size.
|
/// <see cref="Application"/> from changing it's size to match the new terminal size.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static event EventHandler<SizeChangedEventArgs>? SizeChanging;
|
public static event EventHandler<SizeChangedEventArgs>? SizeChanging
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
if (ApplicationImpl.Instance is ApplicationImpl impl)
|
||||||
|
{
|
||||||
|
impl.SizeChanging += value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
if (ApplicationImpl.Instance is ApplicationImpl impl)
|
||||||
|
{
|
||||||
|
impl.SizeChanging -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Internal helper method for ApplicationImpl.ResetState to clear this event
|
// Internal helper method for ApplicationImpl.ResetState to clear this event
|
||||||
internal static void ClearSizeChangingEvent ()
|
internal static void ClearSizeChangingEvent ()
|
||||||
{
|
{
|
||||||
SizeChanging = null;
|
if (ApplicationImpl.Instance is ApplicationImpl impl)
|
||||||
|
{
|
||||||
|
impl.SizeChanging = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -39,24 +58,7 @@ public static partial class Application // Screen related stuff; intended to hid
|
|||||||
/// <returns><see lanword="true"/>if the size was changed.</returns>
|
/// <returns><see lanword="true"/>if the size was changed.</returns>
|
||||||
public static bool OnSizeChanging (SizeChangedEventArgs args)
|
public static bool OnSizeChanging (SizeChangedEventArgs args)
|
||||||
{
|
{
|
||||||
SizeChanging?.Invoke (null, args);
|
return ApplicationImpl.Instance.OnSizeChanging (args);
|
||||||
|
|
||||||
if (args.Cancel || args.Size is null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Screen = new (Point.Empty, args.Size.Value);
|
|
||||||
|
|
||||||
foreach (Toplevel t in TopLevels)
|
|
||||||
{
|
|
||||||
t.OnSizeChanging (new (args.Size));
|
|
||||||
t.SetNeedsLayout ();
|
|
||||||
}
|
|
||||||
|
|
||||||
LayoutAndDraw (true);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -128,6 +128,9 @@ public class ApplicationImpl : IApplication
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool ClearScreenNextIteration { get; set; }
|
public bool ClearScreenNextIteration { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool EndAfterFirstIteration { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ApplicationPopover? Popover { get; set; }
|
public ApplicationPopover? Popover { get; set; }
|
||||||
|
|
||||||
@@ -157,6 +160,11 @@ public class ApplicationImpl : IApplication
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This event is raised when the application's size changes.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<SizeChangedEventArgs>? SizeChanging;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void RequestStop () { RequestStop (null); }
|
public void RequestStop () { RequestStop (null); }
|
||||||
|
|
||||||
@@ -421,6 +429,29 @@ public class ApplicationImpl : IApplication
|
|||||||
_driver?.Refresh ();
|
_driver?.Refresh ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool OnSizeChanging (SizeChangedEventArgs args)
|
||||||
|
{
|
||||||
|
SizeChanging?.Invoke (null, args);
|
||||||
|
|
||||||
|
if (args.Cancel || args.Size is null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Screen = new (Point.Empty, args.Size.Value);
|
||||||
|
|
||||||
|
foreach (Toplevel t in TopLevels)
|
||||||
|
{
|
||||||
|
t.OnSizeChanging (new (args.Size));
|
||||||
|
t.SetNeedsLayout ();
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutAndDraw (true);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void ResetState (bool ignoreDisposed = false)
|
public void ResetState (bool ignoreDisposed = false)
|
||||||
{
|
{
|
||||||
@@ -463,9 +494,9 @@ public class ApplicationImpl : IApplication
|
|||||||
|
|
||||||
MainThreadId = -1;
|
MainThreadId = -1;
|
||||||
|
|
||||||
// These static properties need to be reset
|
// Reset iteration flags
|
||||||
Application.EndAfterFirstIteration = false;
|
EndAfterFirstIteration = false;
|
||||||
Application.ClearScreenNextIteration = false;
|
ClearScreenNextIteration = false;
|
||||||
|
|
||||||
// Driver stuff
|
// Driver stuff
|
||||||
if (_driver is { })
|
if (_driver is { })
|
||||||
@@ -488,12 +519,12 @@ public class ApplicationImpl : IApplication
|
|||||||
// Do not clear _lastMousePosition; Popovers require it to stay set with
|
// Do not clear _lastMousePosition; Popovers require it to stay set with
|
||||||
// last mouse pos.
|
// last mouse pos.
|
||||||
//_lastMousePosition = null;
|
//_lastMousePosition = null;
|
||||||
Application.CachedViewsUnderMouse.Clear ();
|
Mouse.CachedViewsUnderMouse.Clear ();
|
||||||
Application.ResetMouseState ();
|
Mouse.ResetState ();
|
||||||
|
|
||||||
// Keyboard events and bindings are now managed by the Keyboard instance
|
// Keyboard events and bindings are now managed by the Keyboard instance
|
||||||
|
|
||||||
Application.ClearSizeChangingEvent ();
|
SizeChanging = null;
|
||||||
|
|
||||||
Navigation = null;
|
Navigation = null;
|
||||||
|
|
||||||
@@ -623,11 +654,11 @@ public class ApplicationImpl : IApplication
|
|||||||
return new MainLoopCoordinator<T> (_timedEvents, inputBuffer, loop, cf);
|
return new MainLoopCoordinator<T> (_timedEvents, inputBuffer, loop, cf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Driver_KeyDown (object? sender, Key e) { Application.RaiseKeyDownEvent (e); }
|
private void Driver_KeyDown (object? sender, Key e) { Keyboard.RaiseKeyDownEvent (e); }
|
||||||
private void Driver_KeyUp (object? sender, Key e) { Application.RaiseKeyUpEvent (e); }
|
private void Driver_KeyUp (object? sender, Key e) { Keyboard.RaiseKeyUpEvent (e); }
|
||||||
private void Driver_MouseEvent (object? sender, MouseEventArgs e) { Application.RaiseMouseEvent (e); }
|
private void Driver_MouseEvent (object? sender, MouseEventArgs e) { Mouse.RaiseMouseEvent (e); }
|
||||||
|
|
||||||
private void Driver_SizeChanged (object? sender, SizeChangedEventArgs e) { Application.OnSizeChanging (e); }
|
private void Driver_SizeChanged (object? sender, SizeChangedEventArgs e) { OnSizeChanging (e); }
|
||||||
|
|
||||||
private static List<CultureInfo> GetAvailableCulturesFromEmbeddedResources ()
|
private static List<CultureInfo> GetAvailableCulturesFromEmbeddedResources ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,14 @@ public interface IApplication
|
|||||||
/// <summary>Gets or sets the console driver being used.</summary>
|
/// <summary>Gets or sets the console driver being used.</summary>
|
||||||
IConsoleDriver? Driver { get; set; }
|
IConsoleDriver? Driver { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is intended for unit tests and won't stop the <see cref="Application.RunLoop"/> if set to <see langword="true"/>
|
||||||
|
/// If the caller calls <see cref="Application.RunLoop"/> with the returned token from <see cref="Application.Begin"/>, setting
|
||||||
|
/// this property to <see langword="true"/> will cause only one iteration of the main loop to execute. The default is
|
||||||
|
/// <see langword="false"/>, which will cause the application to continue running until Application.RequestStop () is called.
|
||||||
|
/// </summary>
|
||||||
|
bool EndAfterFirstIteration { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether <see cref="Driver"/> will be forced to output only the 16 colors defined in
|
/// Gets or sets whether <see cref="Driver"/> will be forced to output only the 16 colors defined in
|
||||||
/// <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
|
/// <see cref="ColorName16"/>. The default is <see langword="false"/>, meaning 24-bit (TrueColor) colors will be output
|
||||||
@@ -101,6 +109,14 @@ public interface IApplication
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void LayoutAndDraw (bool forceRedraw = false);
|
public void LayoutAndDraw (bool forceRedraw = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the application's size changes. Sets the size of all <see cref="Toplevel"/>s and fires the
|
||||||
|
/// SizeChanging event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">The new size.</param>
|
||||||
|
/// <returns><see langword="true"/> if the size was changed.</returns>
|
||||||
|
bool OnSizeChanging (SizeChangedEventArgs args);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum number of iterations of the main loop (and hence draws)
|
/// Maximum number of iterations of the main loop (and hence draws)
|
||||||
/// to allow to occur per second. Defaults to <see cref="Application.DEFAULT_MAXIMUM_ITERATIONS_PER_SECOND"/> which is
|
/// to allow to occur per second. Defaults to <see cref="Application.DEFAULT_MAXIMUM_ITERATIONS_PER_SECOND"/> which is
|
||||||
|
|||||||
Reference in New Issue
Block a user