From 2c725b877fd331d0e43c6806af1af3b35427b2be Mon Sep 17 00:00:00 2001 From: Tig Date: Mon, 15 Jan 2024 17:46:53 -0700 Subject: [PATCH] Fixes #2944. Makes `ColorScheme` explicitly readonly, removes `Colors.Base`, etc..., Fixes intermittent `TreeView` unit test failures (#3175) * Removed resharper settings from editorconfig * Moved ColorScheme to ColorScheme.cs * Moved ColorScheme to ColorScheme.cs * Potential fix. PlatformColor was not being set by FakeDriver correctly. * Made ColorScheme effectively readonly * Removed Color.Base etc... Updated API docs. --- ReactiveExample/LoginView.cs | 2 +- Terminal.Gui/Application.cs | 2 + .../Configuration/ColorSchemeJsonConverter.cs | 24 +- Terminal.Gui/Configuration/ThemeManager.cs | 2 +- Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs | 2 +- Terminal.Gui/Drawing/Color.cs | 264 +----------------- Terminal.Gui/Drawing/ColorScheme.cs | 246 ++++++++++++++++ .../Text/Autocomplete/PopupAutocomplete.cs | 2 +- Terminal.Gui/View/Adornment/Border.cs | 2 +- Terminal.Gui/View/Adornment/Margin.cs | 2 +- Terminal.Gui/View/ViewDrawing.cs | 9 +- Terminal.Gui/Views/ComboBox.cs | 8 +- Terminal.Gui/Views/Dialog.cs | 4 +- Terminal.Gui/Views/FileDialog.cs | 4 +- Terminal.Gui/Views/Menu/MenuBar.cs | 2 +- Terminal.Gui/Views/MessageBox.cs | 4 +- Terminal.Gui/Views/StatusBar.cs | 2 +- Terminal.Gui/Views/Toplevel.cs | 2 +- Terminal.Gui/Views/Window.cs | 4 +- Terminal.Gui/Views/Wizard/Wizard.cs | 4 +- Terminal.sln | 1 - UICatalog/Scenarios/Adornments.cs | 6 +- UICatalog/Scenarios/AllViewsTester.cs | 10 +- .../Scenarios/AutoSizeAndDirectionText.cs | 2 +- .../Scenarios/BackgroundWorkerCollection.cs | 6 +- UICatalog/Scenarios/BasicColors.cs | 5 +- UICatalog/Scenarios/Buttons.cs | 14 +- UICatalog/Scenarios/CharacterMap.cs | 4 +- UICatalog/Scenarios/Clipping.cs | 12 +- .../Scenarios/CollectionNavigatorTester.cs | 2 +- UICatalog/Scenarios/ComboBoxIteration.cs | 2 +- UICatalog/Scenarios/ComputedLayout.cs | 26 +- UICatalog/Scenarios/Dialogs.cs | 2 +- UICatalog/Scenarios/DynamicMenuBar.cs | 4 +- UICatalog/Scenarios/DynamicStatusBar.cs | 2 +- UICatalog/Scenarios/Editor.cs | 2 +- UICatalog/Scenarios/InvertColors.cs | 10 +- UICatalog/Scenarios/Keys.cs | 10 +- UICatalog/Scenarios/LabelsAsButtons.cs | 14 +- UICatalog/Scenarios/LineCanvasExperiment.cs | 4 +- UICatalog/Scenarios/ListViewWithSelection.cs | 2 +- UICatalog/Scenarios/ListsAndCombos.cs | 4 +- UICatalog/Scenarios/MenuBarScenario.cs | 2 +- UICatalog/Scenarios/MessageBoxes.cs | 2 +- UICatalog/Scenarios/Mouse.cs | 2 +- UICatalog/Scenarios/Notepad.cs | 2 +- UICatalog/Scenarios/Progress.cs | 6 +- .../Scenarios/RuneWidthGreaterThanOne.cs | 2 +- UICatalog/Scenarios/Scrolling.cs | 12 +- UICatalog/Scenarios/SingleBackgroundWorker.cs | 2 +- UICatalog/Scenarios/Sliders.cs | 11 +- UICatalog/Scenarios/TextAlignments.cs | 6 +- .../Scenarios/TextAlignmentsAndDirection.cs | 2 +- UICatalog/Scenarios/TextFormatterDemo.cs | 8 +- UICatalog/Scenarios/Threading.cs | 4 +- UICatalog/Scenarios/VkeyPacketSimulator.cs | 8 +- UICatalog/Scenarios/WindowsAndFrameViews.cs | 28 +- UICatalog/Scenarios/Wizards.cs | 6 +- UnitTests/Application/ApplicationTests.cs | 4 +- .../Configuration/ConfigurationMangerTests.cs | 34 +-- UnitTests/Configuration/ThemeTests.cs | 12 +- UnitTests/Drawing/ColorSchemeTests.cs | 43 +++ UnitTests/Drawing/ColorTests.cs | 22 -- UnitTests/TestHelpers.cs | 27 +- UnitTests/Text/AutocompleteTests.cs | 4 +- UnitTests/UICatalog/ScenarioTests.cs | 10 +- UnitTests/View/Adornment/BorderTests.cs | 1 - UnitTests/View/DrawTests.cs | 18 +- UnitTests/View/Text/AutoSizeTextTests.cs | 8 +- UnitTests/View/ViewTests.cs | 14 +- UnitTests/Views/MenuBarTests.cs | 6 +- UnitTests/Views/OverlappedTests.cs | 4 +- UnitTests/Views/ProgressBarTests.cs | 2 +- UnitTests/Views/RuneCellTests.cs | 10 +- UnitTests/Views/ScrollViewTests.cs | 6 +- UnitTests/Views/StatusBarTests.cs | 2 +- UnitTests/Views/TableViewTests.cs | 106 +++---- UnitTests/Views/TextFieldTests.cs | 2 +- UnitTests/Views/TextViewTests.cs | 2 +- UnitTests/Views/ToplevelTests.cs | 2 +- UnitTests/Views/TreeTableSourceTests.cs | 4 +- 81 files changed, 616 insertions(+), 565 deletions(-) create mode 100644 Terminal.Gui/Drawing/ColorScheme.cs create mode 100644 UnitTests/Drawing/ColorSchemeTests.cs diff --git a/ReactiveExample/LoginView.cs b/ReactiveExample/LoginView.cs index a74fb9f94d..eb9fc13781 100644 --- a/ReactiveExample/LoginView.cs +++ b/ReactiveExample/LoginView.cs @@ -122,7 +122,7 @@ Label ValidationLabel (View previous) { .DisposeWith (_disposable); ViewModel .WhenAnyValue (x => x.IsValid) - .Select (valid => valid ? Colors.Base : Colors.Error) + .Select (valid => valid ? Colors.ColorSchemes ["Base"] : Colors.ColorSchemes ["Error"]) .BindTo (validationLabel, x => x.ColorScheme) .DisposeWith (_disposable); Add (validationLabel); diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs index 8973d8edb4..58bfddd4d8 100644 --- a/Terminal.Gui/Application.cs +++ b/Terminal.Gui/Application.cs @@ -96,6 +96,8 @@ internal static void ResetState () KeyUp = null; SizeChanging = null; + Colors.Reset (); + // Reset synchronization context to allow the user to run async/await, // as the main loop has been ended, the synchronization context from // gui.cs does no longer process any callbacks. See #1084 for more details: diff --git a/Terminal.Gui/Configuration/ColorSchemeJsonConverter.cs b/Terminal.Gui/Configuration/ColorSchemeJsonConverter.cs index 6a57de14db..45a3169858 100644 --- a/Terminal.Gui/Configuration/ColorSchemeJsonConverter.cs +++ b/Terminal.Gui/Configuration/ColorSchemeJsonConverter.cs @@ -28,10 +28,22 @@ public override ColorScheme Read (ref Utf8JsonReader reader, Type typeToConvert, throw new JsonException ($"Unexpected StartObject token when parsing ColorScheme: {reader.TokenType}."); } - var colorScheme = new ColorScheme (); + Attribute normal = Attribute.Default; + Attribute focus = Attribute.Default; + Attribute hotNormal = Attribute.Default; + Attribute hotFocus = Attribute.Default; + Attribute disabled = Attribute.Default; while (reader.Read ()) { if (reader.TokenType == JsonTokenType.EndObject) { + var colorScheme = new ColorScheme () { + Normal = normal, + Focus = focus, + HotNormal = hotNormal, + HotFocus = hotFocus, + Disabled = disabled + }; + return colorScheme; } @@ -45,19 +57,19 @@ public override ColorScheme Read (ref Utf8JsonReader reader, Type typeToConvert, switch (propertyName.ToLower()) { case "normal": - colorScheme.Normal = attribute; + normal = attribute; break; case "focus": - colorScheme.Focus = attribute; + focus = attribute; break; case "hotnormal": - colorScheme.HotNormal = attribute; + hotNormal = attribute; break; case "hotfocus": - colorScheme.HotFocus = attribute; + hotFocus = attribute; break; case "disabled": - colorScheme.Disabled = attribute; + disabled = attribute; break; default: throw new JsonException ($"Unrecognized ColorScheme Attribute name: {propertyName}."); diff --git a/Terminal.Gui/Configuration/ThemeManager.cs b/Terminal.Gui/Configuration/ThemeManager.cs index bf3cf6dd95..a04b3606ba 100644 --- a/Terminal.Gui/Configuration/ThemeManager.cs +++ b/Terminal.Gui/Configuration/ThemeManager.cs @@ -133,7 +133,7 @@ public static Dictionary? Themes { internal static void Reset () { Debug.WriteLine ($"Themes.Reset()"); - + Colors.Reset (); Themes?.Clear (); SelectedTheme = string.Empty; } diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs index 5f88a09e13..17d0846ae3 100644 --- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs @@ -467,7 +467,7 @@ public Attribute SetAttribute (Attribute c) public virtual Attribute MakeColor (Color foreground, Color background) => // Encode the colors into the int value. new ( - 0, // only used by cursesdriver! + -1, // only used by cursesdriver! foreground, background ); diff --git a/Terminal.Gui/Drawing/Color.cs b/Terminal.Gui/Drawing/Color.cs index f4c221dddc..9a2e8b5e77 100644 --- a/Terminal.Gui/Drawing/Color.cs +++ b/Terminal.Gui/Drawing/Color.cs @@ -4,7 +4,6 @@ using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.Linq; -using System.Runtime.CompilerServices; using System.Text.Json.Serialization; using System.Text.RegularExpressions; @@ -634,24 +633,23 @@ public override string ToString () public static implicit operator Color (int rgba) => new (rgba); /// - /// Cast to int. + /// Cast to int. /// /// - public static explicit operator int (Color color) => color.Rgba; + public static implicit operator int (Color color) => color.Rgba; /// - /// Cast from . + /// Cast from . May fail if the color is not a named color. /// /// public static explicit operator Color (ColorName colorName) => new (colorName); /// - /// Cast to . + /// Cast to . May fail if the color is not a named color. /// /// public static explicit operator ColorName (Color color) => color.ColorName; - /// /// Equality operator for two objects.. /// @@ -660,7 +658,6 @@ public override string ToString () /// public static bool operator == (Color left, Color right) => left.Equals (right); - /// /// Inequality operator for two objects. /// @@ -888,257 +885,6 @@ public bool Equals (Attribute other) => PlatformColor == other.PlatformColor && /// public override string ToString () => - // Note, Unit tests are dependent on this format + // Note: Unit tests are dependent on this format $"[{Foreground},{Background}]"; } - -/// -/// Defines the s for common visible elements in a . -/// Containers such as and use to determine -/// the colors used by sub-views. -/// -/// -/// See also: . -/// -[JsonConverter (typeof (ColorSchemeJsonConverter))] -public class ColorScheme : IEquatable { - Attribute _disabled = Attribute.Default; - Attribute _focus = Attribute.Default; - Attribute _hotFocus = Attribute.Default; - Attribute _hotNormal = Attribute.Default; - Attribute _normal = Attribute.Default; - - /// - /// Used by and to - /// track which ColorScheme - /// is being accessed. - /// - internal string _schemeBeingSet = ""; - - /// - /// Creates a new instance. - /// - public ColorScheme () : this (Attribute.Default) { } - - /// - /// Creates a new instance, initialized with the values from . - /// - /// The scheme to initialize the new instance with. - public ColorScheme (ColorScheme scheme) - { - if (scheme != null) { - _normal = scheme.Normal; - _focus = scheme.Focus; - _hotNormal = scheme.HotNormal; - _disabled = scheme.Disabled; - _hotFocus = scheme.HotFocus; - } - } - - /// - /// Creates a new instance, initialized with the values from . - /// - /// The attribute to initialize the new instance with. - public ColorScheme (Attribute attribute) - { - _normal = attribute; - _focus = attribute; - _hotNormal = attribute; - _disabled = attribute; - _hotFocus = attribute; - } - - /// - /// The foreground and background color for text when the view is not focused, hot, or disabled. - /// - public Attribute Normal { - get => _normal; - set => _normal = value; - } - - /// - /// The foreground and background color for text when the view has the focus. - /// - public Attribute Focus { - get => _focus; - set => _focus = value; - } - - /// - /// The foreground and background color for text in a non-focused view that indicates a . - /// - public Attribute HotNormal { - get => _hotNormal; - set => _hotNormal = value; - } - - /// - /// The foreground and background color for for text in a focused view that indicates a . - /// - public Attribute HotFocus { - get => _hotFocus; - set => _hotFocus = value; - } - - /// - /// The default foreground and background color for text when the view is disabled. - /// - public Attribute Disabled { - get => _disabled; - set => _disabled = value; - } - - /// - /// Compares two objects for equality. - /// - /// - /// true if the two objects are equal - public bool Equals (ColorScheme other) => other != null && - EqualityComparer.Default.Equals (_normal, other._normal) && - EqualityComparer.Default.Equals (_focus, other._focus) && - EqualityComparer.Default.Equals (_hotNormal, other._hotNormal) && - EqualityComparer.Default.Equals (_hotFocus, other._hotFocus) && - EqualityComparer.Default.Equals (_disabled, other._disabled); - - /// - /// Compares two objects for equality. - /// - /// - /// true if the two objects are equal - public override bool Equals (object obj) => Equals (obj as ColorScheme); - - /// - /// Returns a hashcode for this instance. - /// - /// hashcode for this instance - public override int GetHashCode () - { - var hashCode = -1242460230; - hashCode = hashCode * -1521134295 + _normal.GetHashCode (); - hashCode = hashCode * -1521134295 + _focus.GetHashCode (); - hashCode = hashCode * -1521134295 + _hotNormal.GetHashCode (); - hashCode = hashCode * -1521134295 + _hotFocus.GetHashCode (); - hashCode = hashCode * -1521134295 + _disabled.GetHashCode (); - return hashCode; - } - - /// - /// Compares two objects for equality. - /// - /// - /// - /// true if the two objects are equivalent - public static bool operator == (ColorScheme left, ColorScheme right) => EqualityComparer.Default.Equals (left, right); - - /// - /// Compares two objects for inequality. - /// - /// - /// - /// true if the two objects are not equivalent - public static bool operator != (ColorScheme left, ColorScheme right) => !(left == right); -} - -/// -/// The default s for the application. -/// -/// -/// This property can be set in a Theme to change the default for the application. -/// -public static class Colors { - - static Colors () => ColorSchemes = Create (); - - /// - /// The application Toplevel color scheme, for the default Toplevel views. - /// - /// - /// - /// This API will be deprecated in the future. Use instead (e.g. - /// edit.ColorScheme = Colors.ColorSchemes["TopLevel"]; - /// - /// - public static ColorScheme TopLevel { get => GetColorScheme (); set => SetColorScheme (value); } - - /// - /// The base color scheme, for the default Toplevel views. - /// - /// - /// - /// This API will be deprecated in the future. Use instead (e.g. - /// edit.ColorScheme = Colors.ColorSchemes["Base"]; - /// - /// - public static ColorScheme Base { get => GetColorScheme (); set => SetColorScheme (value); } - - /// - /// The dialog color scheme, for standard popup dialog boxes - /// - /// - /// - /// This API will be deprecated in the future. Use instead (e.g. - /// edit.ColorScheme = Colors.ColorSchemes["Dialog"]; - /// - /// - public static ColorScheme Dialog { get => GetColorScheme (); set => SetColorScheme (value); } - - /// - /// The menu bar color - /// - /// - /// - /// This API will be deprecated in the future. Use instead (e.g. - /// edit.ColorScheme = Colors.ColorSchemes["Menu"]; - /// - /// - public static ColorScheme Menu { get => GetColorScheme (); set => SetColorScheme (value); } - - /// - /// The color scheme for showing errors. - /// - /// - /// - /// This API will be deprecated in the future. Use instead (e.g. - /// edit.ColorScheme = Colors.ColorSchemes["Error"]; - /// - /// - public static ColorScheme Error { get => GetColorScheme (); set => SetColorScheme (value); } - - /// - /// Provides the defined s. - /// - [SerializableConfigurationProperty (Scope = typeof (ThemeScope), OmitClassName = true)] - [JsonConverter (typeof (DictionaryJsonConverter))] - public static Dictionary ColorSchemes { get; private set; } // Serialization requires this to have a setter (private set;) - - /// - /// Creates a new dictionary of new objects. - /// - public static Dictionary Create () => - // Use reflection to dynamically create the default set of ColorSchemes from the list defined - // by the class. - typeof (Colors).GetProperties () - .Where (p => p.PropertyType == typeof (ColorScheme)) - .Select (p => new KeyValuePair (p.Name, new ColorScheme ())) - .ToDictionary (t => t.Key, t => t.Value, new SchemeNameComparerIgnoreCase ()); - - static ColorScheme GetColorScheme ([CallerMemberName] string schemeBeingSet = null) => ColorSchemes [schemeBeingSet]; - - static void SetColorScheme (ColorScheme colorScheme, [CallerMemberName] string schemeBeingSet = null) - { - ColorSchemes [schemeBeingSet] = colorScheme; - colorScheme._schemeBeingSet = schemeBeingSet; - } - - class SchemeNameComparerIgnoreCase : IEqualityComparer { - public bool Equals (string x, string y) - { - if (x != null && y != null) { - return string.Equals (x, y, StringComparison.InvariantCultureIgnoreCase); - } - return false; - } - - public int GetHashCode (string obj) => obj.ToLowerInvariant ().GetHashCode (); - } -} \ No newline at end of file diff --git a/Terminal.Gui/Drawing/ColorScheme.cs b/Terminal.Gui/Drawing/ColorScheme.cs new file mode 100644 index 0000000000..e988365a10 --- /dev/null +++ b/Terminal.Gui/Drawing/ColorScheme.cs @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Terminal.Gui; + +/// +/// Defines a standard set of s for common visible elements in a . +/// +/// +/// +/// ColorScheme objects are immutable. Once constructed, the properties cannot be changed. +/// To change a ColorScheme, create a new one with the desired values, +/// using the constructor. +/// +/// +/// See also: . +/// +/// +[JsonConverter (typeof (ColorSchemeJsonConverter))] +public class ColorScheme : IEquatable { + readonly Attribute _disabled = Attribute.Default; + readonly Attribute _focus = Attribute.Default; + readonly Attribute _hotFocus = Attribute.Default; + readonly Attribute _hotNormal = Attribute.Default; + readonly Attribute _normal = Attribute.Default; + + /// + /// Creates a new instance set to the default colors (see ). + /// + public ColorScheme () : this (Attribute.Default) { } + + /// + /// Creates a new instance, initialized with the values from . + /// + /// The scheme to initialize the new instance with. + public ColorScheme (ColorScheme scheme) + { + if (scheme == null) { + throw new ArgumentNullException (nameof (scheme)); + } + _normal = scheme.Normal; + _focus = scheme.Focus; + _hotNormal = scheme.HotNormal; + _disabled = scheme.Disabled; + _hotFocus = scheme.HotFocus; + } + + /// + /// Creates a new instance, initialized with the values from . + /// + /// The attribute to initialize the new instance with. + public ColorScheme (Attribute attribute) + { + _normal = attribute; + _focus = attribute; + _hotNormal = attribute; + _disabled = attribute; + _hotFocus = attribute; + } + + /// + /// The foreground and background color for text when the view is not focused, hot, or disabled. + /// + public Attribute Normal { + get => _normal; + init => _normal = value; + } + + /// + /// The foreground and background color for text when the view has the focus. + /// + public Attribute Focus { + get => _focus; + init => _focus = value; + } + + /// + /// The foreground and background color for text in a non-focused view that indicates a . + /// + public Attribute HotNormal { + get => _hotNormal; + init => _hotNormal = value; + } + + /// + /// The foreground and background color for for text in a focused view that indicates a . + /// + public Attribute HotFocus { + get => _hotFocus; + init => _hotFocus = value; + } + + /// + /// The default foreground and background color for text when the view is disabled. + /// + public Attribute Disabled { + get => _disabled; + init => _disabled = value; + } + + /// + /// Compares two objects for equality. + /// + /// + /// true if the two objects are equal + public bool Equals (ColorScheme other) => other != null && + EqualityComparer.Default.Equals (_normal, other._normal) && + EqualityComparer.Default.Equals (_focus, other._focus) && + EqualityComparer.Default.Equals (_hotNormal, other._hotNormal) && + EqualityComparer.Default.Equals (_hotFocus, other._hotFocus) && + EqualityComparer.Default.Equals (_disabled, other._disabled); + + /// + /// Compares two objects for equality. + /// + /// + /// true if the two objects are equal + public override bool Equals (object obj) => Equals (obj is ColorScheme ? (ColorScheme)obj : default); + + /// + /// Returns a hashcode for this instance. + /// + /// hashcode for this instance + public override int GetHashCode () + { + var hashCode = -1242460230; + hashCode = hashCode * -1521134295 + _normal.GetHashCode (); + hashCode = hashCode * -1521134295 + _focus.GetHashCode (); + hashCode = hashCode * -1521134295 + _hotNormal.GetHashCode (); + hashCode = hashCode * -1521134295 + _hotFocus.GetHashCode (); + hashCode = hashCode * -1521134295 + _disabled.GetHashCode (); + return hashCode; + } + + /// + /// Compares two objects for equality. + /// + /// + /// + /// true if the two objects are equivalent + public static bool operator == (ColorScheme left, ColorScheme right) => EqualityComparer.Default.Equals (left, right); + + /// + /// Compares two objects for inequality. + /// + /// + /// + /// true if the two objects are not equivalent + public static bool operator != (ColorScheme left, ColorScheme right) => !(left == right); +} + +/// +/// Holds the s that define the s that are used by views to render themselves. +/// +public static class Colors { + static Colors () => Reset (); + /// + /// Gets a dictionary of defined objects. + /// + /// + /// + /// The dictionary includes the following keys, by default: + /// + /// + /// Built-in Color Scheme + /// Description + /// + /// + /// + /// Base + /// + /// + /// The base color scheme used for most Views. + /// + /// + /// + /// + /// TopLevel + /// + /// + /// The application Toplevel color scheme; used for the View. + /// + /// + /// + /// + /// Dialog + /// + /// + /// The dialog color scheme; used for , , and other views dialog-like views. + /// + /// + /// + /// + /// Menu + /// + /// + /// The menu color scheme; used for , , and . + /// + /// + /// + /// + /// Error + /// + /// + /// The color scheme for showing errors, such as in . + /// + /// + /// + /// + /// + /// Changing the values of an entry in this dictionary will affect all views that use the scheme. + /// + /// + /// can be used to override the default values for these schemes and add additional schemes. + /// See . + /// + /// + [SerializableConfigurationProperty (Scope = typeof (ThemeScope), OmitClassName = true)] + [JsonConverter (typeof (DictionaryJsonConverter))] + public static Dictionary ColorSchemes { get; private set; } // Serialization requires this to have a setter (private set;) + + /// + /// Resets the dictionary to the default values. + /// + public static Dictionary Reset () => + ColorSchemes = new Dictionary (comparer: new SchemeNameComparerIgnoreCase ()) { + { "TopLevel", new ColorScheme () }, + { "Base", new ColorScheme () }, + { "Dialog", new ColorScheme () }, + { "Menu", new ColorScheme () }, + { "Error", new ColorScheme () }, + }; + + class SchemeNameComparerIgnoreCase : IEqualityComparer { + public bool Equals (string x, string y) + { + if (x != null && y != null) { + return string.Equals (x, y, StringComparison.InvariantCultureIgnoreCase); + } + return false; + } + + public int GetHashCode (string obj) => obj.ToLowerInvariant ().GetHashCode (); + } +} \ No newline at end of file diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs index a805b6cf3a..4ff5bb2cc3 100644 --- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs @@ -124,7 +124,7 @@ private void ManipulatePopup () public override ColorScheme ColorScheme { get { if (colorScheme == null) { - colorScheme = Colors.Menu; + colorScheme = Colors.ColorSchemes ["Menu"]; } return colorScheme; } diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs index de9b39e36d..f37c09d734 100644 --- a/Terminal.Gui/View/Adornment/Border.cs +++ b/Terminal.Gui/View/Adornment/Border.cs @@ -99,7 +99,7 @@ public override void OnDrawContent (Rect contentArea) return; } - //Driver.SetAttribute (Colors.Error.Normal); + //Driver.SetAttribute (Colors.ColorSchemes ["Error"].Normal); var screenBounds = BoundsToScreen (Frame); //OnDrawSubviews (bounds); diff --git a/Terminal.Gui/View/Adornment/Margin.cs b/Terminal.Gui/View/Adornment/Margin.cs index e90ea0e62b..82737ec16a 100644 --- a/Terminal.Gui/View/Adornment/Margin.cs +++ b/Terminal.Gui/View/Adornment/Margin.cs @@ -27,7 +27,7 @@ public override ColorScheme ColorScheme { if (base.ColorScheme != null) { return base.ColorScheme; } - return Parent?.SuperView?.ColorScheme ?? Colors.TopLevel; + return Parent?.SuperView?.ColorScheme ?? Colors.ColorSchemes ["TopLevel"]; } set { base.ColorScheme = value; diff --git a/Terminal.Gui/View/ViewDrawing.cs b/Terminal.Gui/View/ViewDrawing.cs index 6a3c29b521..4edf04a724 100644 --- a/Terminal.Gui/View/ViewDrawing.cs +++ b/Terminal.Gui/View/ViewDrawing.cs @@ -274,6 +274,9 @@ internal Rect ScreenClip (Rect regionScreen) /// public Rect ClipToBounds () { + if (Driver == null) { + return Rect.Empty; + } var previous = Driver.Clip; Driver.Clip = Rect.Intersect (previous, BoundsToScreen (Bounds)); return previous; @@ -392,7 +395,7 @@ public void Draw () if (ColorScheme != null) { //Driver.SetAttribute (HasFocus ? GetFocusColor () : GetNormalColor ()); - Driver.SetAttribute (GetNormalColor ()); + Driver?.SetAttribute (GetNormalColor ()); } // Invoke DrawContentEvent @@ -403,7 +406,9 @@ public void Draw () OnDrawContent (Bounds); } - Driver.Clip = prevClip; + if (Driver != null) { + Driver.Clip = prevClip; + } OnRenderLineCanvas (); // Invoke DrawContentCompleteEvent diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index af7ef4c78a..60e2f8b1aa 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -255,7 +255,7 @@ public ComboBox (string text) : base () public ComboBox (Rect rect, IList source) : base (rect) { _search = new TextField ("") { Width = rect.Width }; - _listview = new ComboListView (this, rect, source, HideDropdownListOnClick) { ColorScheme = Colors.Base }; + _listview = new ComboListView (this, rect, source, HideDropdownListOnClick) { ColorScheme = Colors.ColorSchemes ["Base"] }; SetInitialProperties (); SetSource (source); @@ -268,7 +268,7 @@ public ComboBox (Rect rect, IList source) : base (rect) public ComboBox (IList source) : this (string.Empty) { _search = new TextField (""); - _listview = new ComboListView (this, source, HideDropdownListOnClick) { ColorScheme = Colors.Base }; + _listview = new ComboListView (this, source, HideDropdownListOnClick) { ColorScheme = Colors.ColorSchemes ["Base"] }; SetInitialProperties (); SetSource (source); @@ -396,7 +396,9 @@ public bool ReadOnly { _search.ReadOnly = value; if (_search.ReadOnly) { if (_search.ColorScheme != null) { - _search.ColorScheme.Normal = _search.ColorScheme.Focus; + _search.ColorScheme = new ColorScheme (_search.ColorScheme) { + Normal = _search.ColorScheme.Focus + }; } } } diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index abe28b1666..bc23a6c44b 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -7,7 +7,7 @@ namespace Terminal.Gui; /// /// The is a that by default is centered and contains one -/// or more s. It defaults to the color scheme and has a 1 cell padding around the edges. +/// or more s. It defaults to the color scheme and has a 1 cell padding around the edges. /// /// /// To run the modally, create the , and pass it to . @@ -65,7 +65,7 @@ void SetInitialProperties (Button [] buttons) Width = Dim.Percent (85);// Dim.Auto (min: Dim.Percent (10)); Height = Dim.Percent (85);//Dim.Auto (min: Dim.Percent (50)); - ColorScheme = Colors.Dialog; + ColorScheme = Colors.ColorSchemes ["Dialog"]; Modal = true; ButtonAlignment = DefaultButtonAlignment; diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs index 3fbee15484..c2b0b45337 100644 --- a/Terminal.Gui/Views/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialog.cs @@ -657,7 +657,9 @@ public override void OnLoaded () tbPath.Caption = Style.PathCaption; tbFind.Caption = Style.SearchCaption; - tbPath.Autocomplete.ColorScheme.Normal = new Attribute (Color.Black, tbPath.ColorScheme.Normal.Background); + tbPath.Autocomplete.ColorScheme = new ColorScheme (tbPath.ColorScheme) { + Normal = new Attribute (Color.Black, tbPath.ColorScheme.Normal.Background) + }; _treeRoots = Style.TreeRootGetter (); Style.IconProvider.IsOpenGetter = treeView.IsExpanded; diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs index 321a48a4fd..2b7245cba4 100644 --- a/Terminal.Gui/Views/Menu/MenuBar.cs +++ b/Terminal.Gui/Views/Menu/MenuBar.cs @@ -278,7 +278,7 @@ public MenuBar (MenuBarItem [] menus) : base () //CanFocus = true; _selected = -1; _selectedSub = -1; - ColorScheme = Colors.Menu; + ColorScheme = Colors.ColorSchemes ["Menu"]; WantMousePositionReports = true; IsMenuOpen = false; diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 116b1020fd..4a251ae91a 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -278,9 +278,9 @@ static int QueryFull (bool useErrorColors, int width, int height, string title, } if (useErrorColors) { - d.ColorScheme = Colors.Error; + d.ColorScheme = Colors.ColorSchemes ["Error"]; } else { - d.ColorScheme = Colors.Dialog; + d.ColorScheme = Colors.ColorSchemes ["Dialog"]; } var messageLabel = new Label () { diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index 4fdd0b6c94..1c50202261 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -111,7 +111,7 @@ public StatusBar (StatusItem [] items) : base () Items = items; } CanFocus = false; - ColorScheme = Colors.Menu; + ColorScheme = Colors.ColorSchemes ["Menu"]; X = 0; Y = Pos.AnchorEnd (1); Width = Dim.Fill (); diff --git a/Terminal.Gui/Views/Toplevel.cs b/Terminal.Gui/Views/Toplevel.cs index 2ddd8e80e9..29a80c585b 100644 --- a/Terminal.Gui/Views/Toplevel.cs +++ b/Terminal.Gui/Views/Toplevel.cs @@ -251,7 +251,7 @@ internal virtual void OnUnloaded () void SetInitialProperties () { - ColorScheme = Colors.TopLevel; + ColorScheme = Colors.ColorSchemes ["TopLevel"]; Application.GrabbingMouse += Application_GrabbingMouse; Application.UnGrabbingMouse += Application_UnGrabbingMouse; diff --git a/Terminal.Gui/Views/Window.cs b/Terminal.Gui/Views/Window.cs index 50eaa8e521..5e1e4b87cf 100644 --- a/Terminal.Gui/Views/Window.cs +++ b/Terminal.Gui/Views/Window.cs @@ -34,7 +34,7 @@ public class Window : Toplevel { ///// This property can be set in a Theme to change the default for all s. ///// /////[SerializableConfigurationProperty (Scope = typeof (ThemeScope)), JsonConverter (typeof (JsonStringEnumConverter))] - ////public static ColorScheme DefaultColorScheme { get; set; } = Colors.Base; + ////public static ColorScheme DefaultColorScheme { get; set; } = Colors.ColorSchemes ["Base"]; /// /// The default for 's border. The default is @@ -51,7 +51,7 @@ public class Window : Toplevel { void SetInitialProperties () { CanFocus = true; - ColorScheme = Colors.Base; // TODO: make this a theme property + ColorScheme = Colors.ColorSchemes ["Base"]; // TODO: make this a theme property BorderStyle = DefaultBorderStyle; // This enables the default button to be activated by the Enter key. diff --git a/Terminal.Gui/Views/Wizard/Wizard.cs b/Terminal.Gui/Views/Wizard/Wizard.cs index 722a585c3a..85e00166ee 100644 --- a/Terminal.Gui/Views/Wizard/Wizard.cs +++ b/Terminal.Gui/Views/Wizard/Wizard.cs @@ -512,13 +512,13 @@ void SizeStep (WizardStep step) SizeStep (step); } if (base.Modal) { - ColorScheme = Colors.Dialog; + ColorScheme = Colors.ColorSchemes ["Dialog"]; BorderStyle = LineStyle.Rounded; } else { if (SuperView != null) { ColorScheme = SuperView.ColorScheme; } else { - ColorScheme = Colors.Base; + ColorScheme = Colors.ColorSchemes ["Base"]; } CanFocus = true; BorderStyle = LineStyle.None; diff --git a/Terminal.sln b/Terminal.sln index fcc42be940..8f06e5fd6c 100644 --- a/Terminal.sln +++ b/Terminal.sln @@ -26,7 +26,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution nuget.config = nuget.config .github\workflows\publish.yml = .github\workflows\publish.yml README.md = README.md - Terminal.Gui\.vscode\settings.json = Terminal.Gui\.vscode\settings.json Terminal.sln.DotSettings = Terminal.sln.DotSettings testenvironments.json = testenvironments.json EndProjectSection diff --git a/UICatalog/Scenarios/Adornments.cs b/UICatalog/Scenarios/Adornments.cs index 925a7578ba..f6424932c7 100644 --- a/UICatalog/Scenarios/Adornments.cs +++ b/UICatalog/Scenarios/Adornments.cs @@ -77,9 +77,9 @@ public override void Init () editor.Initialized += (s, e) => { editor.ViewToEdit = view; }; - //view.Margin.ColorScheme = new ColorScheme (Colors.Dialog); - //view.Border.ColorScheme = new ColorScheme (Colors.Error); - //view.Padding.ColorScheme = new ColorScheme (Colors.Menu); + //view.Margin.ColorScheme = new ColorScheme (Colors.ColorSchemes ["Dialog"]); + //view.Border.ColorScheme = new ColorScheme (Colors.ColorSchemes ["Error"]); + //view.Padding.ColorScheme = new ColorScheme (Colors.ColorSchemes ["Menu"]); Application.Run (editor); Application.Shutdown (); diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index b9e9ad3918..eb4b15c0e8 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -72,7 +72,7 @@ public override void Setup () Width = 15, Height = Dim.Fill (1), // for status bar CanFocus = false, - ColorScheme = Colors.TopLevel + ColorScheme = Colors.ColorSchemes ["TopLevel"] }; _classListView = new ListView (_viewClasses.Keys.ToList ()) { @@ -81,7 +81,7 @@ public override void Setup () Width = Dim.Fill (0), Height = Dim.Fill (0), AllowsMarking = false, - ColorScheme = Colors.TopLevel, + ColorScheme = Colors.ColorSchemes ["TopLevel"], SelectedItem = 0 }; _classListView.OpenSelectedItem += (s, a) => { @@ -106,7 +106,7 @@ public override void Setup () Width = Dim.Fill (), Height = 10, CanFocus = false, - ColorScheme = Colors.TopLevel + ColorScheme = Colors.ColorSchemes ["TopLevel"] }; _computedCheckBox = new CheckBox ("Computed Layout", true) { X = 0, Y = 0 }; _computedCheckBox.Toggled += (s, e) => { @@ -228,7 +228,7 @@ public override void Setup () Y = Pos.Bottom (_settingsPane), Width = Dim.Fill (), Height = Dim.Fill (1), // + 1 for status bar - ColorScheme = Colors.Dialog + ColorScheme = Colors.ColorSchemes ["Dialog"] }; Application.Top.Add (_leftPane, _settingsPane, _hostPane); @@ -340,7 +340,7 @@ View CreateClass (Type type) // Set the colorscheme to make it stand out if is null by default if (view.ColorScheme == null) { - view.ColorScheme = Colors.Base; + view.ColorScheme = Colors.ColorSchemes ["Base"]; } // If the view supports a Text property, set it so we have something to look at diff --git a/UICatalog/Scenarios/AutoSizeAndDirectionText.cs b/UICatalog/Scenarios/AutoSizeAndDirectionText.cs index 09e66570f2..7ef5c039dd 100644 --- a/UICatalog/Scenarios/AutoSizeAndDirectionText.cs +++ b/UICatalog/Scenarios/AutoSizeAndDirectionText.cs @@ -8,7 +8,7 @@ public override void Setup () { var text = "Hello World"; var wideText = "Hello World 你"; - var color = Colors.Dialog; + var color = Colors.ColorSchemes ["Dialog"]; var labelH = new Label (text, TextDirection.LeftRight_TopBottom) { X = 1, diff --git a/UICatalog/Scenarios/BackgroundWorkerCollection.cs b/UICatalog/Scenarios/BackgroundWorkerCollection.cs index e2165e4ce7..63e635e3e2 100644 --- a/UICatalog/Scenarios/BackgroundWorkerCollection.cs +++ b/UICatalog/Scenarios/BackgroundWorkerCollection.cs @@ -169,7 +169,7 @@ public WorkerApp () Width = Dim.Percent (80); Height = Dim.Percent (50); - ColorScheme = Colors.Base; + ColorScheme = Colors.ColorSchemes ["Base"]; var label = new Label ("Worker collection Log") { X = Pos.Center (), @@ -308,14 +308,14 @@ public StagingUIController () Width = Dim.Percent (85); Height = Dim.Percent (85); - ColorScheme = Colors.Dialog; + ColorScheme = Colors.ColorSchemes ["Dialog"]; Title = "Run Worker"; label = new Label ("Press start to do the work or close to quit.") { X = Pos.Center (), Y = 1, - ColorScheme = Colors.Dialog + ColorScheme = Colors.ColorSchemes ["Dialog"] }; Add (label); diff --git a/UICatalog/Scenarios/BasicColors.cs b/UICatalog/Scenarios/BasicColors.cs index e99c88db32..e0de4019e0 100644 --- a/UICatalog/Scenarios/BasicColors.cs +++ b/UICatalog/Scenarios/BasicColors.cs @@ -91,9 +91,10 @@ public override void Setup () var fore = e.MouseEvent.View.GetNormalColor ().Foreground; var back = e.MouseEvent.View.GetNormalColor ().Background; lblForeground.Text = $"#{fore.R:X2}{fore.G:X2}{fore.B:X2} {fore.ColorName} "; - viewForeground.ColorScheme.Normal = new Attribute (fore, fore); + viewForeground.ColorScheme = new ColorScheme (viewForeground.ColorScheme) { Normal = new Attribute (fore, fore) }; + lblBackground.Text = $"#{back.R:X2}{back.G:X2}{back.B:X2} {back.ColorName} "; - viewBackground.ColorScheme.Normal = new Attribute (back, back); + viewBackground.ColorScheme = new ColorScheme (viewBackground.ColorScheme) { Normal = new Attribute (back, back) }; } }; } diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index 41bc328a44..6966cd8579 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -99,7 +99,7 @@ static void DoMessage (Button button, string txt) var removeButton = new Button ("Remove this button") { X = 2, Y = Pos.Bottom (button) + 1, - ColorScheme = Colors.Error + ColorScheme = Colors.ColorSchemes ["Error"] }; Win.Add (removeButton); // This in interesting test case because `moveBtn` and below are laid out relative to this one! @@ -123,7 +123,7 @@ static void DoMessage (Button button, string txt) X = 0, Y = Pos.Center () - 1, Width = 30, - ColorScheme = Colors.Error, + ColorScheme = Colors.ColorSchemes ["Error"], }; moveBtn.Clicked += (s, e) => { moveBtn.X = moveBtn.Frame.X + 5; @@ -137,7 +137,7 @@ static void DoMessage (Button button, string txt) X = 0, Y = Pos.Center () + 1, Width = 30, - ColorScheme = Colors.Error, + ColorScheme = Colors.ColorSchemes ["Error"], }; sizeBtn.Clicked += (s, e) => { sizeBtn.Width = sizeBtn.Frame.Width + 5; @@ -155,7 +155,7 @@ static void DoMessage (Button button, string txt) // Demonstrates how changing the View.Frame property can move Views var moveBtnA = new Button (0, 0, "Move This Button via Frame") { - ColorScheme = Colors.Error, + ColorScheme = Colors.ColorSchemes ["Error"], }; moveBtnA.Clicked += (s, e) => { moveBtnA.Frame = new Rect (moveBtnA.Frame.X + 5, moveBtnA.Frame.Y, moveBtnA.Frame.Width, moveBtnA.Frame.Height); @@ -164,7 +164,7 @@ static void DoMessage (Button button, string txt) // Demonstrates how changing the View.Frame property can SIZE Views (#583) var sizeBtnA = new Button (0, 2, " ~  s  gui.cs   master ↑10 = Со_хранить") { - ColorScheme = Colors.Error, + ColorScheme = Colors.ColorSchemes ["Error"], }; sizeBtnA.Clicked += (s, e) => { sizeBtnA.Frame = new Rect (sizeBtnA.Frame.X, sizeBtnA.Frame.Y, sizeBtnA.Frame.Width + 5, sizeBtnA.Frame.Height); @@ -215,7 +215,7 @@ string MoveHotkey (string txt) X = 2, Y = Pos.Bottom (radioGroup) + 1, Width = Dim.Width (computedFrame) - 2, - ColorScheme = Colors.TopLevel, + ColorScheme = Colors.ColorSchemes ["TopLevel"], }; moveHotKeyBtn.Clicked += (s, e) => { moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text); @@ -227,7 +227,7 @@ string MoveHotkey (string txt) X = Pos.Left (absoluteFrame) + 1, Y = Pos.Bottom (radioGroup) + 1, Width = Dim.Width (absoluteFrame) - 2, // BUGBUG: Not always the width isn't calculated correctly. - ColorScheme = Colors.TopLevel, + ColorScheme = Colors.ColorSchemes ["TopLevel"], }; moveUnicodeHotKeyBtn.Clicked += (s, e) => { moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text); diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index de4204b7e7..fa52ce9d26 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -36,7 +36,7 @@ public class CharacterMap : Scenario { public override void Init () { Application.Init (); - Application.Top.ColorScheme = Colors.Base; + Application.Top.ColorScheme = Colors.ColorSchemes ["Base"]; } public override void Setup () @@ -330,7 +330,7 @@ public bool ShowGlyphWidths { public CharMap () { - ColorScheme = Colors.Dialog; + ColorScheme = Colors.ColorSchemes ["Dialog"]; CanFocus = true; ContentSize = new Size (RowWidth, (int)((MaxCodePoint / 16 + (ShowHorizontalScrollIndicator ? 2 : 1)) * _rowHeight)); diff --git a/UICatalog/Scenarios/Clipping.cs b/UICatalog/Scenarios/Clipping.cs index 0d9d8e5262..36d815f61f 100644 --- a/UICatalog/Scenarios/Clipping.cs +++ b/UICatalog/Scenarios/Clipping.cs @@ -10,7 +10,7 @@ public class Clipping : Scenario { public override void Init () { Application.Init (); - Application.Top.ColorScheme = Colors.Base; + Application.Top.ColorScheme = Colors.ColorSchemes ["Base"]; } public override void Setup () @@ -21,12 +21,12 @@ public override void Setup () //Win.Height = Dim.Fill () - 2; var label = new Label ("ScrollView (new Rect (3, 3, 50, 20)) with a 200, 100 ContentSize...") { X = 0, Y = 0, - //ColorScheme = Colors.Dialog + //ColorScheme = Colors.ColorSchemes ["Dialog"] }; Application.Top.Add (label); var scrollView = new ScrollView (new Rect (3, 3, 50, 20)); - scrollView.ColorScheme = Colors.Menu; + scrollView.ColorScheme = Colors.ColorSchemes ["Menu"]; scrollView.ContentSize = new Size (200, 100); //ContentOffset = new Point (0, 0), //scrollView.ShowVerticalScrollIndicator = true; @@ -38,7 +38,7 @@ public override void Setup () Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), - ColorScheme = Colors.Dialog, + ColorScheme = Colors.ColorSchemes ["Dialog"], Id = "1" }; @@ -48,7 +48,7 @@ public override void Setup () Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), - ColorScheme = Colors.Error, + ColorScheme = Colors.ColorSchemes ["Error"], Id = "2" }; embedded1.Add (embedded2); @@ -59,7 +59,7 @@ public override void Setup () Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3), - ColorScheme = Colors.TopLevel, + ColorScheme = Colors.ColorSchemes ["TopLevel"], Id = "3" }; diff --git a/UICatalog/Scenarios/CollectionNavigatorTester.cs b/UICatalog/Scenarios/CollectionNavigatorTester.cs index ce1a8444f7..207093a2b6 100644 --- a/UICatalog/Scenarios/CollectionNavigatorTester.cs +++ b/UICatalog/Scenarios/CollectionNavigatorTester.cs @@ -16,7 +16,7 @@ public class CollectionNavigatorTester : Scenario { public override void Init () { Application.Init (); - Application.Top.ColorScheme = Colors.Base; + Application.Top.ColorScheme = Colors.ColorSchemes ["Base"]; } System.Collections.Generic.List _items = new string [] { diff --git a/UICatalog/Scenarios/ComboBoxIteration.cs b/UICatalog/Scenarios/ComboBoxIteration.cs index d3062763bf..3158fe83d7 100644 --- a/UICatalog/Scenarios/ComboBoxIteration.cs +++ b/UICatalog/Scenarios/ComboBoxIteration.cs @@ -24,7 +24,7 @@ public override void Setup () Win.Add (listview); var lbComboBox = new Label () { - ColorScheme = Colors.TopLevel, + ColorScheme = Colors.ColorSchemes ["TopLevel"], X = Pos.Right (lbListView) + 1, Width = Dim.Percent (40) }; diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index c1f24a17c8..c135be4397 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -33,7 +33,7 @@ public override void Setup () Y = 0, Width = Dim.Fill (), Height = 1, - ColorScheme = Colors.Error + ColorScheme = Colors.ColorSchemes ["Error"] }; Application.Top.Add (horizontalRuler); @@ -47,7 +47,7 @@ public override void Setup () Y = 0, Width = 1, Height = Dim.Fill (), - ColorScheme = Colors.Error + ColorScheme = Colors.ColorSchemes ["Error"] }; Application.Top.LayoutComplete += (s, a) => { @@ -88,10 +88,10 @@ public override void Setup () string txt = "Resize the terminal to see computed layout in action."; var labelList = new List