From 5dc2ec7606208323280f6416c370484bdf63913b Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Sat, 29 Oct 2022 17:48:32 -0600 Subject: [PATCH] Clean up old code --- UICatalog/Scenario.cs | 5 +---- UICatalog/Scenarios/AllViewsTester.cs | 5 +---- UICatalog/Scenarios/BordersComparisons.cs | 1 - UICatalog/Scenarios/Clipping.cs | 12 +----------- UICatalog/Scenarios/Editor.cs | 5 +---- UICatalog/Scenarios/WindowsAndFrameViews.cs | 5 +---- UICatalog/UICatalog.cs | 19 ++++--------------- 7 files changed, 9 insertions(+), 43 deletions(-) diff --git a/UICatalog/Scenario.cs b/UICatalog/Scenario.cs index e2a28fbcd..c747829e3 100644 --- a/UICatalog/Scenario.cs +++ b/UICatalog/Scenario.cs @@ -77,10 +77,7 @@ namespace UICatalog { { Application.Init (); - Top = top; - if (Top == null) { - Top = Application.Top; - } + Top = top != null ? top : Application.Top; Win = new Window ($"CTRL-Q to Close - Scenario: {GetName ()}") { X = 0, diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index b82300b13..945b25df8 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -44,10 +44,7 @@ namespace UICatalog.Scenarios { { Application.Init (); - Top = top; - if (Top == null) { - Top = Application.Top; - } + Top = top != null ? top : Application.Top; //Win = new Window ($"CTRL-Q to Close - Scenario: {GetName ()}") { // X = 0, diff --git a/UICatalog/Scenarios/BordersComparisons.cs b/UICatalog/Scenarios/BordersComparisons.cs index baaabcae0..9ea462f52 100644 --- a/UICatalog/Scenarios/BordersComparisons.cs +++ b/UICatalog/Scenarios/BordersComparisons.cs @@ -7,7 +7,6 @@ namespace UICatalog.Scenarios { public class BordersComparisons : Scenario { public override void Init (Toplevel top, ColorScheme colorScheme) { - top.Dispose (); Application.Init (); top = Application.Top; diff --git a/UICatalog/Scenarios/Clipping.cs b/UICatalog/Scenarios/Clipping.cs index 22d2067ec..9c137f03e 100644 --- a/UICatalog/Scenarios/Clipping.cs +++ b/UICatalog/Scenarios/Clipping.cs @@ -11,19 +11,9 @@ namespace UICatalog.Scenarios { { Application.Init (); - Top = top; - if (Top == null) { - Top = Application.Top; - } + Top = top != null ? top : Application.Top; Top.ColorScheme = Colors.Base; - //Win = new TopLevel($"CTRL-Q to Close - Scenario: {GetName ()}") { - // X = 0, - // Y = 0, - // Width = Dim.Fill (), - // Height = Dim.Fill () - //}; - //Top.Add (Win); } public override void Setup () diff --git a/UICatalog/Scenarios/Editor.cs b/UICatalog/Scenarios/Editor.cs index 96f11363e..38d62ee4c 100644 --- a/UICatalog/Scenarios/Editor.cs +++ b/UICatalog/Scenarios/Editor.cs @@ -35,10 +35,7 @@ namespace UICatalog.Scenarios { public override void Init (Toplevel top, ColorScheme colorScheme) { Application.Init (); - Top = top; - if (Top == null) { - Top = Application.Top; - } + Top = top != null ? top : Application.Top; Win = new Window (_fileName ?? "Untitled") { X = 0, diff --git a/UICatalog/Scenarios/WindowsAndFrameViews.cs b/UICatalog/Scenarios/WindowsAndFrameViews.cs index e6ae58301..ca3f613ef 100644 --- a/UICatalog/Scenarios/WindowsAndFrameViews.cs +++ b/UICatalog/Scenarios/WindowsAndFrameViews.cs @@ -10,10 +10,7 @@ namespace UICatalog.Scenarios { { Application.Init (); - Top = top; - if (Top == null) { - Top = Application.Top; - } + Top = top != null ? top : Application.Top; } public override void RequestStop () diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index cd625730a..33f69f321 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -57,7 +57,9 @@ namespace UICatalog { private static StatusItem _numlock; private static StatusItem _scrolllock; + // If set, holds the scenario the user selected private static Scenario _selectedScenario = null; + private static bool _useSystemConsole = false; private static ConsoleDriver.DiagnosticFlags _diagnosticFlags; private static bool _heightAsBuffer = false; @@ -140,10 +142,6 @@ namespace UICatalog { #endif } - // This call to Application.Shutdown brackets the Application.Init call - // for the main UI Catalog app (in SelectScenario()). - //Application.Shutdown (); - #if DEBUG_IDISPOSABLE // This proves that when the user exited the UI Catalog app // it cleaned up properly. @@ -291,12 +289,9 @@ namespace UICatalog { _categoryListView.SelectedItem = _cachedCategoryIndex; _scenarioListView.SelectedItem = _cachedScenarioIndex; - // Run UI Catalog UI. When it exits, if _runningScenario is != null then + // Run UI Catalog UI. When it exits, if _selectedScenario is != null then // a Scenario was selected. Otherwise, the user wants to exit UI Catalog. Application.Run (Application.Top); - - // BUGBUG: Shouldn't Application.Shutdown() be called here? Why is it currently - // outside of the SelectScenario() loop? Application.Shutdown (); return _selectedScenario; @@ -304,7 +299,7 @@ namespace UICatalog { /// - /// Launches the selected scenario, setting the global _runningScenario + /// Launches the selected scenario, setting the global _selectedScenario /// /// private static void _scenarioListView_OpenSelectedItem (EventArgs e) @@ -504,12 +499,6 @@ namespace UICatalog { return menuItems.ToArray (); } - /// - /// When Scenarios are running we need to override the behavior of the Menu - /// and Statusbar to enable Scenarios that use those (or related key input) - /// to not be impacted. Same as for tabs. - /// - /// private static void KeyDownHandler (View.KeyEventEventArgs a) { if (a.KeyEvent.IsCapslock) {