diff --git a/Terminal.Gui/Core/TextFormatter.cs b/Terminal.Gui/Core/TextFormatter.cs index 724e84f41..6a8512272 100644 --- a/Terminal.Gui/Core/TextFormatter.cs +++ b/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--; } } diff --git a/UICatalog/Scenarios/TextFormatterDemo.cs b/UICatalog/Scenarios/TextFormatterDemo.cs index 1c733df99..f665f8b4a 100644 --- a/UICatalog/Scenarios/TextFormatterDemo.cs +++ b/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; diff --git a/demo.txt b/demo.txt deleted file mode 100644 index b23c047cf..000000000 --- a/demo.txt +++ /dev/null @@ -1,2 +0,0 @@ -Hello world. -This is a test of the Emergency Broadcast System.