Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b0f050f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 21, 2025
a64b4bc
touching publish.yml
tig Mar 21, 2025
320384e
Merge branch 'v2_release' into v2_develop
tig Mar 21, 2025
4048436
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Mar 29, 2025
3b0311d
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 29, 2025
ae79c48
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 30, 2025
1c39896
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 1, 2025
9560cf3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 2, 2025
0795dd1
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 2, 2025
ca11609
Fixed UICatalog bugs. Added fluent tests.
tig Apr 2, 2025
c761249
marked v1 menu stuff as obsolte
tig Apr 2, 2025
5805515
Tweaks.
tig Apr 2, 2025
a3e823d
fixed unit tests
tig Apr 2, 2025
ba7fb21
general messing around
tig Apr 2, 2025
366cd89
general messing around
tig Apr 2, 2025
5a26e60
Playing with Fluent
tig Apr 2, 2025
01b5266
ColorScheme tweaks
tig Apr 3, 2025
52f487d
WIP: ColorScheme tweaks
tig Apr 3, 2025
5986301
Playing with Fluent
tig Apr 3, 2025
dba8049
Merged from laptop
tig Apr 3, 2025
cf9c0d0
Merged from laptop2
tig Apr 3, 2025
60183fa
Hacky-ish fixes to:
tig Apr 3, 2025
869c02a
Fixed Region bug preventing menus without borders from working
tig Apr 3, 2025
57fc308
Tweaks
tig Apr 3, 2025
edd3b5a
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 4, 2025
9a2a7a4
Fixed a bunch of CM issues
tig Apr 4, 2025
9c53486
Fixed OoptionSelector
tig Apr 5, 2025
fd31f49
ip
tig Apr 5, 2025
dd6c6a7
FixedCM issues
tig Apr 5, 2025
aa83191
Fixed CM issues2
tig Apr 5, 2025
d4c8b87
Revert "FixedCM issues"
tig Apr 5, 2025
bce9c2e
Reverted stuff
tig Apr 5, 2025
7d22a14
Found and fixed bug in AllViews_Center_Properly
tig Apr 5, 2025
5ed311f
Merge branch 'v2_develop' into v2_2975-v1Menu-Obsolete
tig Apr 5, 2025
4c25418
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 5, 2025
2850f83
Fixed CM issues2
tig Apr 5, 2025
c4b14d4
removed menuv2 onapplied.
tig Apr 5, 2025
47ae0e0
changed test time out to see if it helkps with ubuntu fails
tig Apr 5, 2025
e54f610
reset app on fail?
tig Apr 5, 2025
11fb9cc
back to 1500ms
tig Apr 5, 2025
d8ca951
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 6, 2025
d367b18
Made StatusBar nullable.
tig Apr 6, 2025
79f782b
Code Cleanup.
tig Apr 6, 2025
df661ea
HexEditor Code Cleanup.
tig Apr 6, 2025
a7201a7
HexEditor Code Cleanup.
tig Apr 6, 2025
663ee34
Back to 3000ms. Sigh.
tig Apr 6, 2025
2706cff
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 6, 2025
ba59936
Trying different logic
tig Apr 6, 2025
a628349
Trying different logic2
tig Apr 6, 2025
82c89f9
Fixed potential crash in runlop
tig Apr 6, 2025
21039c3
Fixed potential crash in runlop2
tig Apr 6, 2025
b04f638
Tweaked Spinner stuff
tig Apr 6, 2025
6796bb4
Removed TabView from TextEffects scenario. Not needed and possible cu…
tig Apr 6, 2025
9d3a652
back to 2000ms
tig Apr 6, 2025
8c5d7ac
WIP: Revamping menu scenarios
tig Apr 6, 2025
0a4740c
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 7, 2025
114deee
Menu Scenario refinements.
tig Apr 7, 2025
81310ce
fixed unit test
tig Apr 7, 2025
7a39979
Fixed warnings
tig Apr 7, 2025
7f08306
Fixed warnings2
tig Apr 7, 2025
a433f5e
Fixed File.Exit
tig Apr 7, 2025
f759174
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 7, 2025
89a0093
WIP: Dealing with QuitKey struggles
tig Apr 8, 2025
824e4cf
WIP: Dealing with QuitKey struggles 2
tig Apr 11, 2025
cd9339c
Merge branch 'v2_develop' into v2_2975-v1Menu-Obsolete
tig Apr 16, 2025
8e9c8a3
WIP: Dealing with QuitKey struggles 3
tig Apr 16, 2025
2366242
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 16, 2025
92aae38
Fixed ListView collection nav bug
tig Apr 16, 2025
f7d498d
Fixed a bunch of menu stuff.
tig Apr 17, 2025
f276514
Lots of refactoring and fixing
tig Apr 18, 2025
af5e739
Lots of unit test issues
tig Apr 18, 2025
801f8de
Merge branch 'v2_2975-v1Menu-Obsolete' of tig:tig/Terminal.Gui into v…
tig Apr 19, 2025
95370e0
Fixed DebugIDisposable issues
tig Apr 19, 2025
4f5a020
Fixed release build issue
tig Apr 19, 2025
4d028eb
Fixed release build issue 2
tig Apr 19, 2025
9f0cf82
DebugIDisposable -> EnableDebugIDisposableAsserts and more
tig Apr 19, 2025
69bed23
DebugIDisposable -> EnableDebugIDisposableAsserts and more 2
tig Apr 19, 2025
198cc37
Fixed Menus scenario - context menu
tig Apr 20, 2025
f13837e
Added @bdisp suggested assert. Commented it out as it breaks tests.
tig Apr 23, 2025
c3e2b04
Code cleanup
tig Apr 23, 2025
062f593
Fixed disposed but
tig Apr 23, 2025
0fc7527
Fixed UICatalog exit
tig Apr 23, 2025
b2aa649
Fixed Unit test I broke.
tig Apr 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Terminal.Gui/Application/Application.Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ public static partial class Application // Keyboard handling
/// <returns><see langword="true"/> if the key was handled.</returns>
public static bool RaiseKeyDownEvent (Key key)
{
Logging.Debug ($"{key}");

// TODO: Add a way to ignore certain keys, esp for debugging.
//#if DEBUG
// if (key == Key.Empty.WithAlt || key == Key.Empty.WithCtrl)
// {
// Logging.Debug ($"Ignoring {key}");
// return false;
// }
//#endif

// TODO: This should match standard event patterns
KeyDown?.Invoke (null, key);

Expand Down
13 changes: 8 additions & 5 deletions Terminal.Gui/Application/Application.Mouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void UngrabMouse ()
}

