mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Rename IApplication.Current to TopRunnable
Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,7 @@ public static class Program
|
||||
Services = ConfigureServices ();
|
||||
Application.Init ();
|
||||
Application.Run (Services.GetRequiredService<LoginView> ());
|
||||
Application.Current?.Dispose ();
|
||||
Application.TopRunnable?.Dispose ();
|
||||
Application.Shutdown ();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public static class Program
|
||||
RxApp.MainThreadScheduler = TerminalScheduler.Default;
|
||||
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default;
|
||||
Application.Run (new LoginView (new LoginViewModel ()));
|
||||
Application.Current.Dispose ();
|
||||
Application.TopRunnable.Dispose ();
|
||||
Application.Shutdown ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class Scenario : IDisposable
|
||||
|
||||
private void OnApplicationSessionBegun (object? sender, SessionTokenEventArgs e)
|
||||
{
|
||||
SubscribeAllSubViews (Application.Current!);
|
||||
SubscribeAllSubViews (Application.TopRunnable!);
|
||||
|
||||
_demoKeys = GetDemoKeyStrokes ();
|
||||
|
||||
@@ -241,7 +241,7 @@ public class Scenario : IDisposable
|
||||
|
||||
return;
|
||||
|
||||
// Get a list of all subviews under Application.Current (and their subviews, etc.)
|
||||
// Get a list of all subviews under Application.TopRunnable (and their subviews, etc.)
|
||||
// and subscribe to their DrawComplete event
|
||||
void SubscribeAllSubViews (View view)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public class AllViewsTester : Scenario
|
||||
|
||||
public override void Main ()
|
||||
{
|
||||
// Don't create a sub-win (Scenario.Win); just use Application.Current
|
||||
// Don't create a sub-win (Scenario.Win); just use Application.TopRunnable
|
||||
Application.Init ();
|
||||
|
||||
var app = new Window
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Bars : Scenario
|
||||
// QuitKey and it only sticks if changed after init
|
||||
private void App_Loaded (object sender, EventArgs e)
|
||||
{
|
||||
Application.Current!.Title = GetQuitKeyAndName ();
|
||||
Application.TopRunnable!.Title = GetQuitKeyAndName ();
|
||||
|
||||
ObservableCollection<string> eventSource = new ();
|
||||
ListView eventLog = new ListView ()
|
||||
@@ -41,7 +41,7 @@ public class Bars : Scenario
|
||||
Source = new ListWrapper<string> (eventSource)
|
||||
};
|
||||
eventLog.Border!.Thickness = new (0, 1, 0, 0);
|
||||
Application.Current.Add (eventLog);
|
||||
Application.TopRunnable.Add (eventLog);
|
||||
|
||||
FrameView menuBarLikeExamples = new ()
|
||||
{
|
||||
@@ -51,7 +51,7 @@ public class Bars : Scenario
|
||||
Width = Dim.Fill () - Dim.Width (eventLog),
|
||||
Height = Dim.Percent(33),
|
||||
};
|
||||
Application.Current.Add (menuBarLikeExamples);
|
||||
Application.TopRunnable.Add (menuBarLikeExamples);
|
||||
|
||||
Label label = new Label ()
|
||||
{
|
||||
@@ -98,7 +98,7 @@ public class Bars : Scenario
|
||||
Width = Dim.Fill () - Dim.Width (eventLog),
|
||||
Height = Dim.Percent (33),
|
||||
};
|
||||
Application.Current.Add (menuLikeExamples);
|
||||
Application.TopRunnable.Add (menuLikeExamples);
|
||||
|
||||
label = new Label ()
|
||||
{
|
||||
@@ -212,7 +212,7 @@ public class Bars : Scenario
|
||||
Width = Dim.Width (menuLikeExamples),
|
||||
Height = Dim.Percent (33),
|
||||
};
|
||||
Application.Current.Add (statusBarLikeExamples);
|
||||
Application.TopRunnable.Add (statusBarLikeExamples);
|
||||
|
||||
label = new Label ()
|
||||
{
|
||||
@@ -249,7 +249,7 @@ public class Bars : Scenario
|
||||
ConfigStatusBar (bar);
|
||||
statusBarLikeExamples.Add (bar);
|
||||
|
||||
foreach (FrameView frameView in Application.Current.SubViews.Where (f => f is FrameView)!)
|
||||
foreach (FrameView frameView in Application.TopRunnable.SubViews.Where (f => f is FrameView)!)
|
||||
{
|
||||
foreach (Bar barView in frameView.SubViews.Where (b => b is Bar)!)
|
||||
{
|
||||
@@ -269,8 +269,8 @@ public class Bars : Scenario
|
||||
|
||||
//private void SetupContentMenu ()
|
||||
//{
|
||||
// Application.Current.Add (new Label { Text = "Right Click for Context Menu", X = Pos.Center (), Y = 4 });
|
||||
// Application.Current.MouseClick += ShowContextMenu;
|
||||
// Application.TopRunnable.Add (new Label { Text = "Right Click for Context Menu", X = Pos.Center (), Y = 4 });
|
||||
// Application.TopRunnable.MouseClick += ShowContextMenu;
|
||||
//}
|
||||
|
||||
//private void ShowContextMenu (object s, MouseEventEventArgs e)
|
||||
|
||||
@@ -13,7 +13,7 @@ public class CombiningMarks : Scenario
|
||||
top.DrawComplete += (s, e) =>
|
||||
{
|
||||
// Forces reset _lineColsOffset because we're dealing with direct draw
|
||||
Application.Current!.SetNeedsDraw ();
|
||||
Application.TopRunnable!.SetNeedsDraw ();
|
||||
|
||||
var i = -1;
|
||||
top.Move (0, ++i);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ConfigurationEditor : Scenario
|
||||
|
||||
void ConfigurationManagerOnApplied (object? sender, ConfigurationManagerEventArgs e)
|
||||
{
|
||||
Application.Current?.SetNeedsDraw ();
|
||||
Application.TopRunnable?.SetNeedsDraw ();
|
||||
}
|
||||
}
|
||||
public void Save ()
|
||||
|
||||
@@ -502,7 +502,7 @@ public class CsvEditor : Scenario
|
||||
// Only set the current filename if we successfully loaded the entire file
|
||||
_currentFile = filename;
|
||||
_selectedCellTextField.SuperView.Enabled = true;
|
||||
Application.Current.Title = $"{GetName ()} - {Path.GetFileName (_currentFile)}";
|
||||
Application.TopRunnable.Title = $"{GetName ()} - {Path.GetFileName (_currentFile)}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -171,7 +171,7 @@ public class Mazing : Scenario
|
||||
if (_m.PlayerHp <= 0)
|
||||
{
|
||||
_message = "You died!";
|
||||
Application.Current!.SetNeedsDraw (); // trigger redraw
|
||||
Application.TopRunnable!.SetNeedsDraw (); // trigger redraw
|
||||
_dead = true;
|
||||
|
||||
return; // Stop further action if dead
|
||||
@@ -190,7 +190,7 @@ public class Mazing : Scenario
|
||||
_message = string.Empty;
|
||||
}
|
||||
|
||||
Application.Current!.SetNeedsDraw (); // trigger redraw
|
||||
Application.TopRunnable!.SetNeedsDraw (); // trigger redraw
|
||||
}
|
||||
|
||||
// Optional win condition:
|
||||
@@ -200,7 +200,7 @@ public class Mazing : Scenario
|
||||
_m = new (); // Generate a new maze
|
||||
_m.PlayerHp = hp;
|
||||
GenerateNpcs ();
|
||||
Application.Current!.SetNeedsDraw (); // trigger redraw
|
||||
Application.TopRunnable!.SetNeedsDraw (); // trigger redraw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Shortcuts : Scenario
|
||||
private void App_Loaded (object? sender, EventArgs e)
|
||||
{
|
||||
Application.QuitKey = Key.F4.WithCtrl;
|
||||
Application.Current!.Title = GetQuitKeyAndName ();
|
||||
Application.TopRunnable!.Title = GetQuitKeyAndName ();
|
||||
|
||||
ObservableCollection<string> eventSource = new ();
|
||||
|
||||
@@ -46,14 +46,14 @@ public class Shortcuts : Scenario
|
||||
|
||||
eventLog.Width = Dim.Func (
|
||||
_ => Math.Min (
|
||||
Application.Current.Viewport.Width / 2,
|
||||
Application.TopRunnable.Viewport.Width / 2,
|
||||
eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
|
||||
|
||||
eventLog.Width = Dim.Func (
|
||||
_ => Math.Min (
|
||||
eventLog.SuperView!.Viewport.Width / 2,
|
||||
eventLog?.MaxLength + eventLog!.GetAdornmentsThickness ().Horizontal ?? 0));
|
||||
Application.Current.Add (eventLog);
|
||||
Application.TopRunnable.Add (eventLog);
|
||||
|
||||
var alignKeysShortcut = new Shortcut
|
||||
{
|
||||
@@ -86,7 +86,7 @@ public class Shortcuts : Scenario
|
||||
};
|
||||
|
||||
|
||||
Application.Current.Add (alignKeysShortcut);
|
||||
Application.TopRunnable.Add (alignKeysShortcut);
|
||||
|
||||
var commandFirstShortcut = new Shortcut
|
||||
{
|
||||
@@ -115,7 +115,7 @@ public class Shortcuts : Scenario
|
||||
$"{commandFirstShortcut.Id}.CommandView.CheckedStateChanging: {cb.Text}");
|
||||
eventLog.MoveDown ();
|
||||
|
||||
IEnumerable<View> toAlign = Application.Current.SubViews.OfType<Shortcut> ();
|
||||
IEnumerable<View> toAlign = Application.TopRunnable.SubViews.OfType<Shortcut> ();
|
||||
IEnumerable<View> enumerable = toAlign as View [] ?? toAlign.ToArray ();
|
||||
|
||||
foreach (View view in enumerable)
|
||||
@@ -134,7 +134,7 @@ public class Shortcuts : Scenario
|
||||
}
|
||||
};
|
||||
|
||||
Application.Current.Add (commandFirstShortcut);
|
||||
Application.TopRunnable.Add (commandFirstShortcut);
|
||||
|
||||
var canFocusShortcut = new Shortcut
|
||||
{
|
||||
@@ -159,7 +159,7 @@ public class Shortcuts : Scenario
|
||||
SetCanFocus (e.Result == CheckState.Checked);
|
||||
}
|
||||
};
|
||||
Application.Current.Add (canFocusShortcut);
|
||||
Application.TopRunnable.Add (canFocusShortcut);
|
||||
|
||||
var appShortcut = new Shortcut
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public class Shortcuts : Scenario
|
||||
BindKeyToApplication = true
|
||||
};
|
||||
|
||||
Application.Current.Add (appShortcut);
|
||||
Application.TopRunnable.Add (appShortcut);
|
||||
|
||||
var buttonShortcut = new Shortcut
|
||||
{
|
||||
@@ -193,7 +193,7 @@ public class Shortcuts : Scenario
|
||||
var button = (Button)buttonShortcut.CommandView;
|
||||
buttonShortcut.Accepting += Button_Clicked;
|
||||
|
||||
Application.Current.Add (buttonShortcut);
|
||||
Application.TopRunnable.Add (buttonShortcut);
|
||||
|
||||
var optionSelectorShortcut = new Shortcut
|
||||
{
|
||||
@@ -221,7 +221,7 @@ public class Shortcuts : Scenario
|
||||
}
|
||||
};
|
||||
|
||||
Application.Current.Add (optionSelectorShortcut);
|
||||
Application.TopRunnable.Add (optionSelectorShortcut);
|
||||
|
||||
var sliderShortcut = new Shortcut
|
||||
{
|
||||
@@ -248,7 +248,7 @@ public class Shortcuts : Scenario
|
||||
eventLog.MoveDown ();
|
||||
};
|
||||
|
||||
Application.Current.Add (sliderShortcut);
|
||||
Application.TopRunnable.Add (sliderShortcut);
|
||||
|
||||
ListView listView = new ListView ()
|
||||
{
|
||||
@@ -270,7 +270,7 @@ public class Shortcuts : Scenario
|
||||
Key = Key.F5.WithCtrl,
|
||||
};
|
||||
|
||||
Application.Current.Add (listViewShortcut);
|
||||
Application.TopRunnable.Add (listViewShortcut);
|
||||
|
||||
var noCommandShortcut = new Shortcut
|
||||
{
|
||||
@@ -282,7 +282,7 @@ public class Shortcuts : Scenario
|
||||
Key = Key.D0
|
||||
};
|
||||
|
||||
Application.Current.Add (noCommandShortcut);
|
||||
Application.TopRunnable.Add (noCommandShortcut);
|
||||
|
||||
var noKeyShortcut = new Shortcut
|
||||
{
|
||||
@@ -295,7 +295,7 @@ public class Shortcuts : Scenario
|
||||
HelpText = "Keyless"
|
||||
};
|
||||
|
||||
Application.Current.Add (noKeyShortcut);
|
||||
Application.TopRunnable.Add (noKeyShortcut);
|
||||
|
||||
var noHelpShortcut = new Shortcut
|
||||
{
|
||||
@@ -308,7 +308,7 @@ public class Shortcuts : Scenario
|
||||
HelpText = ""
|
||||
};
|
||||
|
||||
Application.Current.Add (noHelpShortcut);
|
||||
Application.TopRunnable.Add (noHelpShortcut);
|
||||
noHelpShortcut.SetFocus ();
|
||||
|
||||
var framedShortcut = new Shortcut
|
||||
@@ -340,7 +340,7 @@ public class Shortcuts : Scenario
|
||||
}
|
||||
|
||||
framedShortcut.SchemeName = SchemeManager.SchemesToSchemeName (Schemes.Toplevel);
|
||||
Application.Current.Add (framedShortcut);
|
||||
Application.TopRunnable.Add (framedShortcut);
|
||||
|
||||
// Horizontal
|
||||
var progressShortcut = new Shortcut
|
||||
@@ -387,7 +387,7 @@ public class Shortcuts : Scenario
|
||||
};
|
||||
timer.Start ();
|
||||
|
||||
Application.Current.Add (progressShortcut);
|
||||
Application.TopRunnable.Add (progressShortcut);
|
||||
|
||||
var textField = new TextField
|
||||
{
|
||||
@@ -408,7 +408,7 @@ public class Shortcuts : Scenario
|
||||
};
|
||||
textField.CanFocus = true;
|
||||
|
||||
Application.Current.Add (textFieldShortcut);
|
||||
Application.TopRunnable.Add (textFieldShortcut);
|
||||
|
||||
var bgColorShortcut = new Shortcut
|
||||
{
|
||||
@@ -450,19 +450,19 @@ public class Shortcuts : Scenario
|
||||
eventSource.Add ($"ColorChanged: {o.GetType ().Name} - {args.Result}");
|
||||
eventLog.MoveDown ();
|
||||
|
||||
Application.Current.SetScheme (
|
||||
new (Application.Current.GetScheme ())
|
||||
Application.TopRunnable.SetScheme (
|
||||
new (Application.TopRunnable.GetScheme ())
|
||||
{
|
||||
Normal = new (
|
||||
Application.Current!.GetAttributeForRole (VisualRole.Normal).Foreground,
|
||||
Application.TopRunnable!.GetAttributeForRole (VisualRole.Normal).Foreground,
|
||||
args.Result,
|
||||
Application.Current!.GetAttributeForRole (VisualRole.Normal).Style)
|
||||
Application.TopRunnable!.GetAttributeForRole (VisualRole.Normal).Style)
|
||||
});
|
||||
}
|
||||
};
|
||||
bgColorShortcut.CommandView = bgColor;
|
||||
|
||||
Application.Current.Add (bgColorShortcut);
|
||||
Application.TopRunnable.Add (bgColorShortcut);
|
||||
|
||||
var appQuitShortcut = new Shortcut
|
||||
{
|
||||
@@ -476,9 +476,9 @@ public class Shortcuts : Scenario
|
||||
};
|
||||
appQuitShortcut.Accepting += (o, args) => { Application.RequestStop (); };
|
||||
|
||||
Application.Current.Add (appQuitShortcut);
|
||||
Application.TopRunnable.Add (appQuitShortcut);
|
||||
|
||||
foreach (Shortcut shortcut in Application.Current.SubViews.OfType<Shortcut> ())
|
||||
foreach (Shortcut shortcut in Application.TopRunnable.SubViews.OfType<Shortcut> ())
|
||||
{
|
||||
shortcut.Selecting += (o, args) =>
|
||||
{
|
||||
@@ -529,7 +529,7 @@ public class Shortcuts : Scenario
|
||||
|
||||
void SetCanFocus (bool canFocus)
|
||||
{
|
||||
foreach (Shortcut peer in Application.Current!.SubViews.OfType<Shortcut> ())
|
||||
foreach (Shortcut peer in Application.TopRunnable!.SubViews.OfType<Shortcut> ())
|
||||
{
|
||||
if (peer.CanFocus)
|
||||
{
|
||||
@@ -542,7 +542,7 @@ public class Shortcuts : Scenario
|
||||
{
|
||||
var max = 0;
|
||||
|
||||
IEnumerable<Shortcut> toAlign = Application.Current!.SubViews.OfType<Shortcut> ().Where(s => !s.Y.Has<PosAnchorEnd>(out _)).Cast<Shortcut>();
|
||||
IEnumerable<Shortcut> toAlign = Application.TopRunnable!.SubViews.OfType<Shortcut> ().Where(s => !s.Y.Has<PosAnchorEnd>(out _)).Cast<Shortcut>();
|
||||
IEnumerable<Shortcut> enumerable = toAlign as Shortcut [] ?? toAlign.ToArray ();
|
||||
|
||||
if (align)
|
||||
|
||||
@@ -179,9 +179,9 @@ public class SingleBackgroundWorker : Scenario
|
||||
|
||||
var builderUI =
|
||||
new StagingUIController (_startStaging, e.Result as ObservableCollection<string>);
|
||||
Toplevel top = Application.Current;
|
||||
Toplevel top = Application.TopRunnable;
|
||||
top.Visible = false;
|
||||
Application.Current.Visible = false;
|
||||
Application.TopRunnable.Visible = false;
|
||||
builderUI.Load ();
|
||||
builderUI.Dispose ();
|
||||
top.Visible = true;
|
||||
|
||||
@@ -129,7 +129,7 @@ public sealed class Themes : Scenario
|
||||
{
|
||||
if (_view is { })
|
||||
{
|
||||
Application.Current!.SchemeName = args.NewValue;
|
||||
Application.TopRunnable!.SchemeName = args.NewValue;
|
||||
|
||||
if (_view.HasScheme)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TreeUseCases : Scenario
|
||||
|
||||
if (_currentTree != null)
|
||||
{
|
||||
Application.Current.Remove (_currentTree);
|
||||
Application.TopRunnable.Remove (_currentTree);
|
||||
_currentTree.Dispose ();
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class TreeUseCases : Scenario
|
||||
tree.TreeBuilder = new GameObjectTreeBuilder ();
|
||||
}
|
||||
|
||||
Application.Current.Add (tree);
|
||||
Application.TopRunnable.Add (tree);
|
||||
|
||||
tree.AddObject (army1);
|
||||
|
||||
@@ -117,13 +117,13 @@ public class TreeUseCases : Scenario
|
||||
|
||||
if (_currentTree != null)
|
||||
{
|
||||
Application.Current.Remove (_currentTree);
|
||||
Application.TopRunnable.Remove (_currentTree);
|
||||
_currentTree.Dispose ();
|
||||
}
|
||||
|
||||
var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill (1) };
|
||||
|
||||
Application.Current.Add (tree);
|
||||
Application.TopRunnable.Add (tree);
|
||||
|
||||
tree.AddObject (myHouse);
|
||||
|
||||
@@ -134,13 +134,13 @@ public class TreeUseCases : Scenario
|
||||
{
|
||||
if (_currentTree != null)
|
||||
{
|
||||
Application.Current.Remove (_currentTree);
|
||||
Application.TopRunnable.Remove (_currentTree);
|
||||
_currentTree.Dispose ();
|
||||
}
|
||||
|
||||
var tree = new TreeView { X = 0, Y = 1, Width = Dim.Fill (), Height = Dim.Fill (1) };
|
||||
|
||||
Application.Current.Add (tree);
|
||||
Application.TopRunnable.Add (tree);
|
||||
|
||||
var root1 = new TreeNode ("Root1");
|
||||
root1.Children.Add (new TreeNode ("Child1.1"));
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WindowsAndFrameViews : Scenario
|
||||
// add it to our list
|
||||
listWin.Add (win);
|
||||
|
||||
// create 3 more Windows in a loop, adding them Application.Current
|
||||
// create 3 more Windows in a loop, adding them Application.TopRunnable
|
||||
// Each with a
|
||||
// button
|
||||
// sub Window with
|
||||
|
||||
@@ -246,7 +246,7 @@ public class UICatalog
|
||||
|
||||
/// <summary>
|
||||
/// Shows the UI Catalog selection UI. When the user selects a Scenario to run, the UI Catalog main app UI is
|
||||
/// killed and the Scenario is run as though it were Application.Current. When the Scenario exits, this function exits.
|
||||
/// killed and the Scenario is run as though it were Application.TopRunnable. When the Scenario exits, this function exits.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static Scenario RunUICatalogTopLevel ()
|
||||
@@ -347,7 +347,7 @@ public class UICatalog
|
||||
|
||||
private static void ConfigFileChanged (object sender, FileSystemEventArgs e)
|
||||
{
|
||||
if (Application.Current == null)
|
||||
if (Application.TopRunnable == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -700,7 +700,7 @@ public class UICatalogTop : Toplevel
|
||||
_disableMouseCb!.CheckedState = Application.IsMouseDisabled ? CheckState.Checked : CheckState.UnChecked;
|
||||
_force16ColorsShortcutCb!.CheckedState = Application.Force16Colors ? CheckState.Checked : CheckState.UnChecked;
|
||||
|
||||
Application.Current?.SetNeedsDraw ();
|
||||
Application.TopRunnable?.SetNeedsDraw ();
|
||||
}
|
||||
|
||||
private void ConfigAppliedHandler (object? sender, ConfigurationManagerEventArgs? a) { ConfigApplied (); }
|
||||
|
||||
Reference in New Issue
Block a user