mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Fixed nullable warnings 2
This commit is contained in:
@@ -36,7 +36,7 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
/// </param>
|
||||
[RequiresUnreferencedCode ("AOT")]
|
||||
[RequiresDynamicCode ("AOT")]
|
||||
public static void Init (ConsoleDriver driver = null, string driverName = null) { InternalInit (driver, driverName); }
|
||||
public static void Init (ConsoleDriver? driver = null, string? driverName = null) { InternalInit (driver, driverName); }
|
||||
|
||||
internal static bool _initialized;
|
||||
internal static int _mainThreadId = -1;
|
||||
@@ -53,8 +53,8 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
[RequiresUnreferencedCode ("AOT")]
|
||||
[RequiresDynamicCode ("AOT")]
|
||||
internal static void InternalInit (
|
||||
ConsoleDriver driver = null,
|
||||
string driverName = null,
|
||||
ConsoleDriver? driver = null,
|
||||
string? driverName = null,
|
||||
bool calledViaRunT = false
|
||||
)
|
||||
{
|
||||
@@ -114,17 +114,17 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Type> drivers = GetDriverTypes ();
|
||||
Type driverType = drivers.FirstOrDefault (t => t.Name.Equals (ForceDriver, StringComparison.InvariantCultureIgnoreCase));
|
||||
List<Type?> drivers = GetDriverTypes ();
|
||||
Type? driverType = drivers.FirstOrDefault (t => t!.Name.Equals (ForceDriver, StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
if (driverType is { })
|
||||
{
|
||||
Driver = (ConsoleDriver)Activator.CreateInstance (driverType);
|
||||
Driver = (ConsoleDriver)Activator.CreateInstance (driverType)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException (
|
||||
$"Invalid driver name: {ForceDriver}. Valid names are {string.Join (", ", drivers.Select (t => t.Name))}"
|
||||
$"Invalid driver name: {ForceDriver}. Valid names are {string.Join (", ", drivers.Select (t => t!.Name))}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
|
||||
try
|
||||
{
|
||||
MainLoop = Driver.Init ();
|
||||
MainLoop = Driver!.Init ();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
@@ -159,22 +159,22 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
InitializedChanged?.Invoke (null, new (in _initialized));
|
||||
}
|
||||
|
||||
private static void Driver_SizeChanged (object sender, SizeChangedEventArgs e) { OnSizeChanging (e); }
|
||||
private static void Driver_KeyDown (object sender, Key e) { OnKeyDown (e); }
|
||||
private static void Driver_KeyUp (object sender, Key e) { OnKeyUp (e); }
|
||||
private static void Driver_MouseEvent (object sender, MouseEvent e) { OnMouseEvent (e); }
|
||||
private static void Driver_SizeChanged (object? sender, SizeChangedEventArgs e) { OnSizeChanging (e); }
|
||||
private static void Driver_KeyDown (object? sender, Key e) { OnKeyDown (e); }
|
||||
private static void Driver_KeyUp (object? sender, Key e) { OnKeyUp (e); }
|
||||
private static void Driver_MouseEvent (object? sender, MouseEvent e) { OnMouseEvent (e); }
|
||||
|
||||
/// <summary>Gets of list of <see cref="ConsoleDriver"/> types that are available.</summary>
|
||||
/// <returns></returns>
|
||||
[RequiresUnreferencedCode ("AOT")]
|
||||
public static List<Type> GetDriverTypes ()
|
||||
public static List<Type?> GetDriverTypes ()
|
||||
{
|
||||
// use reflection to get the list of drivers
|
||||
List<Type> driverTypes = new ();
|
||||
List<Type?> driverTypes = new ();
|
||||
|
||||
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ())
|
||||
{
|
||||
foreach (Type type in asm.GetTypes ())
|
||||
foreach (Type? type in asm.GetTypes ())
|
||||
{
|
||||
if (type.IsSubclassOf (typeof (ConsoleDriver)) && !type.IsAbstract)
|
||||
{
|
||||
@@ -207,5 +207,5 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
/// <remarks>
|
||||
/// Intended to support unit tests that need to know when the application has been initialized.
|
||||
/// </remarks>
|
||||
public static event EventHandler<EventArgs<bool>> InitializedChanged;
|
||||
public static event EventHandler<EventArgs<bool>>? InitializedChanged;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public static partial class Application // Keyboard handling
|
||||
/// <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
|
||||
/// <para>Fired after <see cref="KeyDown"/> and before <see cref="KeyUp"/>.</para>
|
||||
/// </remarks>
|
||||
public static event EventHandler<Key> KeyDown;
|
||||
public static event EventHandler<Key>? KeyDown;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the <see cref="ConsoleDriver"/> when the user presses a key. Fires the <see cref="KeyDown"/> event
|
||||
@@ -199,7 +199,7 @@ public static partial class Application // Keyboard handling
|
||||
/// <see cref="KeyDown"/> and <see cref="KeyUp"/> events.
|
||||
/// <para>Fired after <see cref="KeyDown"/>.</para>
|
||||
/// </remarks>
|
||||
public static event EventHandler<Key> KeyUp;
|
||||
public static event EventHandler<Key>? KeyUp;
|
||||
|
||||
/// <summary>
|
||||
/// Called by the <see cref="ConsoleDriver"/> when the user releases a key. Fires the <see cref="KeyUp"/> event
|
||||
@@ -304,7 +304,7 @@ public static partial class Application // Keyboard handling
|
||||
{
|
||||
if (OverlappedTop is { })
|
||||
{
|
||||
RequestStop (Current);
|
||||
RequestStop (Current!);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -9,32 +9,32 @@ public static partial class Application // Mouse handling
|
||||
public static bool IsMouseDisabled { get; set; }
|
||||
|
||||
/// <summary>The current <see cref="View"/> object that wants continuous mouse button pressed events.</summary>
|
||||
public static View WantContinuousButtonPressedView { get; private set; }
|
||||
public static View? WantContinuousButtonPressedView { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view that grabbed the mouse (e.g. for dragging). When this is set, all mouse events will be routed to
|
||||
/// this view until the view calls <see cref="UngrabMouse"/> or the mouse is released.
|
||||
/// </summary>
|
||||
public static View MouseGrabView { get; private set; }
|
||||
public static View? MouseGrabView { get; private set; }
|
||||
|
||||
/// <summary>Invoked when a view wants to grab the mouse; can be canceled.</summary>
|
||||
public static event EventHandler<GrabMouseEventArgs> GrabbingMouse;
|
||||
public static event EventHandler<GrabMouseEventArgs>? GrabbingMouse;
|
||||
|
||||
/// <summary>Invoked when a view wants un-grab the mouse; can be canceled.</summary>
|
||||
public static event EventHandler<GrabMouseEventArgs> UnGrabbingMouse;
|
||||
public static event EventHandler<GrabMouseEventArgs>? UnGrabbingMouse;
|
||||
|
||||
/// <summary>Invoked after a view has grabbed the mouse.</summary>
|
||||
public static event EventHandler<ViewEventArgs> GrabbedMouse;
|
||||
public static event EventHandler<ViewEventArgs>? GrabbedMouse;
|
||||
|
||||
/// <summary>Invoked after a view has un-grabbed the mouse.</summary>
|
||||
public static event EventHandler<ViewEventArgs> UnGrabbedMouse;
|
||||
public static event EventHandler<ViewEventArgs>? UnGrabbedMouse;
|
||||
|
||||
/// <summary>
|
||||
/// Grabs the mouse, forcing all mouse events to be routed to the specified view until <see cref="UngrabMouse"/>
|
||||
/// is called.
|
||||
/// </summary>
|
||||
/// <param name="view">View that will receive all mouse events until <see cref="UngrabMouse"/> is invoked.</param>
|
||||
public static void GrabMouse (View view)
|
||||
public static void GrabMouse (View? view)
|
||||
{
|
||||
if (view is null)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ internal static class ViewNavigation
|
||||
/// </summary>
|
||||
/// <param name="view"></param>
|
||||
/// <returns></returns>
|
||||
internal static View GetDeepestFocusedSubview (View view)
|
||||
internal static View? GetDeepestFocusedSubview (View? view)
|
||||
{
|
||||
if (view is null)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ internal static class ViewNavigation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the focus to the next view in the <see cref="TabIndexes"/> list. If the last view is focused, the first view is focused.
|
||||
/// Sets the focus to the next view in the <see cref="View.TabIndexes"/> list. If the last view is focused, the first view is focused.
|
||||
/// </summary>
|
||||
/// <param name="viewsInTabIndexes"></param>
|
||||
/// <param name="direction"></param>
|
||||
@@ -56,11 +56,11 @@ internal static class ViewNavigation
|
||||
{
|
||||
if (direction == NavigationDirection.Forward)
|
||||
{
|
||||
Application.Current.SuperView?.FocusNext ();
|
||||
Application.Current!.SuperView?.FocusNext ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.Current.SuperView?.FocusPrev ();
|
||||
Application.Current!.SuperView?.FocusPrev ();
|
||||
}
|
||||
|
||||
focusProcessed = true;
|
||||
@@ -83,7 +83,7 @@ internal static class ViewNavigation
|
||||
/// </summary>
|
||||
internal static void MoveNextView ()
|
||||
{
|
||||
View old = GetDeepestFocusedSubview (Application.Current.Focused);
|
||||
View? old = GetDeepestFocusedSubview (Application.Current!.Focused);
|
||||
|
||||
if (!Application.Current.FocusNext ())
|
||||
{
|
||||
@@ -105,8 +105,8 @@ internal static class ViewNavigation
|
||||
{
|
||||
if (Application.OverlappedTop is null)
|
||||
{
|
||||
Toplevel top = Application.Current.Modal ? Application.Current : Application.Top;
|
||||
top.FocusNext ();
|
||||
Toplevel? top = Application.Current!.Modal ? Application.Current : Application.Top;
|
||||
top!.FocusNext ();
|
||||
|
||||
if (top.Focused is null)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ internal static class ViewNavigation
|
||||
|
||||
internal static void MovePreviousView ()
|
||||
{
|
||||
View old = GetDeepestFocusedSubview (Application.Current.Focused);
|
||||
View? old = GetDeepestFocusedSubview (Application.Current!.Focused);
|
||||
|
||||
if (!Application.Current.FocusPrev ())
|
||||
{
|
||||
@@ -146,8 +146,8 @@ internal static class ViewNavigation
|
||||
{
|
||||
if (Application.OverlappedTop is null)
|
||||
{
|
||||
Toplevel top = Application.Current.Modal ? Application.Current : Application.Top;
|
||||
top.FocusPrev ();
|
||||
Toplevel? top = Application.Current!.Modal ? Application.Current : Application.Top;
|
||||
top!.FocusPrev ();
|
||||
|
||||
if (top.Focused is null)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
{
|
||||
// When `End ()` is called, it is possible `RunState.Toplevel` is a different object than `Top`.
|
||||
// This variable is set in `End` in this case so that `Begin` correctly sets `Top`.
|
||||
private static Toplevel _cachedRunStateToplevel;
|
||||
private static Toplevel? _cachedRunStateToplevel;
|
||||
|
||||
/// <summary>
|
||||
/// Notify that a new <see cref="RunState"/> was created (<see cref="Begin(Toplevel)"/> was called). The token is
|
||||
@@ -19,7 +19,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// must also subscribe to <see cref="NotifyStopRunState"/> and manually dispose of the <see cref="RunState"/> token
|
||||
/// when the application is done.
|
||||
/// </remarks>
|
||||
public static event EventHandler<RunStateEventArgs> NotifyNewRunState;
|
||||
public static event EventHandler<RunStateEventArgs>? NotifyNewRunState;
|
||||
|
||||
/// <summary>Notify that an existent <see cref="RunState"/> is stopping (<see cref="End(RunState)"/> was called).</summary>
|
||||
/// <remarks>
|
||||
@@ -27,7 +27,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// must also subscribe to <see cref="NotifyStopRunState"/> and manually dispose of the <see cref="RunState"/> token
|
||||
/// when the application is done.
|
||||
/// </remarks>
|
||||
public static event EventHandler<ToplevelEventArgs> NotifyStopRunState;
|
||||
public static event EventHandler<ToplevelEventArgs>? NotifyStopRunState;
|
||||
|
||||
/// <summary>Building block API: Prepares the provided <see cref="Toplevel"/> for execution.</summary>
|
||||
/// <returns>
|
||||
@@ -96,9 +96,9 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
throw new ObjectDisposedException (Top.GetType ().FullName);
|
||||
}
|
||||
}
|
||||
else if (OverlappedTop is { } && toplevel != Top && _topLevels.Contains (Top))
|
||||
else if (OverlappedTop is { } && toplevel != Top && _topLevels.Contains (Top!))
|
||||
{
|
||||
Top.OnLeave (toplevel);
|
||||
Top!.OnLeave (toplevel);
|
||||
}
|
||||
|
||||
// BUGBUG: We should not depend on `Id` internally.
|
||||
@@ -120,7 +120,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
}
|
||||
else
|
||||
{
|
||||
Toplevel dup = _topLevels.FirstOrDefault (x => x.Id == toplevel.Id);
|
||||
Toplevel? dup = _topLevels.FirstOrDefault (x => x.Id == toplevel.Id);
|
||||
|
||||
if (dup is null)
|
||||
{
|
||||
@@ -150,7 +150,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
if (toplevel.Visible)
|
||||
{
|
||||
Current?.OnDeactivate (toplevel);
|
||||
Toplevel previousCurrent = Current;
|
||||
Toplevel previousCurrent = Current!;
|
||||
Current = toplevel;
|
||||
Current.OnActivate (previousCurrent);
|
||||
|
||||
@@ -161,11 +161,10 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
refreshDriver = false;
|
||||
}
|
||||
}
|
||||
else if ((OverlappedTop != null
|
||||
&& toplevel != OverlappedTop
|
||||
else if ((toplevel != OverlappedTop
|
||||
&& Current?.Modal == true
|
||||
&& !_topLevels.Peek ().Modal)
|
||||
|| (OverlappedTop is { } && toplevel != OverlappedTop && Current?.Running == false))
|
||||
|| (toplevel != OverlappedTop && Current?.Running == false))
|
||||
{
|
||||
refreshDriver = false;
|
||||
MoveCurrent (toplevel);
|
||||
@@ -173,10 +172,10 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
else
|
||||
{
|
||||
refreshDriver = false;
|
||||
MoveCurrent (Current);
|
||||
MoveCurrent (Current!);
|
||||
}
|
||||
|
||||
toplevel.SetRelativeLayout (Driver.Screen.Size);
|
||||
toplevel.SetRelativeLayout (Driver!.Screen.Size);
|
||||
|
||||
toplevel.LayoutSubviews ();
|
||||
toplevel.PositionToplevels ();
|
||||
@@ -216,7 +215,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
internal static bool PositionCursor (View view)
|
||||
{
|
||||
// Find the most focused view and position the cursor there.
|
||||
View mostFocused = view?.MostFocused;
|
||||
View? mostFocused = view?.MostFocused;
|
||||
|
||||
if (mostFocused is null)
|
||||
{
|
||||
@@ -233,7 +232,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
// If the view is not visible or enabled, don't position the cursor
|
||||
if (!mostFocused.Visible || !mostFocused.Enabled)
|
||||
{
|
||||
Driver.GetCursorVisibility (out CursorVisibility current);
|
||||
Driver!.GetCursorVisibility (out CursorVisibility current);
|
||||
|
||||
if (current != CursorVisibility.Invisible)
|
||||
{
|
||||
@@ -245,7 +244,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
|
||||
// If the view is not visible within it's superview, don't position the cursor
|
||||
Rectangle mostFocusedViewport = mostFocused.ViewportToScreen (mostFocused.Viewport with { Location = Point.Empty });
|
||||
Rectangle superViewViewport = mostFocused.SuperView?.ViewportToScreen (mostFocused.SuperView.Viewport with { Location = Point.Empty }) ?? Driver.Screen;
|
||||
Rectangle superViewViewport = mostFocused.SuperView?.ViewportToScreen (mostFocused.SuperView.Viewport with { Location = Point.Empty }) ?? Driver!.Screen;
|
||||
|
||||
if (!superViewViewport.IntersectsWith (mostFocusedViewport))
|
||||
{
|
||||
@@ -254,7 +253,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
|
||||
Point? cursor = mostFocused.PositionCursor ();
|
||||
|
||||
Driver.GetCursorVisibility (out CursorVisibility currentCursorVisibility);
|
||||
Driver!.GetCursorVisibility (out CursorVisibility currentCursorVisibility);
|
||||
|
||||
if (cursor is { })
|
||||
{
|
||||
@@ -306,7 +305,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// <returns>The created <see cref="Toplevel"/> object. The caller is responsible for disposing this object.</returns>
|
||||
[RequiresUnreferencedCode ("AOT")]
|
||||
[RequiresDynamicCode ("AOT")]
|
||||
public static Toplevel Run (Func<Exception, bool> errorHandler = null, ConsoleDriver driver = null) { return Run<Toplevel> (errorHandler, driver); }
|
||||
public static Toplevel Run (Func<Exception, bool>? errorHandler = null, ConsoleDriver? driver = null) { return Run<Toplevel> (errorHandler, driver); }
|
||||
|
||||
/// <summary>
|
||||
/// Runs the application by creating a <see cref="Toplevel"/>-derived object of type <c>T</c> and calling
|
||||
@@ -331,7 +330,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// <returns>The created T object. The caller is responsible for disposing this object.</returns>
|
||||
[RequiresUnreferencedCode ("AOT")]
|
||||
[RequiresDynamicCode ("AOT")]
|
||||
public static T Run<T> (Func<Exception, bool> errorHandler = null, ConsoleDriver driver = null)
|
||||
public static T Run<T> (Func<Exception, bool>? errorHandler = null, ConsoleDriver? driver = null)
|
||||
where T : Toplevel, new ()
|
||||
{
|
||||
if (!_initialized)
|
||||
@@ -385,7 +384,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// RELEASE builds only: Handler for any unhandled exceptions (resumes when returns true,
|
||||
/// rethrows when null).
|
||||
/// </param>
|
||||
public static void Run (Toplevel view, Func<Exception, bool> errorHandler = null)
|
||||
public static void Run (Toplevel view, Func<Exception, bool>? errorHandler = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull (view);
|
||||
|
||||
@@ -460,7 +459,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// reset, repeating the invocation. If it returns false, the timeout will stop and be removed. The returned value is a
|
||||
/// token that can be used to stop the timeout by calling <see cref="RemoveTimeout(object)"/>.
|
||||
/// </remarks>
|
||||
public static object AddTimeout (TimeSpan time, Func<bool> callback) { return MainLoop?.AddTimeout (time, callback); }
|
||||
public static object AddTimeout (TimeSpan time, Func<bool> callback) { return MainLoop!.AddTimeout (time, callback); }
|
||||
|
||||
/// <summary>Removes a previously scheduled timeout</summary>
|
||||
/// <remarks>The token parameter is the value returned by <see cref="AddTimeout"/>.</remarks>
|
||||
@@ -498,8 +497,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
public static void Refresh ()
|
||||
{
|
||||
// TODO: Figure out how to remove this call to ClearContents. Refresh should just repaint damaged areas, not clear
|
||||
Driver.ClearContents ();
|
||||
View last = null;
|
||||
Driver!.ClearContents ();
|
||||
|
||||
foreach (Toplevel v in _topLevels.Reverse ())
|
||||
{
|
||||
@@ -509,8 +507,6 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
v.SetSubViewNeedsDisplay ();
|
||||
v.Draw ();
|
||||
}
|
||||
|
||||
last = v;
|
||||
}
|
||||
|
||||
Driver.Refresh ();
|
||||
@@ -518,11 +514,11 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
|
||||
/// <summary>This event is raised on each iteration of the main loop.</summary>
|
||||
/// <remarks>See also <see cref="Timeout"/></remarks>
|
||||
public static event EventHandler<IterationEventArgs> Iteration;
|
||||
public static event EventHandler<IterationEventArgs>? Iteration;
|
||||
|
||||
/// <summary>The <see cref="MainLoop"/> driver for the application</summary>
|
||||
/// <value>The main loop.</value>
|
||||
internal static MainLoop MainLoop { get; private set; }
|
||||
internal static MainLoop? MainLoop { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set to true to cause <see cref="End"/> to be called after the first iteration. Set to false (the default) to
|
||||
@@ -661,17 +657,17 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
/// property on the currently running <see cref="Toplevel"/> to false.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static void RequestStop (Toplevel top = null)
|
||||
public static void RequestStop (Toplevel? top = null)
|
||||
{
|
||||
if (OverlappedTop is null || top is null || (OverlappedTop is null && top is { }))
|
||||
if (OverlappedTop is null || top is null)
|
||||
{
|
||||
top = Current;
|
||||
}
|
||||
|
||||
if (OverlappedTop != null
|
||||
&& top.IsOverlappedContainer
|
||||
&& top!.IsOverlappedContainer
|
||||
&& top?.Running == true
|
||||
&& (Current?.Modal == false || (Current?.Modal == true && Current?.Running == false)))
|
||||
&& (Current?.Modal == false || Current is { Modal: true, Running: false }))
|
||||
{
|
||||
OverlappedTop.RequestStop ();
|
||||
}
|
||||
@@ -679,7 +675,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
&& top != Current
|
||||
&& Current?.Running == true
|
||||
&& Current?.Modal == true
|
||||
&& top.Modal
|
||||
&& top!.Modal
|
||||
&& top.Running)
|
||||
{
|
||||
var ev = new ToplevelClosingEventArgs (Current);
|
||||
@@ -708,13 +704,13 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
&& top != Current
|
||||
&& Current?.Modal == false
|
||||
&& Current?.Running == true
|
||||
&& !top.Running)
|
||||
&& !top!.Running)
|
||||
|| (OverlappedTop != null
|
||||
&& top != OverlappedTop
|
||||
&& top != Current
|
||||
&& Current?.Modal == false
|
||||
&& Current?.Running == false
|
||||
&& !top.Running
|
||||
&& !top!.Running
|
||||
&& _topLevels.ToArray () [1].Running))
|
||||
{
|
||||
MoveCurrent (top);
|
||||
@@ -722,7 +718,7 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
else if (OverlappedTop != null
|
||||
&& Current != top
|
||||
&& Current?.Running == true
|
||||
&& !top.Running
|
||||
&& !top!.Running
|
||||
&& Current?.Modal == true
|
||||
&& top.Modal)
|
||||
{
|
||||
@@ -734,9 +730,9 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
&& Current == top
|
||||
&& OverlappedTop?.Running == true
|
||||
&& Current?.Running == true
|
||||
&& top.Running
|
||||
&& top!.Running
|
||||
&& Current?.Modal == true
|
||||
&& top.Modal)
|
||||
&& top!.Modal)
|
||||
{
|
||||
// The OverlappedTop was requested to stop inside a modal Toplevel which is the Current and top,
|
||||
// both are the same, so needed to set the Current.Running to false too.
|
||||
@@ -747,13 +743,13 @@ public static partial class Application // Run (Begin, Run, End, Stop)
|
||||
{
|
||||
Toplevel currentTop;
|
||||
|
||||
if (top == Current || (Current?.Modal == true && !top.Modal))
|
||||
if (top == Current || (Current?.Modal == true && !top!.Modal))
|
||||
{
|
||||
currentTop = Current;
|
||||
currentTop = Current!;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentTop = top;
|
||||
currentTop = top!;
|
||||
}
|
||||
|
||||
if (!currentTop.Running)
|
||||
|
||||
@@ -10,7 +10,7 @@ public static partial class Application // Toplevel handling
|
||||
|
||||
/// <summary>The <see cref="Toplevel"/> object used for the application on startup (<seealso cref="Top"/>)</summary>
|
||||
/// <value>The top.</value>
|
||||
public static Toplevel Top { get; private set; }
|
||||
public static Toplevel? Top { get; private set; }
|
||||
|
||||
// TODO: Determine why this can't just return _topLevels.Peek()?
|
||||
/// <summary>
|
||||
@@ -22,7 +22,7 @@ public static partial class Application // Toplevel handling
|
||||
/// This will only be distinct from <see cref="Application.Top"/> in scenarios where <see cref="Toplevel.IsOverlappedContainer"/> is <see langword="true"/>.
|
||||
/// </remarks>
|
||||
/// <value>The current.</value>
|
||||
public static Toplevel Current { get; private set; }
|
||||
public static Toplevel? Current { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// If <paramref name="topLevel"/> is not already Current and visible, finds the last Modal Toplevel in the stack and makes it Current.
|
||||
@@ -195,7 +195,7 @@ public static partial class Application // Toplevel handling
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
public static event EventHandler<SizeChangedEventArgs> SizeChanging;
|
||||
public static event EventHandler<SizeChangedEventArgs>? SizeChanging;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the application's size changes. Sets the size of all <see cref="Toplevel"/>s and fires the
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
//
|
||||
// ConsoleDriver.cs: Base class for Terminal.Gui ConsoleDriver implementations.
|
||||
//
|
||||
@@ -16,7 +17,7 @@ public abstract class ConsoleDriver
|
||||
{
|
||||
// As performance is a concern, we keep track of the dirty lines and only refresh those.
|
||||
// This is in addition to the dirty flag on each cell.
|
||||
internal bool [] _dirtyLines;
|
||||
internal bool []? _dirtyLines;
|
||||
|
||||
// QUESTION: When non-full screen apps are supported, will this represent the app size, or will that be in Application?
|
||||
/// <summary>Gets the location and size of the terminal screen.</summary>
|
||||
@@ -443,7 +444,7 @@ public abstract class ConsoleDriver
|
||||
public abstract bool SetCursorVisibility (CursorVisibility visibility);
|
||||
|
||||
/// <summary>The event fired when the terminal is resized.</summary>
|
||||
public event EventHandler<SizeChangedEventArgs> SizeChanged;
|
||||
public event EventHandler<SizeChangedEventArgs>? SizeChanged;
|
||||
|
||||
/// <summary>Suspends the application (e.g. on Linux via SIGTSTP) and upon resume, resets the console driver.</summary>
|
||||
/// <remarks>This is only implemented in <see cref="CursesDriver"/>.</remarks>
|
||||
|
||||
@@ -222,10 +222,10 @@ public class Margin : Adornment
|
||||
// Adjust the shadow such that it is drawn aligned with the Border
|
||||
if (ShadowStyle != ShadowStyle.None && _rightShadow is { } && _bottomShadow is { })
|
||||
{
|
||||
_rightShadow.Y = Parent.Border.Thickness.Top > 0
|
||||
_rightShadow.Y = Parent is { } && Parent.Border.Thickness.Top > 0
|
||||
? Parent.Border.Thickness.Top - (Parent.Border.Thickness.Top > 2 && Parent.Border.Settings.FastHasFlags (BorderSettings.Title) ? 1 : 0)
|
||||
: 1;
|
||||
_bottomShadow.X = Parent.Border.Thickness.Left > 0 ? Parent.Border.Thickness.Left : 1;
|
||||
_bottomShadow.X = Parent is { } && Parent.Border.Thickness.Left > 0 ? Parent.Border.Thickness.Left : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ internal class ShadowView : View
|
||||
{
|
||||
var attr = Attribute.Default;
|
||||
|
||||
if (adornment.Parent.SuperView is { })
|
||||
if (adornment.Parent?.SuperView is { })
|
||||
{
|
||||
attr = adornment.Parent.SuperView.GetNormalColor ();
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ public abstract class Dim
|
||||
}
|
||||
|
||||
var newDim = new DimCombine (AddOrSubtract.Add, left, right);
|
||||
(left as DimView)?.Target.SetNeedsLayout ();
|
||||
(left as DimView)?.Target?.SetNeedsLayout ();
|
||||
|
||||
return newDim;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DimView : Dim
|
||||
public override bool Equals (object? other) { return other is DimView abs && abs.Target == Target && abs.Dimension == Dimension; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode () { return Target.GetHashCode (); }
|
||||
public override int GetHashCode () { return Target!.GetHashCode (); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the View the dimension is anchored to.
|
||||
|
||||
@@ -379,7 +379,7 @@ public abstract class Pos
|
||||
|
||||
if (left is PosView view)
|
||||
{
|
||||
view.Target.SetNeedsLayout ();
|
||||
view.Target?.SetNeedsLayout ();
|
||||
}
|
||||
|
||||
return newPos;
|
||||
@@ -408,7 +408,7 @@ public abstract class Pos
|
||||
|
||||
if (left is PosView view)
|
||||
{
|
||||
view.Target.SetNeedsLayout ();
|
||||
view.Target?.SetNeedsLayout ();
|
||||
}
|
||||
|
||||
return newPos;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PosView (View? view, Side side) : Pos
|
||||
public override bool Equals (object? other) { return other is PosView abs && abs.Target == Target && abs.Side == Side; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode () { return Target.GetHashCode (); }
|
||||
public override int GetHashCode () { return Target!.GetHashCode (); }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString ()
|
||||
|
||||
@@ -1594,7 +1594,7 @@ public class MenuBar : View, IDesignable
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool EnableForDesign<TContext> (in TContext context) where TContext : notnull
|
||||
public bool EnableForDesign<TContext> (ref readonly TContext context) where TContext : notnull
|
||||
{
|
||||
if (context is not Func<string, bool> actionFn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user