#if DEBUG_IDISPOSABLE
if (View.DebugIDisposable)
if (View.EnableDebugIDisposableAsserts)
{
ObjectDisposedException.ThrowIf (MouseGrabView.WasDisposed, MouseGrabView);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ internal static void RaiseMouseEvent (MouseEventArgs mouseEvent)
if (deepestViewUnderMouse is { })
{
#if DEBUG_IDISPOSABLE
if (View.DebugIDisposable && deepestViewUnderMouse.WasDisposed)
if (View.EnableDebugIDisposableAsserts && deepestViewUnderMouse.WasDisposed)
{
throw new ObjectDisposedException (deepestViewUnderMouse.GetType ().FullName);
}
Expand All @@ -174,8 +174,11 @@ internal static void RaiseMouseEvent (MouseEventArgs mouseEvent)
&& Popover?.GetActivePopover () as View is { Visible: true } visiblePopover
&& View.IsInHierarchy (visiblePopover, deepestViewUnderMouse, includeAdornments: true) is false)
{

visiblePopover.Visible = false;
// TODO: Build a use/test case for the popover not handling Quit
if (visiblePopover.InvokeCommand (Command.Quit) is true && visiblePopover.Visible)
{
visiblePopover.Visible = false;
}

// Recurse once so the event can be handled below the popover
RaiseMouseEvent (mouseEvent);
Expand Down Expand Up @@ -297,7 +300,7 @@ internal static bool HandleMouseGrab (View? deepestViewUnderMouse, MouseEventArg
if (MouseGrabView is { })
{
#if DEBUG_IDISPOSABLE
if (View.DebugIDisposable && MouseGrabView.WasDisposed)
if (View.EnableDebugIDisposableAsserts && MouseGrabView.WasDisposed)
{
throw new ObjectDisposedException (MouseGrabView.GetType ().FullName);
}
Expand Down
32 changes: 25 additions & 7 deletions Terminal.Gui/Application/Application.Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static RunState Begin (Toplevel toplevel)
var rs = new RunState (toplevel);

#if DEBUG_IDISPOSABLE
if (View.DebugIDisposable && Top is { } && toplevel != Top && !TopLevels.Contains (Top))
if (View.EnableDebugIDisposableAsserts && Top is { } && toplevel != Top && !TopLevels.Contains (Top))
{
// This assertion confirm if the Top was already disposed
Debug.Assert (Top.WasDisposed);
Expand Down Expand Up @@ -193,6 +193,11 @@ public static RunState Begin (Toplevel toplevel)
toplevel.EndInit (); // Calls Layout
}

// Call ConfigurationManager Apply here to ensure all subscribers to ConfigurationManager.Applied
// can update their state appropriately.
// BUGBUG: DO NOT DO THIS. Leave this commented out until we can figure out how to do this right
//Apply ();

// Try to set initial focus to any TabStop
if (!toplevel.HasFocus)
{
Expand Down Expand Up @@ -426,7 +431,7 @@ public static T Run<T> (Func<Exception, bool>? errorHandler = null, IConsoleDriv

internal static void LayoutAndDrawImpl (bool forceDraw = false)
{
List<View> tops = [..TopLevels];
List<View> tops = [.. TopLevels];

if (Popover?.GetActivePopover () as View is { Visible: true } visiblePopover)
{
Expand Down Expand Up @@ -479,7 +484,10 @@ public static void RunLoop (RunState state)

for (state.Toplevel.Running = true; state.Toplevel?.Running == true;)
{
MainLoop!.Running = true;
if (MainLoop is { })
{
MainLoop.Running = true;
}

if (EndAfterFirstIteration && !firstIteration)
{
Expand All @@ -489,7 +497,10 @@ public static void RunLoop (RunState state)
firstIteration = RunIteration (ref state, firstIteration);
}

MainLoop!.Running = false;
if (MainLoop is { })
{
MainLoop.Running = false;
}

// Run one last iteration to consume any outstanding input events from Driver
// This is important for remaining OnKeyUp events.
Expand All @@ -505,7 +516,7 @@ public static void RunLoop (RunState state)
public static bool RunIteration (ref RunState state, bool firstIteration = false)
{
// If the driver has events pending do an iteration of the driver MainLoop
if (MainLoop!.Running && MainLoop.EventsPending ())
if (MainLoop is { Running: true } && MainLoop.EventsPending ())
{
// Notify Toplevel it's ready
if (firstIteration)
Expand All @@ -529,7 +540,7 @@ public static bool RunIteration (ref RunState state, bool firstIteration = false

if (PositionCursor ())
{
Driver!.UpdateCursor ();
Driver?.UpdateCursor ();
}

return firstIteration;
Expand Down Expand Up @@ -564,7 +575,14 @@ public static void End (RunState runState)
{
ArgumentNullException.ThrowIfNull (runState);

Popover?.Hide (Popover?.GetActivePopover ());
if (Popover?.GetActivePopover () as View is { Visible: true } visiblePopover)
{
// TODO: Build a use/test case for the popover not handling Quit
if (visiblePopover.InvokeCommand (Command.Quit) is true && visiblePopover.Visible)
{
visiblePopover.Visible = false;
}
}

runState.Toplevel.OnUnloaded ();

Expand Down
14 changes: 8 additions & 6 deletions Terminal.Gui/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static string ToString (IConsoleDriver? driver)
{
return string.Empty;
}

var sb = new StringBuilder ();

Cell [,] contents = driver?.Contents!;
Expand Down Expand Up @@ -139,7 +140,7 @@ internal static List<CultureInfo> GetSupportedCultures ()
// starts running and after Shutdown returns.
internal static void ResetState (bool ignoreDisposed = false)
{
Application.Navigation = new ApplicationNavigation ();
Navigation = new ();

// Shutdown is the bookend for Init. As such it needs to clean up all resources
// Init created. Apps that do any threading will need to code defensively for this.
Expand All @@ -151,18 +152,21 @@ internal static void ResetState (bool ignoreDisposed = false)

if (Popover?.GetActivePopover () is View popover)
{
// This forcefully closes the popover; invoking Command.Quit would be more graceful
// but since this is shutdown, doing this is ok.
popover.Visible = false;
}

Popover?.Dispose ();
Popover = null;

TopLevels.Clear ();
#if DEBUG_IDISPOSABLE

// Don't dispose the Top. It's up to caller dispose it
if (View.DebugIDisposable && !ignoreDisposed && Top is { })
if (View.EnableDebugIDisposableAsserts && !ignoreDisposed && Top is { })
{
Debug.Assert (Top.WasDisposed);
Debug.Assert (Top.WasDisposed, $"Title = {Top.Title}, Id = {Top.Id}");

// If End wasn't called _cachedRunStateToplevel may be null
if (_cachedRunStateToplevel is { })
Expand Down Expand Up @@ -223,7 +227,6 @@ internal static void ResetState (bool ignoreDisposed = false)

Navigation = null;


KeyBindings.Clear ();
AddKeyBindings ();

Expand All @@ -234,10 +237,9 @@ internal static void ResetState (bool ignoreDisposed = false)
SynchronizationContext.SetSynchronizationContext (null);
}


/// <summary>
/// Adds specified idle handler function to main iteration processing. The handler function will be called
/// once per iteration of the main loop after other events have been handled.
/// </summary>
public static void AddIdle (Func<bool> func) => ApplicationImpl.Instance.AddIdle (func);
public static void AddIdle (Func<bool> func) { ApplicationImpl.Instance.AddIdle (func); }
}
39 changes: 20 additions & 19 deletions Terminal.Gui/Application/ApplicationImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void ChangeInstance (IApplication newApplication)
[RequiresDynamicCode ("AOT")]
public virtual void Init (IConsoleDriver? driver = null, string? driverName = null)
{
Application.InternalInit (driver, driverName);
Application.InternalInit (driver, driverName);
}

/// <summary>
Expand Down Expand Up @@ -166,34 +166,35 @@ public virtual void Run (Toplevel view, Func<Exception, bool>? errorHandler = nu
try
{
#endif
resume = false;
RunState runState = Application.Begin (view);
resume = false;
RunState runState = Application.Begin (view);

// If EndAfterFirstIteration is true then the user must dispose of the runToken
// by using NotifyStopRunState event.
Application.RunLoop (runState);
// If EndAfterFirstIteration is true then the user must dispose of the runToken
// by using NotifyStopRunState event.
Application.RunLoop (runState);

if (runState.Toplevel is null)
{
if (runState.Toplevel is null)
{
#if DEBUG_IDISPOSABLE
if (View.DebugIDisposable)
if (View.EnableDebugIDisposableAsserts)
{
Debug.Assert (Application.TopLevels.Count == 0);
}
#endif
runState.Dispose ();
runState.Dispose ();

return;
}
return;
}

if (!Application.EndAfterFirstIteration)
{
Application.End (runState);
}
if (!Application.EndAfterFirstIteration)
{
Application.End (runState);
}
#if !DEBUG
}
catch (Exception error)
{
Logging.Warning ($"Release Build Exception: {error}");
if (errorHandler is null)
{
throw;
Expand Down Expand Up @@ -225,7 +226,7 @@ public virtual void Shutdown ()
{
bool init = Application.Initialized;

Application.OnInitializedChanged(this, new (in init));
Application.OnInitializedChanged (this, new (in init));
}
}

Expand Down Expand Up @@ -270,7 +271,7 @@ public virtual void Invoke (Action action)
/// <inheritdoc />
public virtual void AddIdle (Func<bool> func)
{
if(Application.MainLoop is null)
if (Application.MainLoop is null)
{
throw new NotInitializedException ("Cannot add idle before main loop is initialized");
}
Expand All @@ -294,7 +295,7 @@ public virtual object AddTimeout (TimeSpan time, Func<bool> callback)

/// <inheritdoc />
public virtual bool RemoveTimeout (object token)
{
{
return Application.MainLoop?.TimedEvents.RemoveTimeout (token) ?? false;
}

Expand Down
3 changes: 3 additions & 0 deletions Terminal.Gui/Application/ApplicationPopover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void Show (IPopover? popover)

if (popover is View newPopover)
{
Register (popover);
if (!newPopover.IsInitialized)
{
newPopover.BeginInit ();
Expand Down Expand Up @@ -145,6 +146,7 @@ internal bool DispatchKeyDown (Key key)

if (activePopover is { Visible: true })
{
Logging.Debug ($"Active - Calling NewKeyDownEvent ({key}) on {activePopover.Title}");
if (activePopover.NewKeyDownEvent (key))
{
return true;
Expand All @@ -163,6 +165,7 @@ internal bool DispatchKeyDown (Key key)
}

// hotKeyHandled = popoverView.InvokeCommandsBoundToHotKey (key);
Logging.Debug ($"Inactive - Calling NewKeyDownEvent ({key}) on {popoverView.Title}");
hotKeyHandled = popoverView.NewKeyDownEvent (key);

if (hotKeyHandled is true)
Expand Down
21 changes: 16 additions & 5 deletions Terminal.Gui/Application/PopoverBaseImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected PopoverBaseImpl ()
{
Comment thread
tig marked this conversation as resolved.
if (!Visible)
{
return null;
return false;
}

Visible = false;
Expand All @@ -54,11 +54,22 @@ protected PopoverBaseImpl ()
protected override bool OnVisibleChanging ()
{
bool ret = base.OnVisibleChanging ();
if (!ret && !Visible)
if (ret is not true)
{
// Whenever visible is changing to true, we need to resize;
// it's our only chance because we don't get laid out until we're visible
Layout (Application.Screen.Size);
if (!Visible)
{
// Whenever visible is changing to true, we need to resize;
// it's our only chance because we don't get laid out until we're visible
Layout (Application.Screen.Size);
}
else
{
// Whenever visible is changing to false, we need to reset the focus
if (ApplicationNavigation.IsInHierarchy(this, Application.Navigation?.GetFocused ()))
{
Application.Navigation?.SetFocused (Application.Top?.MostFocused);
}
}
}

return ret;
Expand Down
Loading