Browse Source

Use .ReplaceLineEndings() in TextFormatter

Tig 1 year ago
parent
commit
b2cd779c3c

+ 1 - 1
Terminal.Gui/Text/TextFormatter.cs

@@ -579,7 +579,7 @@ public class TextFormatter
     /// </remarks>
     /// </remarks>
     public List<string> GetLines ()
     public List<string> GetLines ()
     {
     {
-        string text = _text!;
+        string text = _text!.ReplaceLineEndings ();
 
 
         // With this check, we protect against subclasses with overrides of Text
         // With this check, we protect against subclasses with overrides of Text
         if (string.IsNullOrEmpty (Text) || ConstrainToWidth is 0 || ConstrainToHeight is 0)
         if (string.IsNullOrEmpty (Text) || ConstrainToWidth is 0 || ConstrainToHeight is 0)

+ 12 - 9
UICatalog/UICatalog.cs

@@ -79,21 +79,24 @@ public class UICatalogApp
     /// <returns></returns>
     /// <returns></returns>
     public static string GetAboutBoxMessage ()
     public static string GetAboutBoxMessage ()
     {
     {
-        // NOTE: Do not use verbatim string here.
+        // NOTE: Do not use multiline verbatim strings here.
         // WSL gets all confused.
         // WSL gets all confused.
         StringBuilder msg = new ();
         StringBuilder msg = new ();
         msg.AppendLine ("UI Catalog: A comprehensive sample library for");
         msg.AppendLine ("UI Catalog: A comprehensive sample library for");
         msg.AppendLine ();
         msg.AppendLine ();
-        msg.AppendLine (@" _______                  _             _   _____       _");
-        msg.AppendLine (@"|__   __|                (_)           | | / ____|     (_)");
-        msg.AppendLine (@"   | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _");
-        msg.AppendLine (@"   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |");
-        msg.AppendLine (@"   | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | |");
-        msg.AppendLine (@"   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|");
+
+        msg.AppendLine ("""
+                         _______                  _             _   _____       _ 
+                        |__   __|                (_)           | | / ____|     (_)
+                           | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _ 
+                           | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |
+                           | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | |
+                           |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|
+                        """);
         msg.AppendLine ();
         msg.AppendLine ();
-        msg.AppendLine (@"v2 - Pre-Alpha");
+        msg.AppendLine ("v2 - Pre-Alpha");
         msg.AppendLine ();
         msg.AppendLine ();
-        msg.AppendLine (@"https://github.com/gui-cs/Terminal.Gui");
+        msg.AppendLine ("https://github.com/gui-cs/Terminal.Gui");
 
 
         return msg.ToString ();
         return msg.ToString ();
     }
     }

+ 3 - 3
UnitTests/Text/TextFormatterTests.cs

@@ -7219,9 +7219,9 @@ B  ")]
         string expectedText = """
         string expectedText = """
                               ******UI Catalog: A comprehensive sample library for******
                               ******UI Catalog: A comprehensive sample library for******
                               **********************************************************
                               **********************************************************
-                               _______                  _             _   _____       _*
+                               _______                  _             _   _____       _ 
                               |__   __|                (_)           | | / ____|     (_)
                               |__   __|                (_)           | | / ____|     (_)
-                                 | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _*
+                                 | | ___ _ __ _ __ ___  _ _ __   __ _| || |  __ _   _ _ 
                                  | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |
                                  | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | || | |_ | | | | |
                                  | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | |
                                  | |  __/ |  | | | | | | | | | | (_| | || |__| | |_| | |
                                  |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|
                                  |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_(_)_____|\__,_|_|
@@ -7232,7 +7232,7 @@ B  ")]
                               **********************************************************
                               **********************************************************
                               """;
                               """;
 
 
-        TestHelpers.AssertDriverContentsAre (expectedText, _output);
+        TestHelpers.AssertDriverContentsAre (expectedText.ReplaceLineEndings (), _output);
 
 
     }
     }
 }
 }