Ver código fonte

Fixed Run Json

Tig 10 meses atrás
pai
commit
591a76e34f

+ 25 - 17
Terminal.Gui/Configuration/RuneJsonConverter.cs

@@ -6,9 +6,18 @@ using System.Text.RegularExpressions;
 namespace Terminal.Gui;
 
 /// <summary>
-///     Json converter for <see cref="Rune"/>. Supports Json converter for <see cref="Rune"/>. Supports A string as
-///     one of: - unicode char (e.g. "☑") - U+hex format (e.g. "U+2611") - \u format (e.g. "\\u2611") A number - The
-///     unicode code in decimal
+///     Json converter for <see cref="Rune"/>.
+///     <para>
+///         If the Rune is printable, it will be serialized as the glyph; otherwise the \u format (e.g. "\\u2611") is used.
+///     </para>
+///     <para>
+///         Supports deserializing a string as
+///         one of:
+///         - unicode char (e.g. "☑")
+///         - U+hex format (e.g. "U+2611")
+///         - \u format (e.g. "\\u2611")
+///         - A decimal number (e.g. "97" for "a")
+///     </para>
 /// </summary>
 internal class RuneJsonConverter : JsonConverter<Rune>
 {
@@ -108,7 +117,7 @@ internal class RuneJsonConverter : JsonConverter<Rune>
                     throw new JsonException ($"Invalid combined Rune ({value})");
                 }
 
-                return new Rune (combined [0]);
+                return new (combined [0]);
             }
             case JsonTokenType.Number:
             {
@@ -116,7 +125,7 @@ internal class RuneJsonConverter : JsonConverter<Rune>
 
                 if (Rune.IsValid (num))
                 {
-                    return new Rune (num);
+                    return new (num);
                 }
 
                 throw new JsonException ($"Invalid Rune (not a scalar Unicode value): {num}.");
@@ -128,18 +137,17 @@ internal class RuneJsonConverter : JsonConverter<Rune>
 
     public override void Write (Utf8JsonWriter writer, Rune value, JsonSerializerOptions options)
     {
-        // HACK: Writes a JSON comment in addition to the glyph to ease debugging.
-        // Technically, JSON comments are not valid, but we use relaxed decoding
-        // (ReadCommentHandling = JsonCommentHandling.Skip)
-        //writer.WriteCommentValue ($"(U+{value.Value:X8})");
-        //var printable = value.MakePrintable ();
-        //if (printable == Rune.ReplacementChar) {
-        //	writer.WriteStringValue (value.ToString ());
-        //} else {
-        //	//writer.WriteRawValue ($"\"{value}\"");
-        //}
-
-        writer.WriteNumberValue (value.Value);
+        Rune printable = value.MakePrintable ();
+        if (printable == Rune.ReplacementChar)
+        {
+            // Write as /u string
+            writer.WriteRawValue ($"\"{value}\"");
+        }
+        else
+        {
+            // Write as the actual glyph
+            writer.WriteStringValue (value.ToString ());
+        }
     }
 }
 #pragma warning restore 1591

+ 5 - 119
Terminal.Gui/Drawing/Glyphs.cs

@@ -1,6 +1,4 @@
-using System.Text.Json.Serialization;
-
-namespace Terminal.Gui;
+namespace Terminal.Gui;
 
 /// <summary>Defines the standard set of glyphs used to draw checkboxes, lines, borders, etc...</summary>
 /// <remarks>
