Skip to content

Commit fee2d0a

Browse files
author
tznind
committed
Start removing scheme support
1 parent 4d2e773 commit fee2d0a

42 files changed

Lines changed: 109 additions & 645 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Showcase/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.ObjectModel;
22
using System.Runtime.InteropServices.ComTypes;
33
using Terminal.Gui;
4+
using Terminal.Gui.App;
45
using Terminal.Gui.Drivers;
56
using Terminal.Gui.ViewBase;
67
using Terminal.Gui.Views;

src/AttributeExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public static class AttributeExtensions
1212
/// <returns>Code construct <paramref name="a"/>.</returns>
1313
public static string ToCode(this Terminal.Gui.Drawing.Attribute a)
1414
{
15-
return $"new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.{a.Foreground},Terminal.Gui.Color.{a.Background})";
15+
return $"new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.{a.Foreground},Terminal.Gui.Drawing.Color.{a.Background})";
1616
}
1717
}

src/ColorSchemeManager.cs

Lines changed: 0 additions & 170 deletions
This file was deleted.

src/DefaultColorSchemes.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,36 @@ public DefaultSchemes()
1919
{
2020
this.RedOnBlack = new NamedScheme("redOnBlack",
2121
new Scheme(
22-
normal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Black),
23-
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.BrightRed, Terminal.Gui.Color.Black),
24-
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Red, Terminal.Gui.Color.Yellow),
25-
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.BrightRed, Terminal.Gui.Color.Yellow),
26-
disabled: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black)
22+
normal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Red, Terminal.Gui.Drawing.Color.Black),
23+
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.BrightRed, Terminal.Gui.Drawing.Color.Black),
24+
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Red, Terminal.Gui.Drawing.Color.Yellow),
25+
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.BrightRed, Terminal.Gui.Drawing.Color.Yellow),
26+
disabled: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Gray, Terminal.Gui.Drawing.Color.Black)
2727
));
2828

2929
this.GreenOnBlack = new NamedScheme("greenOnBlack",
3030
new Scheme(
31-
normal : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Green, Terminal.Gui.Color.Black),
32-
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.BrightGreen, Terminal.Gui.Color.Black),
33-
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Green, Terminal.Gui.Color.Magenta),
34-
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.BrightGreen, Terminal.Gui.Color.Magenta),
35-
disabled : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black)));
31+
normal : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Green, Terminal.Gui.Drawing.Color.Black),
32+
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.BrightGreen, Terminal.Gui.Drawing.Color.Black),
33+
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Green, Terminal.Gui.Drawing.Color.Magenta),
34+
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.BrightGreen, Terminal.Gui.Drawing.Color.Magenta),
35+
disabled : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Gray, Terminal.Gui.Drawing.Color.Black)));
3636

3737
this.BlueOnBlack = new NamedScheme("blueOnBlack",
3838
new Scheme(
39-
normal : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.BrightBlue, Terminal.Gui.Color.Black),
40-
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Cyan, Terminal.Gui.Color.Black),
41-
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.BrightBlue, Terminal.Gui.Color.BrightYellow),
42-
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Cyan, Terminal.Gui.Color.BrightYellow),
43-
disabled: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Gray, Terminal.Gui.Color.Black)));
39+
normal : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.BrightBlue, Terminal.Gui.Drawing.Color.Black),
40+
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Cyan, Terminal.Gui.Drawing.Color.Black),
41+
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.BrightBlue, Terminal.Gui.Drawing.Color.BrightYellow),
42+
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Cyan, Terminal.Gui.Drawing.Color.BrightYellow),
43+
disabled: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Gray, Terminal.Gui.Drawing.Color.Black)));
4444

