Charlie Kindel 5 rokov pred
rodič
commit
856287d6dd

+ 3 - 6
Terminal.Gui/Core/TextFormatter.cs

@@ -227,7 +227,7 @@ namespace Terminal.Gui {
 					end -= 1;
 				if (end == start)
 					end = start + width;
-				lines.Add (ustring.Make (runes.GetRange (start, end - start))); //.TrimStart ((rune) => rune == ' '));
+				lines.Add (ustring.Make (runes.GetRange (start, end - start))); 
 				start = end;
 				if (runes[end] == ' ') {
 					start++;
@@ -235,7 +235,7 @@ namespace Terminal.Gui {
 			}
 
 			if (start < text.RuneCount) {
-				lines.Add (ustring.Make (runes.GetRange (start, runes.Count - start))); //.TrimStart ((rune) => rune == ' '));
+				lines.Add (ustring.Make (runes.GetRange (start, runes.Count - start)));
 			}
 
 			return lines;
@@ -286,15 +286,13 @@ namespace Terminal.Gui {
 				return text;
 			}
 
-			// TODO: Use ustring
-			var words = text.Split (ustring.Make (' '));// whitespace, StringSplitOptions.RemoveEmptyEntries);
+			var words = text.Split (ustring.Make (' '));
 			int textCount = words.Sum (arg => arg.RuneCount);
 
 			var spaces = words.Length > 1 ? (width - textCount) / (words.Length - 1) : 0;
 			var extras = words.Length > 1 ? (width - textCount) % words.Length : 0;
 
 			var s = new System.Text.StringBuilder ();
-			//s.Append ($"tc={textCount} sp={spaces},x={extras} - ");
 			for (int w = 0; w < words.Length; w++) {
 				var x = words [w];
 				s.Append (x);
@@ -302,7 +300,6 @@ namespace Terminal.Gui {
 					for (int i = 0; i < spaces; i++)
 						s.Append (spaceChar);
 				if (extras > 0) {
-					//s.Append ('_');
 					extras--;
 				}
 			}

+ 1 - 11
UICatalog/Scenarios/TextFormatterDemo.cs

@@ -10,19 +10,9 @@ namespace UICatalog {
 	[ScenarioCategory ("Text")]
 	[ScenarioCategory ("POC")]
 	class TextFormatterDemo : Scenario {
-		//public override void Init (Toplevel top, ColorScheme colorScheme)
-		//{
-		//	Application.Init ();
-
-		//	Top = top;
-		//	if (Top == null) {
-		//		Top = Application.Top;
-		//	}
-		//	Win = null;
-		//}
-
 		public override void Setup ()
 		{
+			// TODO: Move this to another Scenario that specifically tests `Views` that have no subviews.
 			//Top.Text = "Press CTRL-Q to Quit. This is the Text for the TopLevel View. TextAlignment.Centered was specified. It is intentionally very long to illustrate word wrap.\n" +
 			//	"<-- There is a new line here to show a hard line break. You should see this text bleed underneath the subviews, which start at Y = 3.";
 			//Top.TextAlignment = TextAlignment.Centered;

+ 0 - 2
demo.txt

@@ -1,2 +0,0 @@
-Hello world.
-This is a test of the Emergency Broadcast System.