Bläddra i källkod

backed out button

Charlie Kindel 5 år sedan
förälder
incheckning
ac3a2e8cb2
2 ändrade filer med 14 tillägg och 33 borttagningar
  1. 0 15
      Terminal.Gui/Views/Button.cs
  2. 14 18
      Terminal.Gui/Views/Label.cs

+ 0 - 15
Terminal.Gui/Views/Button.cs

@@ -6,7 +6,6 @@
 //
 
 using System;
-using System.Collections.Generic;
 using NStack;
 
 namespace Terminal.Gui {
@@ -167,20 +166,6 @@ 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 ();

+ 14 - 18
Terminal.Gui/Views/Label.cs

@@ -166,23 +166,24 @@ namespace Terminal.Gui {
 			Recalc (text, lines, Frame.Width, textAlignment, Bounds.Height > 1);
 		}
 
+		static 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); ;
+		}
+
 		static List<ustring> WordWrap (ustring text, int margin)
 		{
 			int start = 0, end;
 			var lines = new List<ustring> ();
 
-			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) {
@@ -207,12 +208,7 @@ namespace Terminal.Gui {
 			lineResult.Clear ();
 
 			if (wordWrap == false) {
-				textStr = textStr.Replace ("\f", " ")
-				.Replace ("\n", " ")
-				.Replace ("\r", " ")
-				.Replace ("\t", " ")
-				.Replace ("\v", " ")
-				.TrimSpace ();
+				textStr = ReplaceNonPrintables (textStr);
 				lineResult.Add (ClipAndJustify (textStr, width, talign));
 				return;
 			}