@@ -20,157 +18,119 @@ namespace Terminal.Gui;
 public class GlyphDefinitions
 {
     /// <summary>File icon.  Defaults to ☰ (Trigram For Heaven)</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune File { get; set; } = (Rune)'☰';
 
     /// <summary>Folder icon.  Defaults to ꤉ (Kayah Li Digit Nine)</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Folder { get; set; } = (Rune)'꤉';
 
     /// <summary>Horizontal Ellipsis - … U+2026</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HorizontalEllipsis { get; set; } = (Rune)'…';
 
     /// <summary>Vertical Four Dots - ⁞ U+205e</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VerticalFourDots { get; set; } = (Rune)'⁞';
 
     #region ----------------- Single Glyphs -----------------
 
-    /// <summary>Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>) - Ballot Box With Check - ☑ U+02611.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
+    /// <summary>Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>).</summary>
     public Rune CheckStateChecked { get; set; } = (Rune)'☑';
 
     /// <summary>Not Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>).</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CheckStateUnChecked { get; set; } = (Rune)'☐';
 
-    /// <summary>Null Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>). - Ballot Box With X - ☒ U+02612.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
+    /// <summary>Null Checked indicator (e.g. for <see cref="ListView"/> and <see cref="CheckBox"/>).</summary>
     public Rune CheckStateNone { get; set; } = (Rune)'☒';
 
     /// <summary>Selected indicator  (e.g. for <see cref="ListView"/> and <see cref="RadioGroup"/>).</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Selected { get; set; } = (Rune)'◉';
 
     /// <summary>Not Selected indicator (e.g. for <see cref="ListView"/> and <see cref="RadioGroup"/>).</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune UnSelected { get; set; } = (Rune)'○';
 
     /// <summary>Horizontal arrow.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune RightArrow { get; set; } = (Rune)'►';
 
     /// <summary>Left arrow.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LeftArrow { get; set; } = (Rune)'◄';
 
     /// <summary>Down arrow.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune DownArrow { get; set; } = (Rune)'▼';
 
     /// <summary>Vertical arrow.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune UpArrow { get; set; } = (Rune)'▲';
 
     /// <summary>Left default indicator (e.g. for <see cref="Button"/>.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LeftDefaultIndicator { get; set; } = (Rune)'►';
 
     /// <summary>Horizontal default indicator (e.g. for <see cref="Button"/>.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune RightDefaultIndicator { get; set; } = (Rune)'◄';
 
     /// <summary>Left Bracket (e.g. for <see cref="Button"/>. Default is (U+005B) - [.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LeftBracket { get; set; } = (Rune)'⟦';
 
     /// <summary>Horizontal Bracket (e.g. for <see cref="Button"/>. Default is (U+005D) - ].</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune RightBracket { get; set; } = (Rune)'⟧';
 
     /// <summary>Half block meter segment (e.g. for <see cref="ProgressBar"/>).</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune BlocksMeterSegment { get; set; } = (Rune)'▌';
 
     /// <summary>Continuous block meter segment (e.g. for <see cref="ProgressBar"/>).</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ContinuousMeterSegment { get; set; } = (Rune)'█';
 
     /// <summary>Stipple pattern (e.g. for <see cref="ScrollBarView"/>). Default is Light Shade (U+2591) - ░.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Stipple { get; set; } = (Rune)'░';
 
     /// <summary>Diamond (e.g. for <see cref="ScrollBarView"/>. Default is Lozenge (U+25CA) - ◊.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Diamond { get; set; } = (Rune)'◊';
 
     /// <summary>Close. Default is Heavy Ballot X (U+2718) - ✘.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Close { get; set; } = (Rune)'✘';
 
     /// <summary>Minimize. Default is Lower Horizontal Shadowed White Circle (U+274F) - ❏.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Minimize { get; set; } = (Rune)'❏';
 
     /// <summary>Maximize. Default is Upper Horizontal Shadowed White Circle (U+273D) - ✽.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Maximize { get; set; } = (Rune)'✽';
 
     /// <summary>Dot. Default is (U+2219) - ∙.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Dot { get; set; } = (Rune)'∙';
 
     /// <summary>Black Circle . Default is (U+025cf) - ●.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune BlackCircle { get; set; } = (Rune)'●'; // Black Circle - ● U+025cf
 
     /// <summary>Expand (e.g. for <see cref="TreeView"/>.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Expand { get; set; } = (Rune)'+';
 
     /// <summary>Expand (e.g. for <see cref="TreeView"/>.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Collapse { get; set; } = (Rune)'-';
 
     /// <summary>Identical To (U+226)</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune IdenticalTo { get; set; } = (Rune)'≡';
 
     /// <summary>Move indicator. Default is Lozenge (U+25CA) - ◊.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Move { get; set; } = (Rune)'◊';
 
     /// <summary>Size Horizontally indicator. Default is ┥Left Right Arrow - ↔ U+02194</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune SizeHorizontal { get; set; } = (Rune)'↔';
-
+    
     /// <summary>Size Vertical indicator. Default Up Down Arrow - ↕ U+02195</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune SizeVertical { get; set; } = (Rune)'↕';
 
     /// <summary>Size Top Left indicator. North West Arrow - ↖ U+02196</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune SizeTopLeft { get; set; } = (Rune)'↖';
 
     /// <summary>Size Top Right indicator. North East Arrow - ↗ U+02197</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune SizeTopRight { get; set; } = (Rune)'↗';
 
     /// <summary>Size Bottom Right indicator. South East Arrow - ↘ U+02198</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune SizeBottomRight { get; set; } = (Rune)'↘';
 
     /// <summary>Size Bottom Left indicator. South West Arrow - ↙ U+02199</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune SizeBottomLLeft { get; set; } = (Rune)'↙';
-
+    
     /// <summary>Apple (non-BMP). Because snek. And because it's an example of a non-BMP surrogate pair. See Issue #2610.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Apple { get; set; } = "🍎".ToRunes () [0]; // nonBMP
 
     /// <summary>Apple (BMP). Because snek. See Issue #2610.</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune AppleBMP { get; set; } = (Rune)'❦';
 
     ///// <summary>
@@ -183,123 +143,93 @@ public class GlyphDefinitions
     #region ----------------- Lines -----------------
 
     /// <summary>Box Drawings Horizontal Line - Light (U+2500) - ─</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLine { get; set; } = (Rune)'─';
 
     /// <summary>Box Drawings Vertical Line - Light (U+2502) - │</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLine { get; set; } = (Rune)'│';
 
     /// <summary>Box Drawings Double Horizontal (U+2550) - ═</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineDbl { get; set; } = (Rune)'═';
 
     /// <summary>Box Drawings Double Vertical (U+2551) - ║</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineDbl { get; set; } = (Rune)'║';
 
     /// <summary>Box Drawings Heavy Double Dash Horizontal (U+254D) - ╍</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineHvDa2 { get; set; } = (Rune)'╍';
 
     /// <summary>Box Drawings Heavy Triple Dash Vertical (U+2507) - ┇</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineHvDa3 { get; set; } = (Rune)'┇';
 
     /// <summary>Box Drawings Heavy Triple Dash Horizontal (U+2505) - ┅</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineHvDa3 { get; set; } = (Rune)'┅';
 
     /// <summary>Box Drawings Heavy Quadruple Dash Horizontal (U+2509) - ┉</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineHvDa4 { get; set; } = (Rune)'┉';
 
     /// <summary>Box Drawings Heavy Double Dash Vertical (U+254F) - ╏</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineHvDa2 { get; set; } = (Rune)'╏';
 
     /// <summary>Box Drawings Heavy Quadruple Dash Vertical (U+250B) - ┋</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineHvDa4 { get; set; } = (Rune)'┋';
 
     /// <summary>Box Drawings Light Double Dash Horizontal (U+254C) - ╌</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineDa2 { get; set; } = (Rune)'╌';
 
     /// <summary>Box Drawings Light Triple Dash Vertical (U+2506) - ┆</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineDa3 { get; set; } = (Rune)'┆';
 
     /// <summary>Box Drawings Light Triple Dash Horizontal (U+2504) - ┄</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineDa3 { get; set; } = (Rune)'┄';
 
     /// <summary>Box Drawings Light Quadruple Dash Horizontal (U+2508) - ┈</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineDa4 { get; set; } = (Rune)'┈';
 
     /// <summary>Box Drawings Light Double Dash Vertical (U+254E) - ╎</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineDa2 { get; set; } = (Rune)'╎';
 
     /// <summary>Box Drawings Light Quadruple Dash Vertical (U+250A) - ┊</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineDa4 { get; set; } = (Rune)'┊';
 
     /// <summary>Box Drawings Heavy Horizontal (U+2501) - ━</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HLineHv { get; set; } = (Rune)'━';
 
     /// <summary>Box Drawings Heavy Vertical (U+2503) - ┃</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune VLineHv { get; set; } = (Rune)'┃';
 
     /// <summary>Box Drawings Light Left (U+2574) - ╴</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfLeftLine { get; set; } = (Rune)'╴';
 
     /// <summary>Box Drawings Light Vertical (U+2575) - ╵</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfTopLine { get; set; } = (Rune)'╵';
 
     /// <summary>Box Drawings Light Horizontal (U+2576) - ╶</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfRightLine { get; set; } = (Rune)'╶';
 
     /// <summary>Box Drawings Light Down (U+2577) - ╷</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfBottomLine { get; set; } = (Rune)'╷';
 
     /// <summary>Box Drawings Heavy Left (U+2578) - ╸</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfLeftLineHv { get; set; } = (Rune)'╸';
 
     /// <summary>Box Drawings Heavy Vertical (U+2579) - ╹</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfTopLineHv { get; set; } = (Rune)'╹';
 
     /// <summary>Box Drawings Heavy Horizontal (U+257A) - ╺</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfRightLineHv { get; set; } = (Rune)'╺';
 
     /// <summary>Box Drawings Light Vertical and Horizontal (U+257B) - ╻</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune HalfBottomLineLt { get; set; } = (Rune)'╻';
 
     /// <summary>Box Drawings Light Horizontal and Heavy Horizontal (U+257C) - ╼</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune RightSideLineLtHv { get; set; } = (Rune)'╼';
 
     /// <summary>Box Drawings Light Vertical and Heavy Horizontal (U+257D) - ╽</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune BottomSideLineLtHv { get; set; } = (Rune)'╽';
 
     /// <summary>Box Drawings Heavy Left and Light Horizontal (U+257E) - ╾</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LeftSideLineHvLt { get; set; } = (Rune)'╾';
 
     /// <summary>Box Drawings Heavy Vertical and Light Horizontal (U+257F) - ╿</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune TopSideLineHvLt { get; set; } = (Rune)'╿';
 
     #endregion
@@ -307,35 +237,27 @@ public class GlyphDefinitions
     #region ----------------- Upper Left Corners -----------------
 
     /// <summary>Box Drawings Upper Left Corner - Light Vertical and Light Horizontal (U+250C) - ┌</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCorner { get; set; } = (Rune)'┌';
 
     /// <summary>Box Drawings Upper Left Corner -  Double (U+2554) - ╔</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerDbl { get; set; } = (Rune)'╔';
 
     /// <summary>Box Drawings Upper Left Corner - Light Arc Down and Horizontal (U+256D) - ╭</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerR { get; set; } = (Rune)'╭';
 
     /// <summary>Box Drawings Heavy Down and Horizontal (U+250F) - ┏</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerHv { get; set; } = (Rune)'┏';
 
     /// <summary>Box Drawings Down Heavy and Horizontal Light (U+251E) - ┎</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerHvLt { get; set; } = (Rune)'┎';
 
     /// <summary>Box Drawings Down Light and Horizontal Heavy (U+250D) - ┎</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerLtHv { get; set; } = (Rune)'┍';
 
     /// <summary>Box Drawings Double Down and Single Horizontal (U+2553) - ╓</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerDblSingle { get; set; } = (Rune)'╓';
 
     /// <summary>Box Drawings Single Down and Double Horizontal (U+2552) - ╒</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ULCornerSingleDbl { get; set; } = (Rune)'╒';
 
     #endregion
@@ -343,35 +265,27 @@ public class GlyphDefinitions
     #region ----------------- Lower Left Corners -----------------
 
     /// <summary>Box Drawings Lower Left Corner - Light Vertical and Light Horizontal (U+2514) - └</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCorner { get; set; } = (Rune)'└';
 
     /// <summary>Box Drawings Heavy Vertical and Horizontal (U+2517) - ┗</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerHv { get; set; } = (Rune)'┗';
 
     /// <summary>Box Drawings Heavy Vertical and Horizontal Light (U+2516) - ┖</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerHvLt { get; set; } = (Rune)'┖';
 
     /// <summary>Box Drawings Vertical Light and Horizontal Heavy (U+2511) - ┕</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerLtHv { get; set; } = (Rune)'┕';
 
     /// <summary>Box Drawings Double Vertical and Double Left (U+255A) - ╚</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerDbl { get; set; } = (Rune)'╚';
 
     /// <summary>Box Drawings Single Vertical and Double Left (U+2558) - ╘</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerSingleDbl { get; set; } = (Rune)'╘';
 
     /// <summary>Box Drawings Double Down and Single Left (U+2559) - ╙</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerDblSingle { get; set; } = (Rune)'╙';
 
     /// <summary>Box Drawings Upper Left Corner - Light Arc Down and Left (U+2570) - ╰</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LLCornerR { get; set; } = (Rune)'╰';
 
     #endregion
@@ -379,35 +293,27 @@ public class GlyphDefinitions
     #region ----------------- Upper Right Corners -----------------
 
     /// <summary>Box Drawings Upper Horizontal Corner - Light Vertical and Light Horizontal (U+2510) - ┐</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCorner { get; set; } = (Rune)'┐';
 
     /// <summary>Box Drawings Upper Horizontal Corner - Double Vertical and Double Horizontal (U+2557) - ╗</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerDbl { get; set; } = (Rune)'╗';
 
     /// <summary>Box Drawings Upper Horizontal Corner - Light Arc Vertical and Horizontal (U+256E) - ╮</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerR { get; set; } = (Rune)'╮';
 
     /// <summary>Box Drawings Heavy Down and Left (U+2513) - ┓</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerHv { get; set; } = (Rune)'┓';
 
     /// <summary>Box Drawings Heavy Vertical and Left Down Light (U+2511) - ┑</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerHvLt { get; set; } = (Rune)'┑';
 
     /// <summary>Box Drawings Down Light and Horizontal Heavy (U+2514) - ┒</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerLtHv { get; set; } = (Rune)'┒';
 
     /// <summary>Box Drawings Double Vertical and Single Left (U+2556) - ╖</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerDblSingle { get; set; } = (Rune)'╖';
 
     /// <summary>Box Drawings Single Vertical and Double Left (U+2555) - ╕</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune URCornerSingleDbl { get; set; } = (Rune)'╕';
 
     #endregion
@@ -415,35 +321,27 @@ public class GlyphDefinitions
     #region ----------------- Lower Right Corners -----------------
 
     /// <summary>Box Drawings Lower Right Corner - Light (U+2518) - ┘</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCorner { get; set; } = (Rune)'┘';
 
     /// <summary>Box Drawings Lower Right Corner - Double (U+255D) - ╝</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerDbl { get; set; } = (Rune)'╝';
 
     /// <summary>Box Drawings Lower Right Corner - Rounded (U+256F) - ╯</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerR { get; set; } = (Rune)'╯';
 
     /// <summary>Box Drawings Lower Right Corner - Heavy (U+251B) - ┛</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerHv { get; set; } = (Rune)'┛';
 
     /// <summary>Box Drawings Lower Right Corner - Double Vertical and Single Horizontal (U+255C) - ╜</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerDblSingle { get; set; } = (Rune)'╜';
 
     /// <summary>Box Drawings Lower Right Corner - Single Vertical and Double Horizontal (U+255B) - ╛</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerSingleDbl { get; set; } = (Rune)'╛';
 
     /// <summary>Box Drawings Lower Right Corner - Light Vertical and Heavy Horizontal (U+2519) - ┙</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerLtHv { get; set; } = (Rune)'┙';
 
     /// <summary>Box Drawings Lower Right Corner - Heavy Vertical and Light Horizontal (U+251A) - ┚</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune LRCornerHvLt { get; set; } = (Rune)'┚';
 
     #endregion
@@ -539,31 +437,24 @@ public class GlyphDefinitions
     #region ----------------- Crosses -----------------
 
     /// <summary>Box Drawings Cross - Single Vertical and Single Horizontal (U+253C) - ┼</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune Cross { get; set; } = (Rune)'┼';
 
     /// <summary>Box Drawings Cross - Single Vertical and Double Horizontal (U+256A) - ╪</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CrossDblH { get; set; } = (Rune)'╪';
 
     /// <summary>Box Drawings Cross - Double Vertical and Single Horizontal (U+256B) - ╫</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CrossDblV { get; set; } = (Rune)'╫';
 
     /// <summary>Box Drawings Cross - Double Vertical and Double Horizontal (U+256C) - ╬</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CrossDbl { get; set; } = (Rune)'╬';
 
     /// <summary>Box Drawings Cross - Heavy Horizontal and Light Vertical (U+253F) - ┿</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CrossHvH { get; set; } = (Rune)'┿';
 
     /// <summary>Box Drawings Cross - Light Horizontal and Heavy Vertical (U+2541) - ╂</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CrossHvV { get; set; } = (Rune)'╂';
 
     /// <summary>Box Drawings Cross - Heavy Vertical and Heavy Horizontal (U+254B) - ╋</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune CrossHv { get; set; } = (Rune)'╋';
 
     #endregion
@@ -572,23 +463,18 @@ public class GlyphDefinitions
 
 
     /// <summary>Shadow - Vertical Start - Left Half Block - ▌ U+0258c</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ShadowVerticalStart { get; set; } =  (Rune)'▖'; // Half: '\u2596'  ▖;
 
     /// <summary>Shadow - Vertical - Left Half Block - ▌ U+0258c</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ShadowVertical { get; set; } = (Rune)'▌';
 
     /// <summary>Shadow - Horizontal Start - Upper Half Block - ▀ U+02580</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ShadowHorizontalStart { get; set; } = (Rune)'▝'; // Half: ▝ U+0259d;
 
     /// <summary>Shadow - Horizontal - Upper Half Block - ▀ U+02580</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ShadowHorizontal { get; set; } = (Rune)'▀';
 
     /// <summary>Shadow - Horizontal End - Quadrant Upper Left - ▘ U+02598</summary>
-    [JsonConverter (typeof (RuneJsonConverter))]
     public Rune ShadowHorizontalEnd { get; set; } = (Rune)'▘';
 
     #endregion

+ 0 - 1
Terminal.Gui/Input/Key.cs

@@ -977,7 +977,6 @@ public class Key : EventArgs, IEquatable<Key>
 
     /// <summary>Gets or sets the separator character used when parsing and printing Keys. E.g. Ctrl+A. The default is '+'.</summary>
     [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
-    [JsonConverter (typeof (RuneJsonConverter))]
     public static Rune Separator
     {
         get => _separator;

+ 12 - 1
UnitTests/Configuration/JsonConverterTests.cs

@@ -1,4 +1,5 @@
-using System.Text.Encodings.Web;
+using System.Text;
+using System.Text.Encodings.Web;
 using System.Text.Json;
 using System.Text.Unicode;
 
@@ -341,4 +342,14 @@ public class KeyJsonConverterTests
         // Assert
         Assert.Equal (expectedStringTo, deserializedKey.ToString ());
     }
+
+    [Fact]
+    public void Separator_Property_Serializes_As_Glyph ()
+    {
+        // Act
+        string json = JsonSerializer.Serialize (Key.Separator, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("\"+\"", json);
+    }
 }

+ 76 - 0
UnitTests/Configuration/RuneJsonConverterTests.cs

@@ -67,4 +67,80 @@ public class RunJsonConverterTests
         // Assert
         Assert.Equal (expected, deserialized.ToString ());
     }
+
+    [Fact]
+    public void Printable_Rune_Is_Serialized_As_Glyph ()
+    {
+        // Arrange
+
+        // Act
+        string json = JsonSerializer.Serialize ((Rune)'a', ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("\"a\"", json);
+    }
+
+    [Fact]
+    public void Non_Printable_Rune_Is_Serialized_As_u_Encoded_Value ()
+    {
+        // Arrange
+
+        // Act
+        string json = JsonSerializer.Serialize ((Rune)0x01, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("\"\\u0001\"", json);
+    }
+
+    [Fact]
+    public void Json_With_Glyph_Works ()
+    {
+        // Arrange
+        var json = "\"a\"";
+
+        // Act
+        var deserialized = JsonSerializer.Deserialize<Rune> (json, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("a", deserialized.ToString ());
+    }
+
+    [Fact]
+    public void Json_With_u_Encoded_Works ()
+    {
+        // Arrange
+        var json = "\"\\u0061\"";
+
+        // Act
+        var deserialized = JsonSerializer.Deserialize<Rune> (json, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("a", deserialized.ToString ());
+    }
+
+    [Fact]
+    public void Json_With_U_Encoded_Works ()
+    {
+        // Arrange
+        var json = "\"U+0061\"";
+
+        // Act
+        var deserialized = JsonSerializer.Deserialize<Rune> (json, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("a", deserialized.ToString ());
+    }
+
+    [Fact]
+    public void Json_With_Decimal_Works ()
+    {
+        // Arrange
+        var json = "97";
+
+        // Act
+        var deserialized = JsonSerializer.Deserialize<Rune> (json, ConfigurationManager._serializerOptions);
+
+        // Assert
+        Assert.Equal ("a", deserialized.ToString ());
+    }
 }

+ 1 - 1
UnitTests/Configuration/SerializableConfigurationPropertyTests.cs

@@ -46,7 +46,7 @@ public class SerializableConfigurationPropertyTests
 
         // Ensure no property has the generic JsonStringEnumConverter<>
         EnsureNoSpecifiedConverters (properties, new [] { typeof (JsonStringEnumConverter<>) });
-        //// Ensure no property has the type RuneJsonConverter
+        /// Ensure no property has the type RuneJsonConverter
         //EnsureNoSpecifiedConverters (properties, new [] { typeof (RuneJsonConverter) });
         // Ensure no property has the type KeyJsonConverter
         EnsureNoSpecifiedConverters (properties, new [] { typeof (KeyJsonConverter) });