#nullable enable - Attribute.cs

This commit is contained in:
Tig
2024-11-04 10:31:37 -07:00
parent 7656602245
commit 66485a063e

View File

@@ -1,5 +1,4 @@
using System;
#nullable enable
namespace Terminal.Gui;
public partial class View
@@ -8,11 +7,11 @@ public partial class View
// TODO: See https://github.com/gui-cs/Terminal.Gui/issues/457
#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>
public virtual ColorScheme ColorScheme
public virtual ColorScheme? ColorScheme
{
get
{
@@ -29,6 +28,7 @@ public partial class View
{
_colorScheme = value;
// BUGBUG: This should be in Border.cs somehow
if (Border is { } && Border.LineStyle != LineStyle.None && Border.ColorScheme is { })
{
Border.ColorScheme = _colorScheme;
@@ -47,7 +47,7 @@ public partial class View
/// </returns>
public virtual Attribute GetFocusColor ()
{
ColorScheme cs = ColorScheme;
ColorScheme? cs = ColorScheme;
if (cs is null)
{
@@ -65,20 +65,20 @@ public partial class View
/// </returns>
public virtual Attribute GetHotFocusColor ()
{
ColorScheme cs = ColorScheme ?? new ();
ColorScheme? cs = ColorScheme ?? new ();
return Enabled ? GetColor (cs.HotFocus) : cs.Disabled;
}
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
/// <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.
/// </returns>
public virtual Attribute GetHotNormalColor ()
{
ColorScheme cs = ColorScheme;
ColorScheme? cs = ColorScheme;
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>
/// <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.
/// </returns>
public virtual Attribute GetNormalColor ()
{
ColorScheme cs = ColorScheme;
ColorScheme? cs = ColorScheme;
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>
/// <remarks></remarks>
/// <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>
/// <returns>The current attribute.</returns>
public Attribute GetAttribute ()
{
return Driver?.GetAttribute () ?? Attribute.Default;
}
public Attribute GetAttribute () { return Driver?.GetAttribute () ?? Attribute.Default; }
#endregion Attribute
}