diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs index b9e475338..39fef2f89 100644 --- a/Terminal.Gui/Views/Button.cs +++ b/Terminal.Gui/Views/Button.cs @@ -6,6 +6,7 @@ // using System; +using System.Collections.Generic; using NStack; namespace Terminal.Gui { @@ -166,6 +167,20 @@ namespace Terminal.Gui { else shown_text = ustring.Make (_leftBracket) + " " + text + " " + ustring.Make (_rightBracket); + ustring ReplaceNonPrintables (ustring str) + { + var runes = new List (); + foreach (var r in str.ToRunes ()) { + if (r < 0x20) { + runes.Add (new Rune (r + 0x2400)); // U+25A1 □ WHITE SQUARE + } else { + runes.Add (r); + } + } + return ustring.Make (runes); ; + } + shown_text = ReplaceNonPrintables (text); + shown_text = GetTextFromHotKey (shown_text, '_', out hot_pos, out hot_key); SetNeedsDisplay (); diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs index 096b1c511..e93a01ae0 100644 --- a/Terminal.Gui/Views/Label.cs +++ b/Terminal.Gui/Views/Label.cs @@ -171,13 +171,19 @@ namespace Terminal.Gui { int start = 0, end; var lines = new List (); - text = text - .Replace ("\f", "\u21a1") // U+21A1 ↡ DOWNWARDS TWO HEADED ARROW - .Replace ("\n", "\u240a") // U+240A (SYMBOL FOR LINE FEED, ␊) - .Replace ("\r", "\u240d") // U+240D (SYMBOL FOR CARRIAGE RETURN, ␍) - .Replace ("\t", "\u2409") // U+2409 ␉ SYMBOL FOR HORIZONTAL TABULATION - .Replace ("\v", "\u240b") // U+240B ␋ SYMBOL FOR VERTICAL TABULATION - .TrimSpace (); + ustring ReplaceNonPrintables (ustring str) + { + var runes = new List(); + foreach (var r in str.ToRunes()) { + if (r < 0x20) { + runes.Add(new Rune (r + 0x2400)); // U+25A1 □ WHITE SQUARE + } else { + runes.Add(r); + } + } + return ustring.Make (runes); ; + } + text = ReplaceNonPrintables (text); while ((end = start + margin) < text.Length) { while (text [end] != ' ' && end > start)