diff --git a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
index bea8cb0c7..b2a250fe2 100644
--- a/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
+++ b/Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs
@@ -390,7 +390,8 @@ public abstract class ConsoleDriver {
public Attribute CurrentAttribute {
get => _currentAttribute;
set {
- if (value is { Initialized: false, HasValidColors: true } && Application.Driver != null) {
+ //if (value is { Initialized: false, HasValidColors: true } && Application.Driver != null) {
+ if (value is { Initialized: false } && Application.Driver != null) {
_currentAttribute = new Attribute (value.Foreground, value.Background);
return;
}
diff --git a/Terminal.Gui/Drawing/Color.cs b/Terminal.Gui/Drawing/Color.cs
index a05d945ce..8bdb46ae7 100644
--- a/Terminal.Gui/Drawing/Color.cs
+++ b/Terminal.Gui/Drawing/Color.cs
@@ -744,12 +744,13 @@ namespace Terminal.Gui {
[JsonIgnore]
public bool Initialized { get; internal set; }
- ///
- /// Returns if the Attribute is valid (both foreground and background have valid color values).
- ///
- ///
- [JsonIgnore]
- public bool HasValidColors => (int)Foreground.ColorName > -1 && (int)Background.ColorName > -1;
+ //// TODO: This no longer makes sense - remove it
+ /////
+ ///// Returns if the Attribute is valid (both foreground and background have valid color values).
+ /////
+ /////
+ //[JsonIgnore]
+ //public bool HasValidColors => (int)Foreground.ColorName > -1 && (int)Background.ColorName > -1;
///
public override string ToString ()
@@ -820,9 +821,9 @@ namespace Terminal.Gui {
public Attribute Normal {
get { return _normal; }
set {
- if (!value.HasValidColors) {
- return;
- }
+ //if (!value.HasValidColors) {
+ // return;
+ //}
_normal = value;
}
}
@@ -833,9 +834,9 @@ namespace Terminal.Gui {
public Attribute Focus {
get { return _focus; }
set {
- if (!value.HasValidColors) {
- return;
- }
+ //if (!value.HasValidColors) {
+ // return;
+ //}
_focus = value;
}
}
@@ -846,9 +847,9 @@ namespace Terminal.Gui {
public Attribute HotNormal {
get { return _hotNormal; }
set {
- if (!value.HasValidColors) {
- return;
- }
+ //if (!value.HasValidColors) {
+ // return;
+ //}
_hotNormal = value;
}
}
@@ -859,9 +860,9 @@ namespace Terminal.Gui {
public Attribute HotFocus {
get { return _hotFocus; }
set {
- if (!value.HasValidColors) {
- return;
- }
+ //if (!value.HasValidColors) {
+ // return;
+ //}
_hotFocus = value;
}
}
@@ -872,9 +873,9 @@ namespace Terminal.Gui {
public Attribute Disabled {
get { return _disabled; }
set {
- if (!value.HasValidColors) {
- return;
- }
+ //if (!value.HasValidColors) {
+ // return;
+ //}
_disabled = value;
}
}
diff --git a/Terminal.Gui/Drawing/LineCanvas.cs b/Terminal.Gui/Drawing/LineCanvas.cs
index b3171f77f..ca20b21eb 100644
--- a/Terminal.Gui/Drawing/LineCanvas.cs
+++ b/Terminal.Gui/Drawing/LineCanvas.cs
@@ -545,17 +545,7 @@ namespace Terminal.Gui {
}
}
- private Attribute? GetAttributeForIntersects (IntersectionDefinition? [] intersects)
- {
- var set = new List (intersects.Where (i => i!.Line.Attribute?.HasValidColors ?? false));
-
- if (set.Count == 0) {
- return null;
- }
-
- return set [0]!.Line.Attribute;
-
- }
+ private Attribute? GetAttributeForIntersects (IntersectionDefinition? [] intersects) =>intersects [0]!.Line.Attribute;
private Cell? GetCellForIntersects (ConsoleDriver driver, IntersectionDefinition? [] intersects)
{
diff --git a/UnitTests/Drawing/AttributeTests.cs b/UnitTests/Drawing/AttributeTests.cs
index 51f46e150..df547f97d 100644
--- a/UnitTests/Drawing/AttributeTests.cs
+++ b/UnitTests/Drawing/AttributeTests.cs
@@ -110,19 +110,19 @@ public class AttributeTests {
attr = new Attribute (fg, bg);
Assert.True (attr.Initialized);
- Assert.True (attr.HasValidColors);
+ //Assert.True (attr.HasValidColors);
Assert.Equal (fg, attr.Foreground);
Assert.Equal (bg, attr.Background);
attr = new Attribute (fg);
Assert.True (attr.Initialized);
- Assert.True (attr.HasValidColors);
+ //Assert.True (attr.HasValidColors);
Assert.Equal (fg, attr.Foreground);
Assert.Equal (fg, attr.Background);
attr = new Attribute (bg);
Assert.True (attr.Initialized);
- Assert.True (attr.HasValidColors);
+ //Assert.True (attr.HasValidColors);
Assert.Equal (bg, attr.Foreground);
Assert.Equal (bg, attr.Background);
@@ -271,40 +271,6 @@ public class AttributeTests {
Assert.Equal (bg, attr.Background);
}
- [Fact]
- public void Get_Asserts_NoDriver ()
- {
- Assert.Throws (() => Attribute.Get ());
- }
-
- [Fact]
- public void Get_Gets ()
- {
- var driver = new FakeDriver ();
- Application.Init (driver);
- driver.Init (() => { });
-
- var value = 42;
- var fg = new Color ();
- fg = (Color)Color.Red;
-
- var bg = new Color ();
- bg = (Color)Color.Blue;
-
- var attr = new Attribute (value, fg, bg);
-
- driver.SetAttribute (attr);
-
- var ret_attr = Attribute.Get ();
-
- Assert.Equal (value, ret_attr.Value);
- Assert.Equal (fg, ret_attr.Foreground);
- Assert.Equal (bg, ret_attr.Background);
-
- driver.End ();
- Application.Shutdown ();
- }
-
[Fact]
[AutoInitShutdown]
public void GetColors_Based_On_Value ()
@@ -321,10 +287,10 @@ public class AttributeTests {
public void IsValid_Tests ()
{
var attr = new Attribute ();
- Assert.True (attr.HasValidColors);
+ //Assert.True (attr.HasValidColors);
attr = new Attribute (Color.Red, Color.Green);
- Assert.True (attr.HasValidColors);
+ //Assert.True (attr.HasValidColors);
//attr = new Attribute (Color.Red, (Color)(-1));
//Assert.False (attr.HasValidColors);