From 36d19c67257634a4d86c7a948af4d1e5fb756d47 Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Sun, 15 Jan 2023 18:56:30 -0700 Subject: [PATCH] Removed ColorScheme.SetAttribute --- Terminal.Gui/Core/ConsoleDriver.cs | 136 ++--------------------------- 1 file changed, 5 insertions(+), 131 deletions(-) diff --git a/Terminal.Gui/Core/ConsoleDriver.cs b/Terminal.Gui/Core/ConsoleDriver.cs index 300191b150..42d32ebfa2 100644 --- a/Terminal.Gui/Core/ConsoleDriver.cs +++ b/Terminal.Gui/Core/ConsoleDriver.cs @@ -212,153 +212,27 @@ public class ColorScheme : IEquatable { /// /// The default color for text, when the view is not focused. /// - public Attribute Normal { get { return _normal; } set { _normal = SetAttribute (value); } } + public Attribute Normal { get { return _normal; } set { _normal = value; } } /// /// The color for text when the view has the focus. /// - public Attribute Focus { get { return _focus; } set { _focus = SetAttribute (value); } } + public Attribute Focus { get { return _focus; } set { _focus = value; } } /// /// The color for the hotkey when a view is not focused /// - public Attribute HotNormal { get { return _hotNormal; } set { _hotNormal = SetAttribute (value); } } + public Attribute HotNormal { get { return _hotNormal; } set { _hotNormal = value; } } /// /// The color for the hotkey when the view is focused. /// - public Attribute HotFocus { get { return _hotFocus; } set { _hotFocus = SetAttribute (value); } } + public Attribute HotFocus { get { return _hotFocus; } set { _hotFocus = value; } } /// /// The default color for text, when the view is disabled. /// - public Attribute Disabled { get { return _disabled; } set { _disabled = SetAttribute (value); } } - - bool preparingScheme = false; - - Attribute SetAttribute (Attribute attribute, [CallerMemberName] string callerMemberName = null) - { - if (!Application._initialized && !preparingScheme) - return attribute; - - if (preparingScheme) - return attribute; - - preparingScheme = true; - switch (caller) { - case "TopLevel": - switch (callerMemberName) { - case "Normal": - HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background); - break; - case "Focus": - HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background); - break; - case "HotNormal": - HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background); - break; - case "HotFocus": - HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background); - if (Focus.Foreground != attribute.Background) - Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background); - break; - } - break; - - case "Base": - switch (callerMemberName) { - case "Normal": - HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background); - break; - case "Focus": - HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background); - break; - case "HotNormal": - HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background); - Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background); - break; - case "HotFocus": - HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background); - if (Focus.Foreground != attribute.Background) - Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background); - break; - } - break; - - case "Menu": - switch (callerMemberName) { - case "Normal": - if (Focus.Background != attribute.Background) - Focus = Application.Driver.MakeAttribute (attribute.Foreground, Focus.Background); - HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background); - Disabled = Application.Driver.MakeAttribute (Disabled.Foreground, attribute.Background); - break; - case "Focus": - Normal = Application.Driver.MakeAttribute (attribute.Foreground, Normal.Background); - HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background); - break; - case "HotNormal": - if (Focus.Background != attribute.Background) - HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background); - Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background); - Disabled = Application.Driver.MakeAttribute (Disabled.Foreground, attribute.Background); - break; - case "HotFocus": - HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background); - if (Focus.Foreground != attribute.Background) - Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background); - break; - case "Disabled": - if (Focus.Background != attribute.Background) - HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background); - Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background); - HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background); - break; - } - break; - - case "Dialog": - switch (callerMemberName) { - case "Normal": - if (Focus.Background != attribute.Background) - Focus = Application.Driver.MakeAttribute (attribute.Foreground, Focus.Background); - HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background); - break; - case "Focus": - Normal = Application.Driver.MakeAttribute (attribute.Foreground, Normal.Background); - HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background); - break; - case "HotNormal": - if (Focus.Background != attribute.Background) - HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, HotFocus.Background); - if (Normal.Foreground != attribute.Background) - Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background); - break; - case "HotFocus": - HotNormal = Application.Driver.MakeAttribute (attribute.Foreground, HotNormal.Background); - if (Focus.Foreground != attribute.Background) - Focus = Application.Driver.MakeAttribute (Focus.Foreground, attribute.Background); - break; - } - break; - - case "Error": - switch (callerMemberName) { - case "Normal": - HotNormal = Application.Driver.MakeAttribute (HotNormal.Foreground, attribute.Background); - HotFocus = Application.Driver.MakeAttribute (HotFocus.Foreground, attribute.Background); - break; - case "HotNormal": - case "HotFocus": - HotFocus = Application.Driver.MakeAttribute (attribute.Foreground, attribute.Background); - Normal = Application.Driver.MakeAttribute (Normal.Foreground, attribute.Background); - break; - } - break; - } - preparingScheme = false; - return attribute; - } + public Attribute Disabled { get { return _disabled; } set { _disabled = value; } } /// /// Compares two objects for equality.