Skip to content

Commit a98da8c

Browse files
author
tznind
committed
Remove more color scheme code
1 parent fee2d0a commit a98da8c

24 files changed

Lines changed: 31 additions & 1423 deletions

src/DefaultColorSchemes.cs

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

src/Design.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,7 @@ public string GetUniqueFieldName(string? candidate)
514514

515515
// what field names are already taken by other objects?
516516
var usedFieldNames = allDesigns.Select(d => d.FieldName).ToList();
517-
usedFieldNames.AddRange(SchemeManager.Instance.Schemes.Select(k => k.Name));
518-
517+
519518
return candidate.MakeUnique(usedFieldNames);
520519
}
521520

@@ -613,9 +612,6 @@ private IEnumerable<Property> LoadDesignableProperties()
613612
yield return this.CreateSuppressedProperty(nameof(this.View.Visible), true);
614613

615614
yield return this.CreateSuppressedProperty(nameof(this.View.Arrangement), ViewArrangement.Fixed);
616-
617-
618-
yield return new SchemeProperty(this);
619615

620616
yield return this.CreateSuppressedProperty(nameof(View.CanFocus), true);
621617
yield return this.CreateProperty(nameof(this.View.ShadowStyle));

src/DesignState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private void DrawBorderlessViewFrame(Rectangle r)
7070

7171
var color = isSelected ?
7272
SelectionManager.Instance.SelectedScheme.Normal :
73-
this.Design.View.Scheme.Normal;
73+
this.Design.View.GetScheme().Normal;
7474

7575
Application.Driver.SetAttribute(color);
7676

src/ToCode/ViewToCode.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ public void GenerateDesignerCs(Design rootDesign, Type viewType)
158158
initMethod.Name = SourceCodeFile.InitializeComponentMethodName;
159159

160160
var args = new CodeDomArgs(class1, initMethod);
161-
162-
this.AddSchemesToClass(args);
163-
161+
164162
// Add designable root properties to the InitializeComponent method
165163
foreach (var prop in rootDesign.GetDesignableProperties())
166164
{
@@ -328,13 +326,4 @@ private void AddCustomHeaderForDesignerCsFile(CodeNamespace nSpace)
328326
"-----------------------------------" +
329327
"------------------------------------------"));
330328
}
331-
332-
private void AddSchemesToClass(CodeDomArgs args)
333-
{
334-
foreach (var scheme in SchemeManager.Instance.Schemes)
335-
{
336-
var toCode = new SchemeToCode(scheme);
337-
toCode.ToCode(args);
338-
}
339-
}
340329
}

src/UI/Editor.cs

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ protected override void OnDrawComplete(DrawContext? context)
288288

289289
if (this.enableShowFocused)
290290
{
291-
Application.Driver.SetAttribute(this.viewBeingEdited.View.Scheme.Normal);
292-
293291
string? toDisplay = this.GetLowerRightTextIfAny();
294292

295293
// and have a designable view focused
@@ -558,12 +556,6 @@ public bool HandleKey(Key key)
558556
return true;
559557
}
560558

561-
if (keyString == this.keyMap.ShowSchemes)
562-
{
563-
this.ShowSchemes();
564-
return true;
565-
}
566-
567559
if (keyString == this.keyMap.Copy)
568560
{
569561
this.Copy();
@@ -825,15 +817,16 @@ private void BuildRootMenu()
825817
Y = Pos.Percent(75),
826818
Width = maxWidth,
827819
Height = 4,
828-
Scheme = new Scheme
829-
(
830-
new Attribute(new Color(Color.White),new Color(Color.Black)),
831-
new Attribute(new Color(Color.Black),new Color(Color.White)),
832-
new Attribute(new Color(Color.White), new Color(Color.Black)),
833-
new Attribute(new Color(Color.White), new Color(Color.Black)),
834-
new Attribute(new Color(Color.Black), new Color(Color.White))
835-
),
836820
};
821+
rootCommandsListView.SetScheme(new Scheme
822+
{
823+
Normal = new Attribute(new Color(Color.White), new Color(Color.Black)),
824+
Focus = new Attribute(new Color(Color.Black), new Color(Color.White)),
825+
HotNormal = new Attribute(new Color(Color.White), new Color(Color.Black)),
826+
HotFocus = new Attribute(new Color(Color.White), new Color(Color.Black)),
827+
Disabled = new Attribute(new Color(Color.Black), new Color(Color.White))
828+
});
829+
837830
this.rootCommandsListView.SetSource(rootCommands);
838831
this.rootCommandsListView.SelectedItem = 0;
839832

