Rename Toplevel.Running to Toplevel.IsRunning

Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-20 12:29:25 +00:00
parent 48aed9972d
commit c8c38ae46a
15 changed files with 42 additions and 42 deletions

View File

@@ -162,7 +162,7 @@ public partial class ApplicationImpl
// === 1. Stop all running toplevels ===
foreach (Toplevel? t in SessionStack)
{
t!.Running = false;
t!.IsRunning = false;
}
// === 2. Close and dispose popover ===

View File

@@ -198,11 +198,11 @@ public partial class ApplicationImpl
SessionToken rs = Begin (view);
Current.Running = true;
Current.IsRunning = true;
var firstIteration = true;
while (SessionStack.TryPeek (out Toplevel? found) && found == view && view.Running)
while (SessionStack.TryPeek (out Toplevel? found) && found == view && view.IsRunning)
{
if (Coordinator is null)
{
@@ -302,7 +302,7 @@ public partial class ApplicationImpl
return;
}
top.Running = false;
top.IsRunning = false;
}
/// <inheritdoc/>
@@ -327,7 +327,7 @@ public partial class ApplicationImpl
public void Invoke (Action<IApplication>? action)
{
// If we are already on the main UI thread
if (Current is { Running: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId)
if (Current is { IsRunning: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId)
{
action?.Invoke (this);
@@ -350,7 +350,7 @@ public partial class ApplicationImpl
public void Invoke (Action action)
{
// If we are already on the main UI thread
if (Current is { Running: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId)
if (Current is { IsRunning: true } && MainThreadId == Thread.CurrentThread.ManagedThreadId)
{
action?.Invoke ();

View File

@@ -313,7 +313,7 @@ public interface IApplication
/// <remarks>
/// <para>This will cause <see cref="Run(Toplevel, Func{Exception, bool})"/> to return.</para>
/// <para>
/// Calling <see cref="RequestStop(Toplevel)"/> is equivalent to setting the <see cref="Toplevel.Running"/>
/// Calling <see cref="RequestStop(Toplevel)"/> is equivalent to setting the <see cref="Toplevel.IsRunning"/>
/// property on the specified <see cref="Toplevel"/> to <see langword="false"/>.
/// </para>
/// </remarks>

View File

@@ -8,7 +8,7 @@ namespace Terminal.Gui.Views;
/// <para>
/// Toplevel views can run as modal (popup) views, started by calling
/// <see cref="IApplication.Run(Toplevel, Func{Exception, bool})"/>. They return control to the caller when
/// <see cref="IApplication.RequestStop(Toplevel)"/> has been called (which sets the <see cref="Toplevel.Running"/>
/// <see cref="IApplication.RequestStop(Toplevel)"/> has been called (which sets the <see cref="Toplevel.IsRunning"/>
/// property to <c>false</c>).
/// </para>
/// <para>
@@ -83,7 +83,7 @@ public partial class Toplevel : View
// TODO: IRunnable: Re-implement as a property on IRunnable
/// <summary>Gets or sets whether the main loop for this <see cref="Toplevel"/> is running or not.</summary>
/// <remarks>Setting this property directly is discouraged. Use <see cref="IApplication.RequestStop()"/> instead.</remarks>
public bool Running { get; set; }
public bool IsRunning { get; set; }
// TODO: IRunnable: Re-implement in IRunnable
/// <summary>

View File

@@ -16,11 +16,11 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper)
public void QuitKey_ViaApplication_Stops (TestDriver d)
{
using GuiTestContext context = With.A<Window> (40, 10, d);
Assert.True (context.App?.Current!.Running);
Assert.True (context.App?.Current!.IsRunning);
Toplevel? top = context.App?.Current;
context.Then ((_) => context!.App?.Keyboard.RaiseKeyDownEvent (Application.QuitKey));
Assert.False (top!.Running);
Assert.False (top!.IsRunning);
}
[Theory]
@@ -28,12 +28,12 @@ public class GuiTestContextKeyEventTests (ITestOutputHelper outputHelper)
public void QuitKey_ViaEnqueueKey_Stops (TestDriver d)
{
using GuiTestContext context = With.A<Window> (40, 10, d, _out);
Assert.True (context.App?.Current!.Running);
Assert.True (context.App?.Current!.IsRunning);
Toplevel? top = context.App?.Current;
context.EnqueueKeyEvent (Application.QuitKey);
Assert.False (top!.Running);
Assert.False (top!.IsRunning);
}
[Theory]

View File

@@ -43,7 +43,7 @@ public class GuiTestContextTests (ITestOutputHelper outputHelper)
public void With_New_A_Runs (TestDriver d)
{
using GuiTestContext context = With.A<Window> (40, 10, d, _out);
Assert.True (context.App!.Current!.Running);
Assert.True (context.App!.Current!.IsRunning);
Assert.NotEqual (Rectangle.Empty, context.App!.Screen);
}

View File

@@ -434,11 +434,11 @@ public class MenuBarv2Tests
.ScreenShot ("MenuBar initial state", _out)
.EnqueueKeyEvent (MenuBarv2.DefaultKey)
.AssertEqual ("_New file", app.Navigation!.GetFocused ()!.Title)
.AssertTrue (app?.Current!.Running)
.AssertTrue (app?.Current!.IsRunning)
.ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
.EnqueueKeyEvent (Application.QuitKey)
.AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu)
.AssertTrue (app!.Current!.Running);
.AssertTrue (app!.Current!.IsRunning);
}
[Theory]
@@ -480,7 +480,7 @@ public class MenuBarv2Tests
.ScreenShot ($"After {MenuBarv2.DefaultKey}", _out)
.EnqueueKeyEvent (Application.QuitKey)
.AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu)
.AssertTrue (app?.Current!.Running);
.AssertTrue (app?.Current!.IsRunning);
}
[Theory]

View File

@@ -139,7 +139,7 @@ public class PopoverMenuTests
.ScreenShot ($"After {Application.QuitKey}", _out)
.AssertFalse (app?.Popover!.Popovers.Cast<PopoverMenu> ().FirstOrDefault ()!.Visible)
.AssertNull (app?.Popover!.GetActivePopover ())
.AssertTrue (app?.Current!.Running);
.AssertTrue (app?.Current!.IsRunning);
}
[Theory]
@@ -231,11 +231,11 @@ public class PopoverMenuTests
.Then ((_) => app?.Popover!.Show (app?.Popover.Popovers.First ()))
.ScreenShot ("PopoverMenu after Show", _out)
.AssertEqual ("Cu_t", app?.Navigation!.GetFocused ()!.Title)
.AssertTrue (app?.Current!.Running)
.AssertTrue (app?.Current!.IsRunning)
.EnqueueKeyEvent (Application.QuitKey)
.ScreenShot ($"After {Application.QuitKey}", _out)
.AssertFalse (app?.Popover?.GetActivePopover () is PopoverMenu)
.AssertTrue (app?.Current!.Running);
.AssertTrue (app?.Current!.IsRunning);
}
[Theory]

