From 3f823b4ea646dff82dd7e745567258b0c66bf2df Mon Sep 17 00:00:00 2001 From: Tigger Kindel Date: Wed, 19 Jul 2023 10:23:33 -0600 Subject: [PATCH] Fixed charmap crash --- .../ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs | 1 - UICatalog/Scenarios/CharacterMap.cs | 17 +++++------------ UICatalog/Scenarios/TableEditor.cs | 1 - 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs index 182e58bea0..3d71b1a21f 100644 --- a/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs +++ b/Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs @@ -396,7 +396,6 @@ public static ConsoleKeyInfo [] ResizeArray (ConsoleKeyInfo consoleKeyInfo, Cons public static void DecodeEscSeq (EscSeqRequests escSeqRequests, ref ConsoleKeyInfo newConsoleKeyInfo, ref ConsoleKey key, ConsoleKeyInfo [] cki, ref ConsoleModifiers mod, out string c1Control, out string code, out string [] values, out string terminator, out bool isMouse, out List buttonState, out Point pos, out bool isResponse, Action continuousButtonPressedHandler) { char [] kChars = GetKeyCharArray (cki); - Debug.WriteLine ($"EscSeq: {new string(kChars)}"); (c1Control, code, values, terminator) = GetEscapeResult (kChars); isMouse = false; buttonState = new List () { 0 }; diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 7e89d35f8d..20e46db531 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -11,6 +11,7 @@ using System.Text.Unicode; using System.Threading.Tasks; using Terminal.Gui; +using static Terminal.Gui.SpinnerStyle; using static Terminal.Gui.TableView; namespace UICatalog.Scenarios; @@ -401,22 +402,15 @@ public override void OnDrawContentComplete (Rect contentArea) var x = firstColumnX + COLUMN_WIDTH * col + 1; - //Move (x, y); - //Driver.SetAttribute (GetNormalColor ()); - //Driver.AddRune ('!'); - //Driver.AddRune ('@'); - //Driver.AddRune ('#'); - Move (x, y); if (cursorRow + ContentOffset.Y + 1 == y && cursorCol + ContentOffset.X + firstColumnX + 1 == x && !HasFocus) { Driver.SetAttribute (GetFocusColor ()); } - - var rune = new Rune (val + col); - if (val + col < 0xffff && char.IsSurrogate ((char)(val + col)) || rune.GetColumns() == 0) { - Driver.AddRune (Rune.ReplacementChar); + var scalar = val + col; + if (Rune.IsValid (scalar)) { + Driver.AddRune (new Rune (scalar)); } else { - Driver.AddRune (rune); + Driver.AddRune ((Rune)'?'); } if (cursorRow + ContentOffset.Y + 1 == y && cursorCol + ContentOffset.X + firstColumnX + 1 == x && !HasFocus) { @@ -646,7 +640,6 @@ public static List GetRanges () new UnicodeRange (0x1F130, 0x1F149 ,"Squared Latin Capital Letters"), new UnicodeRange (0x12400, 0x1240f ,"Cuneiform Numbers and Punctuation"), - new UnicodeRange (0x1FA00, 0x1FA0f ,"Chess Symbols"), new UnicodeRange (0x10000, 0x1007F ,"Linear B Syllabary"), new UnicodeRange (0x10080, 0x100FF ,"Linear B Ideograms"), new UnicodeRange (0x10100, 0x1013F ,"Aegean Numbers"), diff --git a/UICatalog/Scenarios/TableEditor.cs b/UICatalog/Scenarios/TableEditor.cs index b392a72f73..d172d59b7a 100644 --- a/UICatalog/Scenarios/TableEditor.cs +++ b/UICatalog/Scenarios/TableEditor.cs @@ -786,7 +786,6 @@ public UnicodeRange (uint start, uint end, string category) new UnicodeRange(0x2b00, 0x2bff,"Miscellaneous Symbols and Arrows"), new UnicodeRange(0xFB00, 0xFb4f,"Alphabetic Presentation Forms"), new UnicodeRange(0x12400, 0x1240f,"Cuneiform Numbers and Punctuation"), - new UnicodeRange(0x1FA00, 0x1FA0f,"Chess Symbols"), new UnicodeRange((uint)(CharMap.MaxCodePoint - 16), (uint)CharMap.MaxCodePoint,"End"), new UnicodeRange (0x0020 ,0x007F ,"Basic Latin"),