From 57fc30804da8ca4d5270900b30fb5552be47a4f7 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 3 Apr 2025 16:41:25 -0600 Subject: [PATCH] Tweaks --- .../Configuration/AttributeJsonConverter.cs | 2 +- .../Configuration/ScopeJsonConverter.cs | 4 +- Terminal.Gui/Resources/config.json | 527 +++++++++--------- Terminal.Gui/View/View.Adornments.cs | 19 +- Terminal.Gui/Views/Bar.cs | 9 +- Terminal.Gui/Views/Menu/Menuv2.cs | 18 +- 6 files changed, 306 insertions(+), 273 deletions(-) diff --git a/Terminal.Gui/Configuration/AttributeJsonConverter.cs b/Terminal.Gui/Configuration/AttributeJsonConverter.cs index ff1797221..ba291c75a 100644 --- a/Terminal.Gui/Configuration/AttributeJsonConverter.cs +++ b/Terminal.Gui/Configuration/AttributeJsonConverter.cs @@ -92,7 +92,7 @@ internal class AttributeJsonConverter : JsonConverter } } - throw new JsonException (); + throw new JsonException ("Attribute"); } public override void Write (Utf8JsonWriter writer, Attribute value, JsonSerializerOptions options) diff --git a/Terminal.Gui/Configuration/ScopeJsonConverter.cs b/Terminal.Gui/Configuration/ScopeJsonConverter.cs index d1d6e475e..bcfdd665e 100644 --- a/Terminal.Gui/Configuration/ScopeJsonConverter.cs +++ b/Terminal.Gui/Configuration/ScopeJsonConverter.cs @@ -96,6 +96,8 @@ internal class ScopeJsonConverter<[DynamicallyAccessedMembers (DynamicallyAccess // Logging.Trace ($"scopeT Read: {ex}"); } } + Logging.Warning ($"{propertyName} = {scope! [propertyName].PropertyValue}"); + } else { @@ -147,7 +149,7 @@ internal class ScopeJsonConverter<[DynamicallyAccessedMembers (DynamicallyAccess } } - throw new JsonException (); + throw new JsonException ("ScopeJsonConverter"); } public override void Write (Utf8JsonWriter writer, scopeT scope, JsonSerializerOptions options) diff --git a/Terminal.Gui/Resources/config.json b/Terminal.Gui/Resources/config.json index 230533b29..9d125c27b 100644 --- a/Terminal.Gui/Resources/config.json +++ b/Terminal.Gui/Resources/config.json @@ -52,271 +52,272 @@ "MessageBox.DefaultButtonAlignment": "Center", "MessageBox.DefaultBorderStyle": "Heavy", "Button.DefaultShadow": "Opaque", - "ColorSchemes": [ - { - "TopLevel": { - "Normal": { - "Foreground": "BrightGreen", - "Background": "#505050" // DarkerGray - }, - "Focus": { - "Foreground": "White", - "Background": "#696969" // DimGray - }, - "HotNormal": { - "Foreground": "Yellow", - "Background": "#505050" // DarkerGray - }, - "HotFocus": { - "Foreground": "Yellow", - "Background": "#696969" // DimGray - }, - "Disabled": { - "Foreground": "DarkGray", - "Background": "#505050" // DarkerGray + "Menuv2.DefaultBorderStyle": "Single", + "ColorSchemes": [ + { + "TopLevel": { + "Normal": { + "Foreground": "BrightGreen", + "Background": "#505050" // DarkerGray + }, + "Focus": { + "Foreground": "White", + "Background": "#696969" // DimGray + }, + "HotNormal": { + "Foreground": "Yellow", + "Background": "#505050" // DarkerGray + }, + "HotFocus": { + "Foreground": "Yellow", + "Background": "#696969" // DimGray + }, + "Disabled": { + "Foreground": "DarkGray", + "Background": "#505050" // DarkerGray + } + } + }, + { + "Base": { + "Normal": { + "Foreground": "White", + "Background": "Blue" + }, + "Focus": { + "Foreground": "DarkBlue", + "Background": "LightGray" + }, + "HotNormal": { + "Foreground": "BrightCyan", + "Background": "Blue" + }, + "HotFocus": { + "Foreground": "BrightBlue", + "Background": "LightGray" + }, + "Disabled": { + "Foreground": "DarkGray", + "Background": "Blue" + } + } + }, + { + "Dialog": { + "Normal": { + "Foreground": "Black", + "Background": "LightGray" + }, + "Focus": { + "Foreground": "DarkGray", + "Background": "LightGray" + }, + "HotNormal": { + "Foreground": "Blue", + "Background": "LightGray" + }, + "HotFocus": { + "Foreground": "BrightBlue", + "Background": "LightGray" + }, + "Disabled": { + "Foreground": "Gray", + "Background": "DarkGray" + } + } + }, + { + "Menu": { + "Normal": { + "Foreground": "White", + "Background": "DarkBlue" + }, + "Focus": { + "Foreground": "White", + "Background": "Blue" + }, + "HotNormal": { + "Foreground": "Yellow", + "Background": "DarkBlue" + }, + "HotFocus": { + "Foreground": "Yellow", + "Background": "Blue" + }, + "Disabled": { + "Foreground": "Gray", + "Background": "DarkGray" + } + } + }, + { + "Error": { + "Normal": { + "Foreground": "Red", + "Background": "Pink" + }, + "Focus": { + "Foreground": "White", + "Background": "BrightRed" + }, + "HotNormal": { + "Foreground": "Black", + "Background": "Pink" + }, + "HotFocus": { + "Foreground": "Pink", + "Background": "BrightRed" + }, + "Disabled": { + "Foreground": "DarkGray", + "Background": "White" + } } } - }, - { - "Base": { - "Normal": { - "Foreground": "White", - "Background": "Blue" - }, - "Focus": { - "Foreground": "DarkBlue", - "Background": "LightGray" - }, - "HotNormal": { - "Foreground": "BrightCyan", - "Background": "Blue" - }, - "HotFocus": { - "Foreground": "BrightBlue", - "Background": "LightGray" - }, - "Disabled": { - "Foreground": "DarkGray", - "Background": "Blue" - } - } - }, - { - "Dialog": { - "Normal": { - "Foreground": "Black", - "Background": "LightGray" - }, - "Focus": { - "Foreground": "DarkGray", - "Background": "LightGray" - }, - "HotNormal": { - "Foreground": "Blue", - "Background": "LightGray" - }, - "HotFocus": { - "Foreground": "BrightBlue", - "Background": "LightGray" - }, - "Disabled": { - "Foreground": "Gray", - "Background": "DarkGray" - } - } - }, - { - "Menu": { - "Normal": { - "Foreground": "White", - "Background": "DarkBlue" - }, - "Focus": { - "Foreground": "White", - "Background": "Blue" - }, - "HotNormal": { - "Foreground": "Yellow", - "Background": "DarkBlue" - }, - "HotFocus": { - "Foreground": "Yellow", - "Background": "Blue" - }, - "Disabled": { - "Foreground": "Gray", - "Background": "DarkGray" - } - } - }, - { - "Error": { - "Normal": { - "Foreground": "Red", - "Background": "Pink" - }, - "Focus": { - "Foreground": "White", - "Background": "BrightRed" - }, - "HotNormal": { - "Foreground": "Black", - "Background": "Pink" - }, - "HotFocus": { - "Foreground": "Pink", - "Background": "BrightRed" - }, - "Disabled": { - "Foreground": "DarkGray", - "Background": "White" - } - } - } - ], - "Glyphs.Apple": "\uD83C\uDF4E", - "Glyphs.AppleBMP": "❦", - "Glyphs.BlackCircle": "●", - "Glyphs.BlocksMeterSegment": "▌", - "Glyphs.BottomSideLineLtHv": "╽", - "Glyphs.BottomTee": "┴", - "Glyphs.BottomTeeDbl": "╩", - "Glyphs.BottomTeeDblH": "╧", - "Glyphs.BottomTeeDblV": "╨", - "Glyphs.BottomTeeHvDblH": "┻", - "Glyphs.BottomTeeHvH": "┷", - "Glyphs.BottomTeeHvV": "┸", - "Glyphs.CheckStateChecked": "☑", - "Glyphs.CheckStateNone": "☒", - "Glyphs.CheckStateUnChecked": "☐", - "Glyphs.Close": "✘", - "Glyphs.Collapse": "-", - "Glyphs.ContinuousMeterSegment": "█", - "Glyphs.Cross": "┼", - "Glyphs.CrossDbl": "╬", - "Glyphs.CrossDblH": "╪", - "Glyphs.CrossDblV": "╫", - "Glyphs.CrossHv": "╋", - "Glyphs.CrossHvH": "┿", - "Glyphs.CrossHvV": "╂", - "Glyphs.Diamond": "◊", - "Glyphs.Dot": "∙", - "Glyphs.DottedSquare": "⬚", - "Glyphs.DownArrow": "▼", - "Glyphs.Expand": "+", - "Glyphs.File": "☰", - "Glyphs.Folder": "꤉", - "Glyphs.HalfBottomLine": "╷", - "Glyphs.HalfBottomLineLt": "╻", - "Glyphs.HalfLeftLine": "╴", - "Glyphs.HalfLeftLineHv": "╸", - "Glyphs.HalfRightLine": "╶", - "Glyphs.HalfRightLineHv": "╺", - "Glyphs.HalfTopLine": "╵", - "Glyphs.HalfTopLineHv": "╹", - "Glyphs.HLine": "─", - "Glyphs.HLineDa2": "╌", - "Glyphs.HLineDa3": "┄", - "Glyphs.HLineDa4": "┈", - "Glyphs.HLineDbl": "═", - "Glyphs.HLineHv": "━", - "Glyphs.HLineHvDa2": "╍", - "Glyphs.HLineHvDa3": "┅", - "Glyphs.HLineHvDa4": "┉", - "Glyphs.HorizontalEllipsis": "…", - "Glyphs.IdenticalTo": "≡", - "Glyphs.LeftArrow": "◄", - "Glyphs.LeftBracket": "⟦", - "Glyphs.LeftDefaultIndicator": "►", - "Glyphs.LeftSideLineHvLt": "╾", - "Glyphs.LeftTee": "├", - "Glyphs.LeftTeeDbl": "╠", - "Glyphs.LeftTeeDblH": "╞", - "Glyphs.LeftTeeDblV": "╟", - "Glyphs.LeftTeeHvDblH": "┣", - "Glyphs.LeftTeeHvH": "┝", - "Glyphs.LeftTeeHvV": "┠", - "Glyphs.LLCorner": "└", - "Glyphs.LLCornerDbl": "╚", - "Glyphs.LLCornerDblSingle": "╙", - "Glyphs.LLCornerHv": "┗", - "Glyphs.LLCornerHvLt": "┖", - "Glyphs.LLCornerLtHv": "┕", - "Glyphs.LLCornerR": "╰", - "Glyphs.LLCornerSingleDbl": "╘", - "Glyphs.LRCorner": "┘", - "Glyphs.LRCornerDbl": "╝", - "Glyphs.LRCornerDblSingle": "╜", - "Glyphs.LRCornerHv": "┛", - "Glyphs.LRCornerHvLt": "┚", - "Glyphs.LRCornerLtHv": "┙", - "Glyphs.LRCornerR": "╯", - "Glyphs.LRCornerSingleDbl": "╛", - "Glyphs.Maximize": "✽", - "Glyphs.Minimize": "❏", - "Glyphs.Move": "◊", - "Glyphs.RightArrow": "►", - "Glyphs.RightBracket": "⟧", - "Glyphs.RightDefaultIndicator": "◄", - "Glyphs.RightSideLineLtHv": "╼", - "Glyphs.RightTee": "┤", - "Glyphs.RightTeeDbl": "╣", - "Glyphs.RightTeeDblH": "╡", - "Glyphs.RightTeeDblV": "╢", - "Glyphs.RightTeeHvDblH": "┫", - "Glyphs.RightTeeHvH": "┥", - "Glyphs.RightTeeHvV": "┨", - "Glyphs.Selected": "◉", - "Glyphs.ShadowHorizontal": "▀", - "Glyphs.ShadowHorizontalEnd": "▘", - "Glyphs.ShadowHorizontalStart": "▝", - "Glyphs.ShadowVertical": "▌", - "Glyphs.ShadowVerticalStart": "▖", - "Glyphs.SizeBottomLeft": "↙", - "Glyphs.SizeBottomRight": "↘", - "Glyphs.SizeHorizontal": "↔", - "Glyphs.SizeTopLeft": "↖", - "Glyphs.SizeTopRight": "↗", - "Glyphs.SizeVertical": "↕", - "Glyphs.Stipple": "░", - "Glyphs.TopSideLineHvLt": "╿", - "Glyphs.TopTee": "┬", - "Glyphs.TopTeeDbl": "╦", - "Glyphs.TopTeeDblH": "╤", - "Glyphs.TopTeeDblV": "╥", - "Glyphs.TopTeeHvDblH": "┳", - "Glyphs.TopTeeHvH": "┯", - "Glyphs.TopTeeHvV": "┰", - "Glyphs.ULCorner": "┌", - "Glyphs.ULCornerDbl": "╔", - "Glyphs.ULCornerDblSingle": "╓", - "Glyphs.ULCornerHv": "┏", - "Glyphs.ULCornerHvLt": "┎", - "Glyphs.ULCornerLtHv": "┍", - "Glyphs.ULCornerR": "╭", - "Glyphs.ULCornerSingleDbl": "╒", - "Glyphs.UnSelected": "○", - "Glyphs.UpArrow": "▲", - "Glyphs.URCorner": "┐", - "Glyphs.URCornerDbl": "╗", - "Glyphs.URCornerDblSingle": "╖", - "Glyphs.URCornerHv": "┓", - "Glyphs.URCornerHvLt": "┑", - "Glyphs.URCornerLtHv": "┒", - "Glyphs.URCornerR": "╮", - "Glyphs.URCornerSingleDbl": "╕", - "Glyphs.VerticalFourDots": "⁞", - "Glyphs.VLine": "│", - "Glyphs.VLineDa2": "╎", - "Glyphs.VLineDa3": "┆", - "Glyphs.VLineDa4": "┊", - "Glyphs.VLineDbl": "║", - "Glyphs.VLineHv": "┃", - "Glyphs.VLineHvDa2": "╏", - "Glyphs.VLineHvDa3": "┇", - "Glyphs.VLineHvDa4": "┋" - } - }, + ], + "Glyphs.Apple": "\uD83C\uDF4E", + "Glyphs.AppleBMP": "❦", + "Glyphs.BlackCircle": "●", + "Glyphs.BlocksMeterSegment": "▌", + "Glyphs.BottomSideLineLtHv": "╽", + "Glyphs.BottomTee": "┴", + "Glyphs.BottomTeeDbl": "╩", + "Glyphs.BottomTeeDblH": "╧", + "Glyphs.BottomTeeDblV": "╨", + "Glyphs.BottomTeeHvDblH": "┻", + "Glyphs.BottomTeeHvH": "┷", + "Glyphs.BottomTeeHvV": "┸", + "Glyphs.CheckStateChecked": "☑", + "Glyphs.CheckStateNone": "☒", + "Glyphs.CheckStateUnChecked": "☐", + "Glyphs.Close": "✘", + "Glyphs.Collapse": "-", + "Glyphs.ContinuousMeterSegment": "█", + "Glyphs.Cross": "┼", + "Glyphs.CrossDbl": "╬", + "Glyphs.CrossDblH": "╪", + "Glyphs.CrossDblV": "╫", + "Glyphs.CrossHv": "╋", + "Glyphs.CrossHvH": "┿", + "Glyphs.CrossHvV": "╂", + "Glyphs.Diamond": "◊", + "Glyphs.Dot": "∙", + "Glyphs.DottedSquare": "⬚", + "Glyphs.DownArrow": "▼", + "Glyphs.Expand": "+", + "Glyphs.File": "☰", + "Glyphs.Folder": "꤉", + "Glyphs.HalfBottomLine": "╷", + "Glyphs.HalfBottomLineLt": "╻", + "Glyphs.HalfLeftLine": "╴", + "Glyphs.HalfLeftLineHv": "╸", + "Glyphs.HalfRightLine": "╶", + "Glyphs.HalfRightLineHv": "╺", + "Glyphs.HalfTopLine": "╵", + "Glyphs.HalfTopLineHv": "╹", + "Glyphs.HLine": "─", + "Glyphs.HLineDa2": "╌", + "Glyphs.HLineDa3": "┄", + "Glyphs.HLineDa4": "┈", + "Glyphs.HLineDbl": "═", + "Glyphs.HLineHv": "━", + "Glyphs.HLineHvDa2": "╍", + "Glyphs.HLineHvDa3": "┅", + "Glyphs.HLineHvDa4": "┉", + "Glyphs.HorizontalEllipsis": "…", + "Glyphs.IdenticalTo": "≡", + "Glyphs.LeftArrow": "◄", + "Glyphs.LeftBracket": "⟦", + "Glyphs.LeftDefaultIndicator": "►", + "Glyphs.LeftSideLineHvLt": "╾", + "Glyphs.LeftTee": "├", + "Glyphs.LeftTeeDbl": "╠", + "Glyphs.LeftTeeDblH": "╞", + "Glyphs.LeftTeeDblV": "╟", + "Glyphs.LeftTeeHvDblH": "┣", + "Glyphs.LeftTeeHvH": "┝", + "Glyphs.LeftTeeHvV": "┠", + "Glyphs.LLCorner": "└", + "Glyphs.LLCornerDbl": "╚", + "Glyphs.LLCornerDblSingle": "╙", + "Glyphs.LLCornerHv": "┗", + "Glyphs.LLCornerHvLt": "┖", + "Glyphs.LLCornerLtHv": "┕", + "Glyphs.LLCornerR": "╰", + "Glyphs.LLCornerSingleDbl": "╘", + "Glyphs.LRCorner": "┘", + "Glyphs.LRCornerDbl": "╝", + "Glyphs.LRCornerDblSingle": "╜", + "Glyphs.LRCornerHv": "┛", + "Glyphs.LRCornerHvLt": "┚", + "Glyphs.LRCornerLtHv": "┙", + "Glyphs.LRCornerR": "╯", + "Glyphs.LRCornerSingleDbl": "╛", + "Glyphs.Maximize": "✽", + "Glyphs.Minimize": "❏", + "Glyphs.Move": "◊", + "Glyphs.RightArrow": "►", + "Glyphs.RightBracket": "⟧", + "Glyphs.RightDefaultIndicator": "◄", + "Glyphs.RightSideLineLtHv": "╼", + "Glyphs.RightTee": "┤", + "Glyphs.RightTeeDbl": "╣", + "Glyphs.RightTeeDblH": "╡", + "Glyphs.RightTeeDblV": "╢", + "Glyphs.RightTeeHvDblH": "┫", + "Glyphs.RightTeeHvH": "┥", + "Glyphs.RightTeeHvV": "┨", + "Glyphs.Selected": "◉", + "Glyphs.ShadowHorizontal": "▀", + "Glyphs.ShadowHorizontalEnd": "▘", + "Glyphs.ShadowHorizontalStart": "▝", + "Glyphs.ShadowVertical": "▌", + "Glyphs.ShadowVerticalStart": "▖", + "Glyphs.SizeBottomLeft": "↙", + "Glyphs.SizeBottomRight": "↘", + "Glyphs.SizeHorizontal": "↔", + "Glyphs.SizeTopLeft": "↖", + "Glyphs.SizeTopRight": "↗", + "Glyphs.SizeVertical": "↕", + "Glyphs.Stipple": "░", + "Glyphs.TopSideLineHvLt": "╿", + "Glyphs.TopTee": "┬", + "Glyphs.TopTeeDbl": "╦", + "Glyphs.TopTeeDblH": "╤", + "Glyphs.TopTeeDblV": "╥", + "Glyphs.TopTeeHvDblH": "┳", + "Glyphs.TopTeeHvH": "┯", + "Glyphs.TopTeeHvV": "┰", + "Glyphs.ULCorner": "┌", + "Glyphs.ULCornerDbl": "╔", + "Glyphs.ULCornerDblSingle": "╓", + "Glyphs.ULCornerHv": "┏", + "Glyphs.ULCornerHvLt": "┎", + "Glyphs.ULCornerLtHv": "┍", + "Glyphs.ULCornerR": "╭", + "Glyphs.ULCornerSingleDbl": "╒", + "Glyphs.UnSelected": "○", + "Glyphs.UpArrow": "▲", + "Glyphs.URCorner": "┐", + "Glyphs.URCornerDbl": "╗", + "Glyphs.URCornerDblSingle": "╖", + "Glyphs.URCornerHv": "┓", + "Glyphs.URCornerHvLt": "┑", + "Glyphs.URCornerLtHv": "┒", + "Glyphs.URCornerR": "╮", + "Glyphs.URCornerSingleDbl": "╕", + "Glyphs.VerticalFourDots": "⁞", + "Glyphs.VLine": "│", + "Glyphs.VLineDa2": "╎", + "Glyphs.VLineDa3": "┆", + "Glyphs.VLineDa4": "┊", + "Glyphs.VLineDbl": "║", + "Glyphs.VLineHv": "┃", + "Glyphs.VLineHvDa2": "╏", + "Glyphs.VLineHvDa3": "┇", + "Glyphs.VLineHvDa4": "┋" + } + }, { "Dark": { "Dialog.DefaultButtonAlignment": "End", diff --git a/Terminal.Gui/View/View.Adornments.cs b/Terminal.Gui/View/View.Adornments.cs index 9e0549839..c9c874cc1 100644 --- a/Terminal.Gui/View/View.Adornments.cs +++ b/Terminal.Gui/View/View.Adornments.cs @@ -168,8 +168,8 @@ public partial class View // Adornments } SetBorderStyle (e.NewValue); - SetAdornmentFrames (); - SetNeedsLayout (); + OnBorderStyleChanged (); + BorderStyleChanged?.Invoke(this, EventArgs.Empty); } } @@ -187,6 +187,16 @@ public partial class View // Adornments /// public event EventHandler>? BorderStyleChanging; + /// + /// Called when the has changed. + /// + protected virtual bool OnBorderStyleChanged () { return false; } + + /// + /// Fired when the has changed. + /// + public event EventHandler? BorderStyleChanged; + /// /// Sets the of the view to the specified value. /// @@ -204,7 +214,7 @@ public partial class View // Adornments /// For more advanced customization of the view's border, manipulate see directly. /// /// - public virtual void SetBorderStyle (LineStyle style) + internal void SetBorderStyle (LineStyle style) { if (style != LineStyle.None) { @@ -219,6 +229,9 @@ public partial class View // Adornments } Border.LineStyle = style; + + SetAdornmentFrames (); + SetNeedsLayout (); } /// diff --git a/Terminal.Gui/Views/Bar.cs b/Terminal.Gui/Views/Bar.cs index 2608390f2..20929b79d 100644 --- a/Terminal.Gui/Views/Bar.cs +++ b/Terminal.Gui/Views/Bar.cs @@ -75,14 +75,17 @@ public class Bar : View, IOrientation, IDesignable } /// - public override void SetBorderStyle (LineStyle lineStyle) + protected override bool OnBorderStyleChanging (CancelEventArgs e) { if (Border is { }) { // The default changes the thickness. We don't want that. We just set the style. - Border.LineStyle = lineStyle; + Border.LineStyle = e.NewValue; + + return true; // Cancel } - //base.SetBorderStyle(lineStyle); + + return base.OnBorderStyleChanging (e); } #region IOrientation members diff --git a/Terminal.Gui/Views/Menu/Menuv2.cs b/Terminal.Gui/Views/Menu/Menuv2.cs index 2d2385237..75e532019 100644 --- a/Terminal.Gui/Views/Menu/Menuv2.cs +++ b/Terminal.Gui/Views/Menu/Menuv2.cs @@ -20,8 +20,22 @@ public class Menuv2 : Bar Height = Dim.Auto (DimAutoStyle.Content, 1); base.ColorScheme = Colors.ColorSchemes ["Menu"]; - Border!.Thickness = new Thickness (1, 1, 1, 1); - Border.LineStyle = LineStyle.Single; + BorderStyle = DefaultBorderStyle; + } + + // BUGBUG: For some reason this config property is not working! + /// + /// Gets or sets the default Highlight Style. + /// + [SerializableConfigurationProperty (Scope = typeof (ThemeScope))] + public static LineStyle DefaultBorderStyle { get; set; } = LineStyle.Single; + + /// + protected override bool OnBorderStyleChanging (CancelEventArgs e) + { + // Bar (our base) overrides this to prevent automatic changing of thickness. + // We don't want that so we override as well. + return false; } ///