4545
this.GrayOnBlack = new NamedScheme("greyOnBlack",
4646
new Scheme(
47-
normal : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black),
48-
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black),
49-
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray),
50-
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray),
51-
disabled: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black)));
47+
normal : new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.DarkGray, Terminal.Gui.Drawing.Color.Black),
48+
hotNormal: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.DarkGray, Terminal.Gui.Drawing.Color.Black),
49+
focus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Black, Terminal.Gui.Drawing.Color.DarkGray),
50+
hotFocus: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.Black, Terminal.Gui.Drawing.Color.DarkGray),
51+
disabled: new Terminal.Gui.Drawing.Attribute(Terminal.Gui.Drawing.Color.DarkGray, Terminal.Gui.Drawing.Color.Black)));
5252

5353
this.TerminalGuiDefault = new NamedScheme("tgDefault",
5454
new Scheme(

src/Design.cs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Xml.Linq;
66
using NLog;
77
using Terminal.Gui;
8+
using Terminal.Gui.Configuration;
89
using Terminal.Gui.Drawing;
910
using Terminal.Gui.Input;
1011
using Terminal.Gui.ViewBase;
@@ -259,57 +260,6 @@ public Design CreateSubControlDesign(string name, View subView)
259260
return d;
260261
}
261262

262-
/// <summary>
263-
/// <para>
264-
/// Returns true if there is an explicit Scheme set
265-
/// on this Design's View or false if it is inherited from
266-
/// a View further up the Layout (or a library default scheme).
267-
/// </para>
268-
/// <para> If a scheme is found that is not known about by SchemeManager
269-
/// then false is returned.</para>
270-
/// </summary>
271-
/// <returns>True if view explicitly uses one in <see cref="SchemeManager"/>
272-
/// because user explicitly allocated it to the <see cref="View"/> (rather than inheriting).</returns>
273-
public bool HasKnownScheme()
274-
{
275-
var userDefinedScheme = this.State.OriginalScheme ?? this.View.GetExplicitScheme();
276-
277-
if (userDefinedScheme == null)
278-
{
279-
return false;
280-
}
281-
282-
// theres a color scheme defined but we aren't tracking it
283-
// so report it as inherited since it must have got it from
284-
// the API somehow
285-
if (Colors.Schemes.Values.Contains(userDefinedScheme))
286-
{
287-
return false;
288-
}
289-
290-
// it has a Scheme but not one we are tracking
291-
if (SchemeManager.Instance.GetNameForScheme(userDefinedScheme) == null)
292-
{
293-
return false;
294-
}
295-
296-
return true;
297-
}
298-
299-
/// <summary>
300-
/// True if this view EXPLICITLY states that it uses the scheme
301-
/// False if its scheme is inherited from a parent or it explicitly
302-
/// uses a different Scheme.
303-
/// </summary>
304-
/// <param name="scheme">The scheme you want to know if <see cref="View"/> is using.</param>
305-
/// <returns>True if <see cref="View"/> uses <paramref name="scheme"/> explicitly.</returns>
306-
public bool UsesScheme(Scheme scheme)
307-
{
308-
// we use this scheme if it is a known scheme
309-
return this.HasKnownScheme() &&
310-
(this.View.Scheme.Equals(scheme) || (this.State.OriginalScheme?.Equals(scheme) ?? false));
311-
}
312-
313263
/// <summary>
314264
/// Gets the designable properties of the hosted <see cref="View"/>.
315265
/// </summary>

src/DesignState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Text;
22
using Terminal.Gui;
3+
using Terminal.Gui.App;
34
using Terminal.Gui.Drawing;
45
using Terminal.Gui.ViewBase;
56
using TerminalGuiDesigner.UI;
@@ -23,8 +24,7 @@ public class DesignState
2324
public DesignState(Design design)
2425
{
2526
this.Design = design;
26-
this.OriginalScheme = this.Design.View.GetExplicitScheme();
27-
this.Design.View.DrawComplete += this.DrawContentComplete;
27+
this.Design.View.DrawComplete += this.DrawContentComplete;
2828
this.Design.View.HasFocusChanged += this.Enter;
2929
}
3030

src/Operations/AddViewOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Terminal.Gui;
2+
using Terminal.Gui.App;
23
using Terminal.Gui.ViewBase;
34
using Terminal.Gui.Views;
45
using TerminalGuiDesigner.UI.Windows;

0 commit comments

Comments
 (0)