View File

@@ -72,7 +72,7 @@ public class ApplicationStressTests
int tbNow = _tbCounter;
// Wait for Application.Current to be running to ensure timed events can be processed
while (Application.Current is null || Application.Current is { Running: false })
while (Application.Current is null || Application.Current is { IsRunning: false })
{
Thread.Sleep (1);
}

View File

@@ -385,14 +385,14 @@ public class ApplicationImplBeginEndTests
try
{
toplevel1 = new() { Id = "1", Running = true };
toplevel2 = new() { Id = "2", Running = true };
toplevel1 = new() { Id = "1", IsRunning = true };
toplevel2 = new() { Id = "2", IsRunning = true };
app.Begin (toplevel1);
app.Begin (toplevel2);
Assert.True (toplevel1.Running);
Assert.True (toplevel2.Running);
Assert.True (toplevel1.IsRunning);
Assert.True (toplevel2.IsRunning);
}
finally
{
@@ -404,8 +404,8 @@ public class ApplicationImplBeginEndTests
app.Shutdown ();
// Verify toplevels were stopped
Assert.False (toplevel1!.Running);
Assert.False (toplevel2!.Running);
Assert.False (toplevel1!.IsRunning);
Assert.False (toplevel2!.IsRunning);
}
}

View File

@@ -122,7 +122,7 @@ public class ApplicationImplTests
TimeSpan.FromMilliseconds (150),
() =>
{
Assert.True (top!.Running);
Assert.True (top!.IsRunning);
if (app.Current != null)
{
@@ -135,7 +135,7 @@ public class ApplicationImplTests
}
);
Assert.False (top!.Running);
Assert.False (top!.IsRunning);
// Blocks until the timeout call is hit
app.Run (top);
@@ -143,7 +143,7 @@ public class ApplicationImplTests
// We returned false above, so we should not have to remove the timeout
Assert.False (app.RemoveTimeout (timeoutToken));
Assert.False (top!.Running);
Assert.False (top!.IsRunning);
// BUGBUG: Shutdown sets Top to null, not End.
//Assert.Null (Application.Current);
@@ -226,7 +226,7 @@ public class ApplicationImplTests
TimeSpan.FromMilliseconds (150),
() =>
{
Assert.True (top!.Running);
Assert.True (top!.IsRunning);
if (app.Current != null)
{
@@ -273,7 +273,7 @@ public class ApplicationImplTests
TimeSpan.FromMilliseconds (150),
() =>
{
Assert.True (top!.Running);
Assert.True (top!.IsRunning);
if (app.Current != null)
{
@@ -284,7 +284,7 @@ public class ApplicationImplTests
}
);
Assert.False (top!.Running);
Assert.False (top!.IsRunning);
// Blocks until the timeout call is hit
app.Run (top);
@@ -292,7 +292,7 @@ public class ApplicationImplTests
// We returned false above, so we should not have to remove the timeout
Assert.False (app.RemoveTimeout (timeoutToken));
Assert.False (top!.Running);
Assert.False (top!.IsRunning);
Assert.NotNull (app.Current);
top.Dispose ();

View File

@@ -660,8 +660,8 @@ public class ApplicationTests
void OnApplicationOnIteration (object s, IterationEventArgs a)
{
Assert.True (top.Running);
top.Running = false;
Assert.True (top.IsRunning);
top.IsRunning = false;
}
}
@@ -681,7 +681,7 @@ public class ApplicationTests
return;
void OnApplicationOnIteration (object s, IterationEventArgs a) { top.Running = false; }
void OnApplicationOnIteration (object s, IterationEventArgs a) { top.IsRunning = false; }
}
[Fact]
@@ -893,7 +893,7 @@ public class ApplicationTests
Application.Run<TestToplevel> ();
Assert.NotNull (Application.Driver);
Assert.NotNull (Application.Current);
Assert.False (Application.Current!.Running);
Assert.False (Application.Current!.IsRunning);
Application.Current!.Dispose ();
Application.Shutdown ();
}

View File

@@ -39,7 +39,7 @@ public class SyncrhonizationContextTests
Task.Run (() =>
{
while (Application.Current is null || Application.Current is { Running: false })
while (Application.Current is null || Application.Current is { IsRunning: false })
{
Thread.Sleep (500);
}
@@ -56,7 +56,7 @@ public class SyncrhonizationContextTests
null
);
if (Application.Current is { Running: true })
if (Application.Current is { IsRunning: true })
{
Assert.False (success);
}

View File

@@ -101,7 +101,7 @@ public class SubViewTests
v1.Add (sv1);
Application.LayoutAndDraw ();
t.Running = false;
t.IsRunning = false;
}
}
}

View File

@@ -10,7 +10,7 @@ public class ToplevelTests
Assert.Equal ("Toplevel", top.SchemeName);
Assert.Equal ("Fill(Absolute(0))", top.Width.ToString ());
Assert.Equal ("Fill(Absolute(0))", top.Height.ToString ());
Assert.False (top.Running);
Assert.False (top.IsRunning);
Assert.False (top.Modal);
Assert.Null (top.MenuBar);