mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 00:38:00 +01:00
more replace non printable
This commit is contained in:
@@ -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<Rune> ();
|
||||
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 ();
|
||||
|
||||
@@ -171,13 +171,19 @@ namespace Terminal.Gui {
|
||||
int start = 0, end;
|
||||
var lines = new List<ustring> ();
|
||||
|
||||
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<Rune>();
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user