|
@@ -1,5 +1,4 @@
|
|
-using System;
|
|
|
|
-
|
|
|
|
|
|
+#nullable enable
|
|
namespace Terminal.Gui;
|
|
namespace Terminal.Gui;
|
|
|
|
|
|
public partial class View
|
|
public partial class View
|
|
@@ -8,11 +7,11 @@ public partial class View
|
|
// TODO: See https://github.com/gui-cs/Terminal.Gui/issues/457
|
|
// TODO: See https://github.com/gui-cs/Terminal.Gui/issues/457
|
|
|
|
|
|
#region ColorScheme
|
|
#region ColorScheme
|
|
-
|
|
|
|
- private ColorScheme _colorScheme;
|
|
|
|
|
|
+
|
|
|
|
+ private ColorScheme? _colorScheme;
|
|
|
|
|
|
/// <summary>The color scheme for this view, if it is not defined, it returns the <see cref="SuperView"/>'s color scheme.</summary>
|
|
/// <summary>The color scheme for this view, if it is not defined, it returns the <see cref="SuperView"/>'s color scheme.</summary>
|
|
- public virtual ColorScheme ColorScheme
|
|
|
|
|
|
+ public virtual ColorScheme? ColorScheme
|
|
{
|
|
{
|
|
get
|
|
get
|
|
{
|
|
{
|
|
@@ -29,6 +28,7 @@ public partial class View
|
|
{
|
|
{
|
|
_colorScheme = value;
|
|
_colorScheme = value;
|
|
|
|
|
|
|
|
+ // BUGBUG: This should be in Border.cs somehow
|
|
if (Border is { } && Border.LineStyle != LineStyle.None && Border.ColorScheme is { })
|
|
if (Border is { } && Border.LineStyle != LineStyle.None && Border.ColorScheme is { })
|
|
{
|
|
{
|
|
Border.ColorScheme = _colorScheme;
|
|
Border.ColorScheme = _colorScheme;
|
|
@@ -47,7 +47,7 @@ public partial class View
|
|
/// </returns>
|
|
/// </returns>
|
|
public virtual Attribute GetFocusColor ()
|
|
public virtual Attribute GetFocusColor ()
|
|
{
|
|
{
|
|
- ColorScheme cs = ColorScheme;
|
|
|
|
|
|
+ ColorScheme? cs = ColorScheme;
|
|
|
|
|
|
if (cs is null)
|
|
if (cs is null)
|
|
{
|
|
{
|
|
@@ -65,20 +65,20 @@ public partial class View
|
|
/// </returns>
|
|
/// </returns>
|
|
public virtual Attribute GetHotFocusColor ()
|
|
public virtual Attribute GetHotFocusColor ()
|
|
{
|
|
{
|
|
- ColorScheme cs = ColorScheme ?? new ();
|
|
|
|
|
|
+ ColorScheme? cs = ColorScheme ?? new ();
|
|
|
|
|
|
return Enabled ? GetColor (cs.HotFocus) : cs.Disabled;
|
|
return Enabled ? GetColor (cs.HotFocus) : cs.Disabled;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
|
|
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
|
|
/// <returns>
|
|
/// <returns>
|
|
- /// <see cref="Terminal.Gui.ColorScheme.HotNormal"/> if <see cref="Enabled"/> is <see langword="true"/> or
|
|
|
|
- /// <see cref="Terminal.Gui.ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
|
|
|
|
|
|
+ /// <see cref="ColorScheme.HotNormal"/> if <see cref="Enabled"/> is <see langword="true"/> or
|
|
|
|
+ /// <see cref="ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
|
|
/// overridden can return other values.
|
|
/// overridden can return other values.
|
|
/// </returns>
|
|
/// </returns>
|
|
public virtual Attribute GetHotNormalColor ()
|
|
public virtual Attribute GetHotNormalColor ()
|
|
{
|
|
{
|
|
- ColorScheme cs = ColorScheme;
|
|
|
|
|
|
+ ColorScheme? cs = ColorScheme;
|
|
|
|
|
|
if (cs is null)
|
|
if (cs is null)
|
|
{
|
|
{
|
|
@@ -90,13 +90,13 @@ public partial class View
|
|
|
|
|
|
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
|
|
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
|
|
/// <returns>
|
|
/// <returns>
|
|
- /// <see cref="Terminal.Gui.ColorScheme.Normal"/> if <see cref="Enabled"/> is <see langword="true"/> or
|
|
|
|
- /// <see cref="Terminal.Gui.ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
|
|
|
|
|
|
+ /// <see cref="ColorScheme.Normal"/> if <see cref="Enabled"/> is <see langword="true"/> or
|
|
|
|
+ /// <see cref="ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
|
|
/// overridden can return other values.
|
|
/// overridden can return other values.
|
|
/// </returns>
|
|
/// </returns>
|
|
public virtual Attribute GetNormalColor ()
|
|
public virtual Attribute GetNormalColor ()
|
|
{
|
|
{
|
|
- ColorScheme cs = ColorScheme;
|
|
|
|
|
|
+ ColorScheme? cs = ColorScheme;
|
|
|
|
|
|
if (cs is null)
|
|
if (cs is null)
|
|
{
|
|
{
|
|
@@ -132,16 +132,11 @@ public partial class View
|
|
/// <summary>Selects the specified attribute as the attribute to use for future calls to AddRune and AddString.</summary>
|
|
/// <summary>Selects the specified attribute as the attribute to use for future calls to AddRune and AddString.</summary>
|
|
/// <remarks></remarks>
|
|
/// <remarks></remarks>
|
|
/// <param name="attribute">THe Attribute to set.</param>
|
|
/// <param name="attribute">THe Attribute to set.</param>
|
|
- public Attribute SetAttribute (Attribute attribute)
|
|
|
|
- {
|
|
|
|
- return Driver?.SetAttribute (attribute) ?? Attribute.Default;
|
|
|
|
- }
|
|
|
|
|
|
+ public Attribute SetAttribute (Attribute attribute) { return Driver?.SetAttribute (attribute) ?? Attribute.Default; }
|
|
|
|
|
|
/// <summary>Gets the current <see cref="Attribute"/>.</summary>
|
|
/// <summary>Gets the current <see cref="Attribute"/>.</summary>
|
|
/// <returns>The current attribute.</returns>
|
|
/// <returns>The current attribute.</returns>
|
|
- public Attribute GetAttribute ()
|
|
|
|
- {
|
|
|
|
- return Driver?.GetAttribute () ?? Attribute.Default;
|
|
|
|
- }
|
|
|
|
|
|
+ public Attribute GetAttribute () { return Driver?.GetAttribute () ?? Attribute.Default; }
|
|
|
|
+
|
|
#endregion Attribute
|
|
#endregion Attribute
|
|
}
|
|
}
|