diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs
index 1939fe0b7..9bf578f31 100644
--- a/Terminal.Gui/Application.cs
+++ b/Terminal.Gui/Application.cs
@@ -1,33 +1,16 @@
-//
-// Core.cs: The core engine for gui.cs
-//
-// Authors:
-// Miguel de Icaza (miguel@gnome.org)
-//
-// Pending:
-// - Check for NeedDisplay on the hierarchy and repaint
-// - Layout support
-// - "Colors" type or "Attributes" type?
-// - What to surface as "BackgroundCOlor" when clearing a window, an attribute or colors?
-//
-// Optimizations
-// - Add rendering limitation to the exposed area
using System;
using System.Collections.Generic;
using System.Threading;
using System.Linq;
-using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.IO;
-using Terminal.Gui;
using System.Text.Json.Serialization;
using static Terminal.Gui.ConfigurationManager;
namespace Terminal.Gui {
-
///
- /// A static, singleton class providing the main application driver for Terminal.Gui apps.
+ /// A static, singleton class representing the application. This class is the entry point for the application.
///
///
///
@@ -51,16 +34,15 @@ namespace Terminal.Gui {
/// other sources of data. It is accessible via the property.
///
///
- /// You can hook up to the event to have your method
- /// invoked on each iteration of the .
+ /// The event is invoked on each iteration of the .
///
///
- /// When invoked sets the SynchronizationContext to one that is tied
- /// to the mainloop, allowing user code to use async/await.
+ /// When invoked it sets the to one that is tied
+ /// to the , allowing user code to use async/await.
///
///
public static partial class Application {
- static readonly Stack toplevels = new Stack ();
+ static readonly Stack _toplevels = new Stack ();
///
/// The current in use.
@@ -70,16 +52,16 @@ namespace Terminal.Gui {
///
/// Gets all the Mdi childes which represent all the not modal from the .
///
- public static List MdiChildes {
+ public static List MdiChildren {
get {
if (MdiTop != null) {
- List mdiChildes = new List ();
- foreach (var top in toplevels) {
+ List _mdiChildren = new List ();
+ foreach (var top in _toplevels) {
if (top != MdiTop && !top.Modal) {
- mdiChildes.Add (top);
+ _mdiChildren.Add (top);
}
}
- return mdiChildes;
+ return _mdiChildren;
}
return null;
}
@@ -150,18 +132,18 @@ namespace Terminal.Gui {
}
}
- static Key alternateForwardKey = Key.PageDown | Key.CtrlMask;
+ static Key _alternateForwardKey = Key.PageDown | Key.CtrlMask;
///
/// Alternative key to navigate forwards through views. Ctrl+Tab is the primary key.
///
[SerializableConfigurationProperty (Scope = typeof (SettingsScope)), JsonConverter (typeof (KeyJsonConverter))]
public static Key AlternateForwardKey {
- get => alternateForwardKey;
+ get => _alternateForwardKey;
set {
- if (alternateForwardKey != value) {
- var oldKey = alternateForwardKey;
- alternateForwardKey = value;
+ if (_alternateForwardKey != value) {
+ var oldKey = _alternateForwardKey;
+ _alternateForwardKey = value;
OnAlternateForwardKeyChanged (new KeyChangedEventArgs (oldKey, value));
}
}
@@ -169,23 +151,23 @@ namespace Terminal.Gui {
static void OnAlternateForwardKeyChanged (KeyChangedEventArgs e)
{
- foreach (var top in toplevels.ToArray ()) {
+ foreach (var top in _toplevels.ToArray ()) {
top.OnAlternateForwardKeyChanged (e);
}
}
- static Key alternateBackwardKey = Key.PageUp | Key.CtrlMask;
+ static Key _alternateBackwardKey = Key.PageUp | Key.CtrlMask;
///
/// Alternative key to navigate backwards through views. Shift+Ctrl+Tab is the primary key.
///
[SerializableConfigurationProperty (Scope = typeof (SettingsScope)), JsonConverter (typeof (KeyJsonConverter))]
public static Key AlternateBackwardKey {
- get => alternateBackwardKey;
+ get => _alternateBackwardKey;
set {
- if (alternateBackwardKey != value) {
- var oldKey = alternateBackwardKey;
- alternateBackwardKey = value;
+ if (_alternateBackwardKey != value) {
+ var oldKey = _alternateBackwardKey;
+ _alternateBackwardKey = value;
OnAlternateBackwardKeyChanged (new KeyChangedEventArgs (oldKey, value));
}
}
@@ -193,39 +175,39 @@ namespace Terminal.Gui {
static void OnAlternateBackwardKeyChanged (KeyChangedEventArgs oldKey)
{
- foreach (var top in toplevels.ToArray ()) {
+ foreach (var top in _toplevels.ToArray ()) {
top.OnAlternateBackwardKeyChanged (oldKey);
}
}
- static Key quitKey = Key.Q | Key.CtrlMask;
+ static Key _quitKey = Key.Q | Key.CtrlMask;
///
/// Gets or sets the key to quit the application.
///
[SerializableConfigurationProperty (Scope = typeof (SettingsScope)), JsonConverter (typeof (KeyJsonConverter))]
public static Key QuitKey {
- get => quitKey;
+ get => _quitKey;
set {
- if (quitKey != value) {
- var oldKey = quitKey;
- quitKey = value;
+ if (_quitKey != value) {
+ var oldKey = _quitKey;
+ _quitKey = value;
OnQuitKeyChanged (new KeyChangedEventArgs (oldKey, value));
}
}
}
- private static List supportedCultures;
+ private static List _supportedCultures;
///
/// Gets all supported cultures by the application without the invariant language.
///
- public static List SupportedCultures => supportedCultures;
+ public static List SupportedCultures => _supportedCultures;
static void OnQuitKeyChanged (KeyChangedEventArgs e)
{
// Duplicate the list so if it changes during enumeration we're safe
- foreach (var top in toplevels.ToArray ()) {
+ foreach (var top in _toplevels.ToArray ()) {
top.OnQuitKeyChanged (e);
}
}
@@ -337,7 +319,7 @@ namespace Terminal.Gui {
public static bool UseSystemConsole { get; set; } = false;
// For Unit testing - ignores UseSystemConsole
- internal static bool ForceFakeConsole;
+ internal static bool _forceFakeConsole;
///
/// Initializes a new instance of Application.
@@ -415,7 +397,7 @@ namespace Terminal.Gui {
// Start the process of configuration management.
// Note that we end up calling LoadConfigurationFromAllSources
- // mulitlple times. We need to do this because some settings are only
+ // multiple times. We need to do this because some settings are only
// valid after a Driver is loaded. In this cases we need just
// `Settings` so we can determine which driver to use.
ConfigurationManager.Load (true);
@@ -423,7 +405,7 @@ namespace Terminal.Gui {
if (Driver == null) {
var p = Environment.OSVersion.Platform;
- if (ForceFakeConsole) {
+ if (_forceFakeConsole) {
// For Unit Testing only
Driver = new FakeDriver ();
} else if (UseSystemConsole) {
@@ -471,7 +453,7 @@ namespace Terminal.Gui {
Top = topLevelFactory ();
Current = Top;
- supportedCultures = GetSupportedCultures ();
+ _supportedCultures = GetSupportedCultures ();
_mainThreadId = Thread.CurrentThread.ManagedThreadId;
_initialized = true;
}
@@ -544,10 +526,6 @@ namespace Terminal.Gui {
{
if (Toplevel != null && disposing) {
throw new InvalidOperationException ("You must clean up (Dispose) the Toplevel before calling Application.RunState.Dispose");
- // BUGBUG: It's insidious that we call EndFirstTopLevel here so I moved it to End.
- //EndFirstTopLevel (Toplevel);
- //Toplevel.Dispose ();
- //Toplevel = null;
}
}
}
@@ -558,7 +536,7 @@ namespace Terminal.Gui {
return;
}
- var chain = toplevels.ToList ();
+ var chain = _toplevels.ToList ();
foreach (var topLevel in chain) {
if (topLevel.ProcessHotKey (ke))
return;
@@ -584,7 +562,7 @@ namespace Terminal.Gui {
static void ProcessKeyDownEvent (KeyEvent ke)
{
- var chain = toplevels.ToList ();
+ var chain = _toplevels.ToList ();
foreach (var topLevel in chain) {
if (topLevel.OnKeyDown (ke))
return;
@@ -596,7 +574,7 @@ namespace Terminal.Gui {
static void ProcessKeyUpEvent (KeyEvent ke)
{
- var chain = toplevels.ToList ();
+ var chain = _toplevels.ToList ();
foreach (var topLevel in chain) {
if (topLevel.OnKeyUp (ke))
return;
@@ -615,12 +593,12 @@ namespace Terminal.Gui {
return null;
}
- if (toplevels != null) {
- int count = toplevels.Count;
+ if (_toplevels != null) {
+ int count = _toplevels.Count;
if (count > 0) {
var rx = x - startFrame.X;
var ry = y - startFrame.Y;
- foreach (var t in toplevels) {
+ foreach (var t in _toplevels) {
if (t != Current) {
if (t != start && t.Visible && t.Frame.Contains (rx, ry)) {
start = t;
@@ -652,9 +630,9 @@ namespace Terminal.Gui {
return null;
}
- int count = toplevels.Count;
+ int count = _toplevels.Count;
for (int i = count - 1; i >= 0; i--) {
- foreach (var top in toplevels) {
+ foreach (var top in _toplevels) {
var rx = x - startFrame.X;
var ry = y - startFrame.Y;
if (top.Visible && top.Frame.Contains (rx, ry)) {
@@ -682,12 +660,12 @@ namespace Terminal.Gui {
return top;
}
- static View mouseGrabView;
+ static View _mouseGrabView;
///
/// The view that grabbed the mouse, to where will be routed all the mouse events.
///
- public static View MouseGrabView => mouseGrabView;
+ public static View MouseGrabView => _mouseGrabView;
///
/// Event to be invoked when a view want grab the mouse which can be canceled.
@@ -720,7 +698,7 @@ namespace Terminal.Gui {
return;
if (!OnGrabbingMouse (view)) {
OnGrabbedMouse (view);
- mouseGrabView = view;
+ _mouseGrabView = view;
Driver.UncookMouse ();
}
}
@@ -730,11 +708,11 @@ namespace Terminal.Gui {
///
public static void UngrabMouse ()
{
- if (mouseGrabView == null)
+ if (_mouseGrabView == null)
return;
- if (!OnUnGrabbingMouse (mouseGrabView)) {
- OnUnGrabbedMouse (mouseGrabView);
- mouseGrabView = null;
+ if (!OnUnGrabbingMouse (_mouseGrabView)) {
+ OnUnGrabbedMouse (_mouseGrabView);
+ _mouseGrabView = null;
Driver.CookMouse ();
}
}
@@ -809,8 +787,8 @@ namespace Terminal.Gui {
return;
}
- if (mouseGrabView != null) {
- var newxy = mouseGrabView.ScreenToView (me.X, me.Y);
+ if (_mouseGrabView != null) {
+ var newxy = _mouseGrabView.ScreenToView (me.X, me.Y);
var nme = new MouseEvent () {
X = newxy.X,
Y = newxy.Y,
@@ -819,11 +797,11 @@ namespace Terminal.Gui {
OfY = me.Y - newxy.Y,
View = view
};
- if (OutsideFrame (new Point (nme.X, nme.Y), mouseGrabView.Frame)) {
+ if (OutsideFrame (new Point (nme.X, nme.Y), _mouseGrabView.Frame)) {
lastMouseOwnerView?.OnMouseLeave (me);
}
//System.Diagnostics.Debug.WriteLine ($"{nme.Flags};{nme.X};{nme.Y};{mouseGrabView}");
- if (mouseGrabView?.OnMouseEvent (nme) == true) {
+ if (_mouseGrabView?.OnMouseEvent (nme) == true) {
return;
}
}
@@ -878,16 +856,16 @@ namespace Terminal.Gui {
{
// The Current is modal and the top is not modal toplevel then
// the Current must be moved above the first not modal toplevel.
- if (MdiTop != null && top != MdiTop && top != Current && Current?.Modal == true && !toplevels.Peek ().Modal) {
- lock (toplevels) {
- toplevels.MoveTo (Current, 0, new ToplevelEqualityComparer ());
+ if (MdiTop != null && top != MdiTop && top != Current && Current?.Modal == true && !_toplevels.Peek ().Modal) {
+ lock (_toplevels) {
+ _toplevels.MoveTo (Current, 0, new ToplevelEqualityComparer ());
}
var index = 0;
- var savedToplevels = toplevels.ToArray ();
+ var savedToplevels = _toplevels.ToArray ();
foreach (var t in savedToplevels) {
if (!t.Modal && t != Current && t != top && t != savedToplevels [index]) {
- lock (toplevels) {
- toplevels.MoveTo (top, index, new ToplevelEqualityComparer ());
+ lock (_toplevels) {
+ _toplevels.MoveTo (top, index, new ToplevelEqualityComparer ());
}
}
index++;
@@ -897,26 +875,26 @@ namespace Terminal.Gui {
// The Current and the top are both not running toplevel then
// the top must be moved above the first not running toplevel.
if (MdiTop != null && top != MdiTop && top != Current && Current?.Running == false && !top.Running) {
- lock (toplevels) {
- toplevels.MoveTo (Current, 0, new ToplevelEqualityComparer ());
+ lock (_toplevels) {
+ _toplevels.MoveTo (Current, 0, new ToplevelEqualityComparer ());
}
var index = 0;
- foreach (var t in toplevels.ToArray ()) {
+ foreach (var t in _toplevels.ToArray ()) {
if (!t.Running && t != Current && index > 0) {
- lock (toplevels) {
- toplevels.MoveTo (top, index - 1, new ToplevelEqualityComparer ());
+ lock (_toplevels) {
+ _toplevels.MoveTo (top, index - 1, new ToplevelEqualityComparer ());
}
}
index++;
}
return false;
}
- if ((MdiTop != null && top?.Modal == true && toplevels.Peek () != top)
+ if ((MdiTop != null && top?.Modal == true && _toplevels.Peek () != top)
|| (MdiTop != null && Current != MdiTop && Current?.Modal == false && top == MdiTop)
|| (MdiTop != null && Current?.Modal == false && top != Current)
|| (MdiTop != null && Current?.Modal == true && top == MdiTop)) {
- lock (toplevels) {
- toplevels.MoveTo (top, 0, new ToplevelEqualityComparer ());
+ lock (_toplevels) {
+ _toplevels.MoveTo (top, 0, new ToplevelEqualityComparer ());
Current = top;
}
}
@@ -957,38 +935,37 @@ namespace Terminal.Gui {
toplevel.EndInit ();
}
- lock (toplevels) {
+ lock (_toplevels) {
// If Top was already initialized with Init, and Begin has never been called
// Top was not added to the toplevels Stack. It will thus never get disposed.
// Clean it up here:
- if (Top != null && toplevel != Top && !toplevels.Contains (Top)) {
+ if (Top != null && toplevel != Top && !_toplevels.Contains (Top)) {
Top.Dispose ();
Top = null;
- } else if (Top != null && toplevel != Top && toplevels.Contains (Top)) {
+ } else if (Top != null && toplevel != Top && _toplevels.Contains (Top)) {
Top.OnLeave (toplevel);
}
if (string.IsNullOrEmpty (toplevel.Id.ToString ())) {
var count = 1;
- var id = (toplevels.Count + count).ToString ();
- while (toplevels.Count > 0 && toplevels.FirstOrDefault (x => x.Id.ToString () == id) != null) {
+ var id = (_toplevels.Count + count).ToString ();
+ while (_toplevels.Count > 0 && _toplevels.FirstOrDefault (x => x.Id.ToString () == id) != null) {
count++;
- id = (toplevels.Count + count).ToString ();
+ id = (_toplevels.Count + count).ToString ();
}
- toplevel.Id = (toplevels.Count + count).ToString ();
+ toplevel.Id = (_toplevels.Count + count).ToString ();
- toplevels.Push (toplevel);
+ _toplevels.Push (toplevel);
} else {
- var dup = toplevels.FirstOrDefault (x => x.Id.ToString () == toplevel.Id);
+ var dup = _toplevels.FirstOrDefault (x => x.Id.ToString () == toplevel.Id);
if (dup == null) {
- toplevels.Push (toplevel);
+ _toplevels.Push (toplevel);
}
}
- if (toplevels.FindDuplicates (new ToplevelEqualityComparer ()).Count > 0) {
+ if (_toplevels.FindDuplicates (new ToplevelEqualityComparer ()).Count > 0) {
throw new ArgumentException ("There are duplicates toplevels Id's");
}
}
- // Fix $520 - Set Top = toplevel if Top == null
if (Top == null || toplevel.IsMdiContainer) {
Top = toplevel;
}
@@ -1003,7 +980,7 @@ namespace Terminal.Gui {
} else {
refreshDriver = false;
}
- } else if ((MdiTop != null && toplevel != MdiTop && Current?.Modal == true && !toplevels.Peek ().Modal)
+ } else if ((MdiTop != null && toplevel != MdiTop && Current?.Modal == true && !_toplevels.Peek ().Modal)
|| (MdiTop != null && toplevel != MdiTop && Current?.Running == false)) {
refreshDriver = false;
MoveCurrent (toplevel);
@@ -1048,13 +1025,13 @@ namespace Terminal.Gui {
// End the RunState.Toplevel
// First, take it off the toplevel Stack
- if (toplevels.Count > 0) {
- if (toplevels.Peek () != runState.Toplevel) {
+ if (_toplevels.Count > 0) {
+ if (_toplevels.Peek () != runState.Toplevel) {
// If there the top of the stack is not the RunState.Toplevel then
// this call to End is not balanced with the call to Begin that started the RunState
throw new ArgumentException ("End must be balanced with calls to Begin");
}
- toplevels.Pop ();
+ _toplevels.Pop ();
}
// Notify that it is closing
@@ -1067,11 +1044,11 @@ namespace Terminal.Gui {
}
// Set Current and Top to the next TopLevel on the stack
- if (toplevels.Count == 0) {
+ if (_toplevels.Count == 0) {
Current = null;
} else {
- Current = toplevels.Peek ();
- if (toplevels.Count == 1 && Current == MdiTop) {
+ Current = _toplevels.Peek ();
+ if (_toplevels.Count == 1 && Current == MdiTop) {
MdiTop.OnAllChildClosed ();
} else {
SetCurrentAsTop ();
@@ -1108,11 +1085,11 @@ namespace Terminal.Gui {
// 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.
// e.g. see Issue #537
- foreach (var t in toplevels) {
+ foreach (var t in _toplevels) {
t.Running = false;
t.Dispose ();
}
- toplevels.Clear ();
+ _toplevels.Clear ();
Current = null;
Top?.Dispose ();
Top = null;
@@ -1130,7 +1107,7 @@ namespace Terminal.Gui {
NotifyNewRunState = null;
NotifyStopRunState = null;
_initialized = false;
- mouseGrabView = null;
+ _mouseGrabView = null;
_enableConsoleScrolling = false;
lastMouseOwnerView = null;
@@ -1155,7 +1132,7 @@ namespace Terminal.Gui {
{
Driver.UpdateOffScreen ();
View last = null;
- foreach (var v in toplevels.Reverse ()) {
+ foreach (var v in _toplevels.Reverse ()) {
if (v.Visible) {
v.SetNeedsDisplay ();
v.Redraw (v.Bounds);
@@ -1233,14 +1210,14 @@ namespace Terminal.Gui {
&& (!Top._needsDisplay.IsEmpty || Top._childNeedsDisplay || Top.LayoutNeeded)) {
state.Toplevel.SetNeedsDisplay (state.Toplevel.Bounds);
Top.Redraw (Top.Bounds);
- foreach (var top in toplevels.Reverse ()) {
+ foreach (var top in _toplevels.Reverse ()) {
if (top != Top && top != state.Toplevel) {
top.SetNeedsDisplay ();
top.Redraw (top.Bounds);
}
}
}
- if (toplevels.Count == 1 && state.Toplevel == Top
+ if (_toplevels.Count == 1 && state.Toplevel == Top
&& (Driver.Cols != state.Toplevel.Frame.Width || Driver.Rows != state.Toplevel.Frame.Height)
&& (!state.Toplevel._needsDisplay.IsEmpty || state.Toplevel._childNeedsDisplay || state.Toplevel.LayoutNeeded)) {
@@ -1252,7 +1229,7 @@ namespace Terminal.Gui {
if (!state.Toplevel._needsDisplay.IsEmpty || state.Toplevel._childNeedsDisplay || state.Toplevel.LayoutNeeded
|| MdiChildNeedsDisplay ()) {
state.Toplevel.Redraw (state.Toplevel.Bounds);
- if (DebugDrawBounds) {
+ if (_debugDrawBounds) {
DrawBounds (state.Toplevel);
}
state.Toplevel.PositionCursor ();
@@ -1268,11 +1245,11 @@ namespace Terminal.Gui {
static void EnsureModalOrVisibleAlwaysOnTop (Toplevel toplevel)
{
- if (!toplevel.Running || (toplevel == Current && toplevel.Visible) || MdiTop == null || toplevels.Peek ().Modal) {
+ if (!toplevel.Running || (toplevel == Current && toplevel.Visible) || MdiTop == null || _toplevels.Peek ().Modal) {
return;
}
- foreach (var top in toplevels.Reverse ()) {
+ foreach (var top in _toplevels.Reverse ()) {
if (top.Modal && top != Current) {
MoveCurrent (top);
return;
@@ -1289,7 +1266,7 @@ namespace Terminal.Gui {
return false;
}
- foreach (var top in toplevels) {
+ foreach (var top in _toplevels) {
if (top != Current && top.Visible && (!top._needsDisplay.IsEmpty || top._childNeedsDisplay || top.LayoutNeeded)) {
MdiTop.SetSubViewNeedsDisplay ();
return true;
@@ -1298,7 +1275,7 @@ namespace Terminal.Gui {
return false;
}
- internal static bool DebugDrawBounds = false;
+ internal static bool _debugDrawBounds = false;
// Need to look into why this does not work properly.
static void DrawBounds (View v)
@@ -1468,7 +1445,7 @@ namespace Terminal.Gui {
} else if ((MdiTop != null && top != MdiTop && top != Current && Current?.Modal == false
&& Current?.Running == true && !top.Running)
|| (MdiTop != null && top != MdiTop && top != Current && Current?.Modal == false
- && Current?.Running == false && !top.Running && toplevels.ToArray () [1].Running)) {
+ && Current?.Running == false && !top.Running && _toplevels.ToArray () [1].Running)) {
MoveCurrent (top);
} else if (MdiTop != null && Current != top && Current?.Running == true && !top.Running
@@ -1519,7 +1496,7 @@ namespace Terminal.Gui {
var full = new Rect (0, 0, Driver.Cols, Driver.Rows);
Resized?.Invoke (new ResizedEventArgs () { Cols = full.Width, Rows = full.Height });
Driver.Clip = full;
- foreach (var t in toplevels) {
+ foreach (var t in _toplevels) {
t.SetRelativeLayout (full);
t.LayoutSubviews ();
t.PositionToplevels ();
@@ -1546,19 +1523,19 @@ namespace Terminal.Gui {
public static void MoveNext ()
{
if (MdiTop != null && !Current.Modal) {
- lock (toplevels) {
- toplevels.MoveNext ();
+ lock (_toplevels) {
+ _toplevels.MoveNext ();
var isMdi = false;
- while (toplevels.Peek () == MdiTop || !toplevels.Peek ().Visible) {
- if (!isMdi && toplevels.Peek () == MdiTop) {
+ while (_toplevels.Peek () == MdiTop || !_toplevels.Peek ().Visible) {
+ if (!isMdi && _toplevels.Peek () == MdiTop) {
isMdi = true;
- } else if (isMdi && toplevels.Peek () == MdiTop) {
+ } else if (isMdi && _toplevels.Peek () == MdiTop) {
MoveCurrent (Top);
break;
}
- toplevels.MoveNext ();
+ _toplevels.MoveNext ();
}
- Current = toplevels.Peek ();
+ Current = _toplevels.Peek ();
}
}
}
@@ -1569,19 +1546,19 @@ namespace Terminal.Gui {
public static void MovePrevious ()
{
if (MdiTop != null && !Current.Modal) {
- lock (toplevels) {
- toplevels.MovePrevious ();
+ lock (_toplevels) {
+ _toplevels.MovePrevious ();
var isMdi = false;
- while (toplevels.Peek () == MdiTop || !toplevels.Peek ().Visible) {
- if (!isMdi && toplevels.Peek () == MdiTop) {
+ while (_toplevels.Peek () == MdiTop || !_toplevels.Peek ().Visible) {
+ if (!isMdi && _toplevels.Peek () == MdiTop) {
isMdi = true;
- } else if (isMdi && toplevels.Peek () == MdiTop) {
+ } else if (isMdi && _toplevels.Peek () == MdiTop) {
MoveCurrent (Top);
break;
}
- toplevels.MovePrevious ();
+ _toplevels.MovePrevious ();
}
- Current = toplevels.Peek ();
+ Current = _toplevels.Peek ();
}
}
}
@@ -1589,8 +1566,8 @@ namespace Terminal.Gui {
internal static bool ShowChild (Toplevel top)
{
if (top.Visible && MdiTop != null && Current?.Modal == false) {
- lock (toplevels) {
- toplevels.MoveTo (top, 0, new ToplevelEqualityComparer ());
+ lock (_toplevels) {
+ _toplevels.MoveTo (top, 0, new ToplevelEqualityComparer ());
Current = top;
}
return true;
diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs
index e5c92f317..8c4a6cabe 100644
--- a/Terminal.Gui/Views/Toplevel.cs
+++ b/Terminal.Gui/Views/Toplevel.cs
@@ -770,7 +770,7 @@ namespace Terminal.Gui {
PositionToplevels ();
if (this == Application.MdiTop) {
- foreach (var top in Application.MdiChildes.AsEnumerable ().Reverse ()) {
+ foreach (var top in Application.MdiChildren.AsEnumerable ().Reverse ()) {
if (top.Frame.IntersectsWith (bounds)) {
if (top != this && !top.IsCurrentTop && !OutsideTopFrame (top) && top.Visible) {
top.SetNeedsLayout ();
@@ -904,7 +904,7 @@ namespace Terminal.Gui {
|| Application.Current?.Modal == false
|| Application.Current?.Modal == true && Application.Current?.Running == false)) {
- foreach (var child in Application.MdiChildes) {
+ foreach (var child in Application.MdiChildren) {
var ev = new ToplevelClosingEventArgs (this);
if (child.OnClosing (ev)) {
return;
@@ -957,7 +957,7 @@ namespace Terminal.Gui {
}
if (Focused == null) {
- foreach (var top in Application.MdiChildes) {
+ foreach (var top in Application.MdiChildren) {
if (top != this && top.Visible) {
top.SetFocus ();
return;
@@ -982,7 +982,7 @@ namespace Terminal.Gui {
return null;
}
- foreach (var top in Application.MdiChildes) {
+ foreach (var top in Application.MdiChildren) {
if (type != null && top.GetType () == type
&& exclude?.Contains (top.Data.ToString ()) == false) {
return top;
@@ -1070,7 +1070,7 @@ namespace Terminal.Gui {
///
/// Implements the to sort the
- /// from the if needed.
+ /// from the if needed.
///
public sealed class ToplevelComparer : IComparer {
/// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
diff --git a/UICatalog/Scenarios/BackgroundWorkerCollection.cs b/UICatalog/Scenarios/BackgroundWorkerCollection.cs
index be7666b92..ba9a19044 100644
--- a/UICatalog/Scenarios/BackgroundWorkerCollection.cs
+++ b/UICatalog/Scenarios/BackgroundWorkerCollection.cs
@@ -99,12 +99,12 @@ namespace UICatalog.Scenarios {
Title = "WorkerApp",
CheckType = MenuItemCheckStyle.Checked
};
- var top = Application.MdiChildes?.Find ((x) => x.Data.ToString () == "WorkerApp");
+ var top = Application.MdiChildren?.Find ((x) => x.Data.ToString () == "WorkerApp");
if (top != null) {
item.Checked = top.Visible;
}
item.Action += () => {
- var top = Application.MdiChildes.Find ((x) => x.Data.ToString () == "WorkerApp");
+ var top = Application.MdiChildren.Find ((x) => x.Data.ToString () == "WorkerApp");
item.Checked = top.Visible = (bool)!item.Checked;
if (top.Visible) {
top.ShowChild ();
@@ -121,7 +121,7 @@ namespace UICatalog.Scenarios {
{
var index = 1;
List