Skip to content

Commit

Permalink
Merge pull request gui-cs#3346 from tznind/color-scheme-ctor
Browse files Browse the repository at this point in the history
Fixes gui-cs#3345 - Add full constructor to ColorScheme
  • Loading branch information
tig authored Mar 29, 2024
2 parents 6070e80 + b5747cc commit ab1c89b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Terminal.Gui/Drawing/ColorScheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ public ColorScheme (Attribute attribute)
_hotFocus = attribute;
}

/// <summary>Creates a new instance, initialized with the values provided.</summary>
public ColorScheme (
Attribute normal,
Attribute focus,
Attribute hotNormal,
Attribute disabled,
Attribute hotFocus)
{
_normal = normal;
_focus = focus;
_hotNormal = hotNormal;
_disabled = disabled;
_hotFocus = hotFocus;
}

/// <summary>The default foreground and background color for text when the view is disabled.</summary>
public Attribute Disabled
{
Expand Down
23 changes: 23 additions & 0 deletions UnitTests/Drawing/ColorSchemeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,27 @@ public void ColorScheme_New ()
lbl.ColorScheme = scheme;
lbl.Draw ();
}

[Fact]
public void ColorScheme_BigConstructor ()
{
var a = new Attribute (1);
var b = new Attribute (2);
var c = new Attribute (3);
var d = new Attribute (4);
var e = new Attribute (5);

var cs = new ColorScheme (
normal: a,
focus: b,
hotNormal: c,
disabled: d,
hotFocus: e);

Assert.Equal (a, cs.Normal);
Assert.Equal (b, cs.Focus);
Assert.Equal (c, cs.HotNormal);
Assert.Equal (d, cs.Disabled);
Assert.Equal (e, cs.HotFocus);
}
}

0 comments on commit ab1c89b

Please sign in to comment.