Skip to content

Commit

Permalink
Fixed charmap crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Jul 19, 2023
1 parent 7569ea7 commit 3f823b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 0 additions & 1 deletion Terminal.Gui/ConsoleDrivers/EscSeqUtils/EscSeqUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MouseFlags> buttonState, out Point pos, out bool isResponse, Action<MouseFlags, Point> continuousButtonPressedHandler)
{
char [] kChars = GetKeyCharArray (cki);
Debug.WriteLine ($"EscSeq: {new string(kChars)}");
(c1Control, code, values, terminator) = GetEscapeResult (kChars);
isMouse = false;
buttonState = new List<MouseFlags> () { 0 };
Expand Down
17 changes: 5 additions & 12 deletions UICatalog/Scenarios/CharacterMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -646,7 +640,6 @@ public static List<UnicodeRange> 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"),
Expand Down
1 change: 0 additions & 1 deletion UICatalog/Scenarios/TableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 3f823b4

Please sign in to comment.