Skip to content

Commit 66485a0

Browse files
committed
#nullable enable - Attribute.cs
1 parent 7656602 commit 66485a0

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

Terminal.Gui/View/View.Attribute.cs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
1+
#nullable enable
32
namespace Terminal.Gui;
43

54
public partial class View
@@ -8,11 +7,11 @@ public partial class View
87
// TODO: See https://github.com/gui-cs/Terminal.Gui/issues/457
98

109
#region ColorScheme
11-
12-
private ColorScheme _colorScheme;
10+
11+
private ColorScheme? _colorScheme;
1312

1413
/// <summary>The color scheme for this view, if it is not defined, it returns the <see cref="SuperView"/>'s color scheme.</summary>
15-
public virtual ColorScheme ColorScheme
14+
public virtual ColorScheme? ColorScheme
1615
{
1716
get
1817
{
@@ -29,6 +28,7 @@ public virtual ColorScheme ColorScheme
2928
{
3029
_colorScheme = value;
3130

31+
// BUGBUG: This should be in Border.cs somehow
3232
if (Border is { } && Border.LineStyle != LineStyle.None && Border.ColorScheme is { })
3333
{
3434
Border.ColorScheme = _colorScheme;
@@ -47,7 +47,7 @@ public virtual ColorScheme ColorScheme
4747
/// </returns>
4848
public virtual Attribute GetFocusColor ()
4949
{
50-
ColorScheme cs = ColorScheme;
50+
ColorScheme? cs = ColorScheme;
5151

5252
if (cs is null)
5353
{
@@ -65,20 +65,20 @@ public virtual Attribute GetFocusColor ()
6565
/// </returns>
6666
public virtual Attribute GetHotFocusColor ()
6767
{
68-
ColorScheme cs = ColorScheme ?? new ();
68+
ColorScheme? cs = ColorScheme ?? new ();
6969

7070
return Enabled ? GetColor (cs.HotFocus) : cs.Disabled;
7171
}
7272

7373
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
7474
/// <returns>
75-
/// <see cref="Terminal.Gui.ColorScheme.HotNormal"/> if <see cref="Enabled"/> is <see langword="true"/> or
76-
/// <see cref="Terminal.Gui.ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
75+
/// <see cref="ColorScheme.HotNormal"/> if <see cref="Enabled"/> is <see langword="true"/> or
76+
/// <see cref="ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
7777
/// overridden can return other values.
7878
/// </returns>
7979
public virtual Attribute GetHotNormalColor ()
8080
{
81-
ColorScheme cs = ColorScheme;
81+
ColorScheme? cs = ColorScheme;
8282

8383
if (cs is null)
8484
{
@@ -90,13 +90,13 @@ public virtual Attribute GetHotNormalColor ()
9090

9191
/// <summary>Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.</summary>
9292
/// <returns>
93-
/// <see cref="Terminal.Gui.ColorScheme.Normal"/> if <see cref="Enabled"/> is <see langword="true"/> or
94-
/// <see cref="Terminal.Gui.ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
93+
/// <see cref="ColorScheme.Normal"/> if <see cref="Enabled"/> is <see langword="true"/> or
94+
/// <see cref="ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>. If it's
9595
/// overridden can return other values.
9696
/// </returns>
9797
public virtual Attribute GetNormalColor ()
9898
{
99-
ColorScheme cs = ColorScheme;
99+
ColorScheme? cs = ColorScheme;
100100

101101
if (cs is null)
102102
{
@@ -132,16 +132,11 @@ private Attribute GetColor (Attribute inputAttribute)
132132
/// <summary>Selects the specified attribute as the attribute to use for future calls to AddRune and AddString.</summary>
133133
/// <remarks></remarks>
134134
/// <param name="attribute">THe Attribute to set.</param>
135-
public Attribute SetAttribute (Attribute attribute)
136-
{
137-
return Driver?.SetAttribute (attribute) ?? Attribute.Default;
138-
}
135+
public Attribute SetAttribute (Attribute attribute) { return Driver?.SetAttribute (attribute) ?? Attribute.Default; }
139136

140137
/// <summary>Gets the current <see cref="Attribute"/>.</summary>
141138
/// <returns>The current attribute.</returns>
142-
public Attribute GetAttribute ()
143-
{
144-
return Driver?.GetAttribute () ?? Attribute.Default;
145-
}
139+
public Attribute GetAttribute () { return Driver?.GetAttribute () ?? Attribute.Default; }
140+
146141
#endregion Attribute
147142
}

0 commit comments

Comments
 (0)