@@ -1196,7 +1189,6 @@ private void Open()
11961189
Title = "Open",
11971190
AllowedTypes = new List<IAllowedType>(new[] { new AllowedType("View", SourceCodeFile.ExpectedExtension) })
11981191
};
1199-
ofd.SetupNiceSchemes();
12001192
ofd.Layout();
12011193

12021194
Application.Run(ofd, this.ErrorHandler);
@@ -1279,7 +1271,6 @@ private void New()
12791271
Path = "MyView.cs",
12801272
};
12811273
ofd.Layout();
1282-
ofd.SetupNiceSchemes();
12831274

12841275
Application.Run(ofd);
12851276

@@ -1421,9 +1412,6 @@ private void ReplaceViewBeingEdited(Design design)
14211412
// Load new instance
14221413
this.viewBeingEdited = design;
14231414

1424-
// TODO: Find a better place for this
1425-
SchemeManager.Instance.FindDeclaredSchemes(this.viewBeingEdited);
1426-
14271415
// And add it to the editing window
14281416
this.Add(this.viewBeingEdited.View);
14291417
});
@@ -1476,15 +1464,4 @@ private void ShowEditProperties(Design d)
14761464
var edit = new EditDialog(d);
14771465
Application.Run(edit, this.ErrorHandler);
14781466
}
1479-
1480-
private void ShowSchemes()
1481-
{
1482-
if (this.viewBeingEdited == null)
1483-
{
1484-
return;
1485-
}
1486-
1487-
var schemes = new SchemesUI(this.viewBeingEdited);
1488-
Application.Run(schemes);
1489-
}
14901467
}

src/UI/KeyMap.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,6 @@ public KeyMap( )
164164
/// <summary>Gets the string to assign a new shortcut to a <see cref="MenuItem" />.</summary>
165165
public string SetShortcut { get; init; } = SetShortcut;
166166

167-
/// <summary>
168-
/// Gets the string to open the <see cref="SchemesUI" /> window for creating/deleting <see cref="Scheme" /> that can be
169-
/// used in the <see cref="Editor" />.
170-
/// </summary>
171-
public string ShowSchemes { get; init; } = ShowSchemes;
172-
173167
/// <summary>Gets the string to pop up the right click context menu.</summary>
174168
public string ShowContextMenu { get; init; } = ShowContextMenu;
175169

src/UI/ValueFactory.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Terminal.Gui.Views;
88
using TerminalGuiDesigner.ToCode;
99
using TerminalGuiDesigner.UI.Windows;
10-
using ColorPicker = TerminalGuiDesigner.UI.Windows.ColorPicker;
1110
using Attribute = Terminal.Gui.Drawing.Attribute;
1211

1312
namespace TerminalGuiDesigner.UI
@@ -56,10 +55,6 @@ internal static bool GetNewValue(string propertyName, Design design, Type type,
5655
{
5756
return RunEditor(new SliderOptionEditor(type.GetGenericArguments()[0], oldValue), out newValue);
5857
}
59-
if (type == typeof(Attribute) || type == typeof(Attribute?))
60-
{
61-
return RunEditor(new ColorPicker((Attribute?)oldValue), out newValue);
62-
}
6358
if (type == typeof(Pos))
6459
{
6560
return RunEditor(new PosEditor(design, (Pos)oldValue ?? throw new Exception("Pos property was unexpectedly null")), out newValue);
@@ -190,7 +185,6 @@ internal static bool GetNewValue(string propertyName, Design design, Type type,
190185
if (type == typeof(FileSystemInfo))
191186
{
192187
var fd = new FileDialog();
193-
fd.SetupNiceSchemes();
194188
fd.AllowsMultipleSelection = false;
195189
fd.Layout();
196190

src/UI/Windows/ArrayEditor.Designer.cs

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/UI/Windows/ChoicesDialog.Designer.cs

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)