From 55c3f3b7a83cf292b6f5ff0b3c655128d16110bd Mon Sep 17 00:00:00 2001 From: Patrik Svensson Date: Tue, 15 Nov 2022 12:25:00 +0100 Subject: [PATCH] Figlet text should not pad on right side automatically --- .../Widgets/Figlet/FigletText.cs | 15 ++++++++++-- ...am.Output_fontfile=poison.flf.verified.txt | 24 +++++++++---------- ....Output_fontfile=starwars.flf.verified.txt | 14 +++++------ .../Widgets/Figlet/Render.Output.verified.txt | 24 +++++++++---------- .../Render_Centered.Output.verified.txt | 12 +++++----- .../Render_LeftAligned.Output.verified.txt | 12 +++++----- .../Figlet/Render_Wrapped.Output.verified.txt | 14 +++++------ 7 files changed, 63 insertions(+), 52 deletions(-) diff --git a/src/Spectre.Console/Widgets/Figlet/FigletText.cs b/src/Spectre.Console/Widgets/Figlet/FigletText.cs index be4ecde9c..ce9f73f59 100644 --- a/src/Spectre.Console/Widgets/Figlet/FigletText.cs +++ b/src/Spectre.Console/Widgets/Figlet/FigletText.cs @@ -16,6 +16,13 @@ public sealed class FigletText : Renderable, IHasJustification /// public Justify? Justification { get; set; } + /// + /// Gets or sets a value indicating whether or not + /// the right side should be padded. + /// + /// Defaults to false. + public bool Pad { get; set; } + /// /// Initializes a new instance of the class. /// @@ -53,7 +60,7 @@ protected override IEnumerable Render(RenderOptions options, int maxWid { yield return line; - if (lineWidth < maxWidth) + if (lineWidth < maxWidth && Pad) { yield return Segment.Padding(maxWidth - lineWidth); } @@ -65,7 +72,11 @@ protected override IEnumerable Render(RenderOptions options, int maxWid yield return Segment.Padding(left); yield return line; - yield return Segment.Padding(right); + + if (Pad) + { + yield return Segment.Padding(right); + } } else if (alignment == Console.Justify.Right) { diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=poison.flf.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=poison.flf.verified.txt index 1235447a0..7b6953771 100644 --- a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=poison.flf.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=poison.flf.verified.txt @@ -1,12 +1,12 @@ - -@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@ @@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@@@@@@ -@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ -@@! @@@ @@! @@@ @@! @@! @@@ @@! @@! !@@ @@! @@! @@! @@! @@@ !@@ @@! @@@ @@! @@! @@@ @@! -!@! @!@ !@! @!@ !@! !@! @!@ !@! !@! @!! !@! !@! !@! !@! @!@ !@! !@! @!@ !@! !@! @!@ !@! -@!@@!@! @!@!@!@! @!! @!@!!@! !!@ @!@@!@! @!! !!@ @!@ @!@!@!@! !!@@!! @!@!@!@! @!!!:! @!@!!@! @!!!:! -!!@!!! !!!@!!!! !!! !!@!@! !!! !!@!!! !@! !!! !@! !!!@!!!! !!@!!! !!!@!!!! !!!!!: !!@!@! !!!!!: -!!: !!: !!! !!: !!: :!! !!: !!: :!! !!: !!: !!: !!: !!! !:! !!: !!! !!: !!: :!! !!: -:!: :!: !:! :!: :!: !:! :!: :!: !:! :!: :!: :!: :!: !:! !:! :!: !:! :!: :!: !:! :!: - :: :: ::: :: :: ::: :: :: ::: :::: :: ::: :: ::: :::: :: :: ::: :: :::: :: ::: :: :::: - : : : : : : : : : : ::: :: : : : : : : :: : : : : : : :: :: : : : : :: :: - + +@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@ @@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@@@@@@ +@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ +@@! @@@ @@! @@@ @@! @@! @@@ @@! @@! !@@ @@! @@! @@! @@! @@@ !@@ @@! @@@ @@! @@! @@@ @@! +!@! @!@ !@! @!@ !@! !@! @!@ !@! !@! @!! !@! !@! !@! !@! @!@ !@! !@! @!@ !@! !@! @!@ !@! +@!@@!@! @!@!@!@! @!! @!@!!@! !!@ @!@@!@! @!! !!@ @!@ @!@!@!@! !!@@!! @!@!@!@! @!!!:! @!@!!@! @!!!:! +!!@!!! !!!@!!!! !!! !!@!@! !!! !!@!!! !@! !!! !@! !!!@!!!! !!@!!! !!!@!!!! !!!!!: !!@!@! !!!!!: +!!: !!: !!! !!: !!: :!! !!: !!: :!! !!: !!: !!: !!: !!! !:! !!: !!! !!: !!: :!! !!: +:!: :!: !:! :!: :!: !:! :!: :!: !:! :!: :!: :!: :!: !:! !:! :!: !:! :!: :!: !:! :!: + :: :: ::: :: :: ::: :: :: ::: :::: :: ::: :: ::: :::: :: :: ::: :: :::: :: ::: :: :::: + : : : : : : : : : : ::: :: : : : : : : :: : : : : : : :: :: : : : : :: :: + diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=starwars.flf.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=starwars.flf.verified.txt index 76aff34b6..e25eb5864 100644 --- a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=starwars.flf.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Load_Stream.Output_fontfile=starwars.flf.verified.txt @@ -1,7 +1,7 @@ -.______ ___ .___________..______ __ __ ___ ____ __ ____ ___ _______. __ __ _______ .______ _______ -| _ \ / \ | || _ \ | | | |/ / \ \ / \ / / / \ / | | | | | | ____|| _ \ | ____| -| |_) | / ^ \ `---| |----`| |_) | | | | ' / \ \/ \/ / / ^ \ | (----` | |__| | | |__ | |_) | | |__ -| ___/ / /_\ \ | | | / | | | < \ / / /_\ \ \ \ | __ | | __| | / | __| -| | / _____ \ | | | |\ \----.| | | . \ \ /\ / / _____ \ .----) | | | | | | |____ | |\ \----.| |____ -| _| /__/ \__\ |__| | _| `._____||__| |__|\__\ \__/ \__/ /__/ \__\ |_______/ |__| |__| |_______|| _| `._____||_______| - +.______ ___ .___________..______ __ __ ___ ____ __ ____ ___ _______. __ __ _______ .______ _______ +| _ \ / \ | || _ \ | | | |/ / \ \ / \ / / / \ / | | | | | | ____|| _ \ | ____| +| |_) | / ^ \ `---| |----`| |_) | | | | ' / \ \/ \/ / / ^ \ | (----` | |__| | | |__ | |_) | | |__ +| ___/ / /_\ \ | | | / | | | < \ / / /_\ \ \ \ | __ | | __| | / | __| +| | / _____ \ | | | |\ \----.| | | . \ \ /\ / / _____ \ .----) | | | | | | |____ | |\ \----.| |____ +| _| /__/ \__\ |__| | _| `._____||__| |__|\__\ \__/ \__/ /__/ \__\ |_______/ |__| |__| |_______|| _| `._____||_______| + diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render.Output.verified.txt index 3e813831b..a3bbd711c 100644 --- a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render.Output.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render.Output.verified.txt @@ -1,12 +1,12 @@ - ____ _ _ _ - | _ \ __ _ | |_ _ __ (_) | | __ __ __ __ _ ___ - | |_) | / _` | | __| | '__| | | | |/ / \ \ /\ / / / _` | / __| - | __/ | (_| | | |_ | | | | | < \ V V / | (_| | \__ \ - |_| \__,_| \__| |_| |_| |_|\_\ \_/\_/ \__,_| |___/ - - _ - | |__ ___ _ __ ___ - | '_ \ / _ \ | '__| / _ \ - | | | | | __/ | | | __/ - |_| |_| \___| |_| \___| - + ____ _ _ _ + | _ \ __ _ | |_ _ __ (_) | | __ __ __ __ _ ___ + | |_) | / _` | | __| | '__| | | | |/ / \ \ /\ / / / _` | / __| + | __/ | (_| | | |_ | | | | | < \ V V / | (_| | \__ \ + |_| \__,_| \__| |_| |_| |_|\_\ \_/\_/ \__,_| |___/ + + _ + | |__ ___ _ __ ___ + | '_ \ / _ \ | '__| / _ \ + | | | | | __/ | | | __/ + |_| |_| \___| |_| \___| + diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Centered.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Centered.Output.verified.txt index af87b25f1..13236c45a 100644 --- a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Centered.Output.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Centered.Output.verified.txt @@ -1,6 +1,6 @@ - ____ _ ____ _ - / ___| _ __ ___ ___ | |_ _ __ ___ / ___| ___ _ __ ___ ___ | | ___ - \___ \ | '_ \ / _ \ / __| | __| | '__| / _ \ | | / _ \ | '_ \ / __| / _ \ | | / _ \ - ___) | | |_) | | __/ | (__ | |_ | | | __/ _ | |___ | (_) | | | | | \__ \ | (_) | | | | __/ - |____/ | .__/ \___| \___| \__| |_| \___| (_) \____| \___/ |_| |_| |___/ \___/ |_| \___| - |_| + ____ _ ____ _ + / ___| _ __ ___ ___ | |_ _ __ ___ / ___| ___ _ __ ___ ___ | | ___ + \___ \ | '_ \ / _ \ / __| | __| | '__| / _ \ | | / _ \ | '_ \ / __| / _ \ | | / _ \ + ___) | | |_) | | __/ | (__ | |_ | | | __/ _ | |___ | (_) | | | | | \__ \ | (_) | | | | __/ + |____/ | .__/ \___| \___| \__| |_| \___| (_) \____| \___/ |_| |_| |___/ \___/ |_| \___| + |_| diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_LeftAligned.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_LeftAligned.Output.verified.txt index 702c7865f..21bfd2bcb 100644 --- a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_LeftAligned.Output.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_LeftAligned.Output.verified.txt @@ -1,6 +1,6 @@ - ____ _ ____ _ - / ___| _ __ ___ ___ | |_ _ __ ___ / ___| ___ _ __ ___ ___ | | ___ - \___ \ | '_ \ / _ \ / __| | __| | '__| / _ \ | | / _ \ | '_ \ / __| / _ \ | | / _ \ - ___) | | |_) | | __/ | (__ | |_ | | | __/ _ | |___ | (_) | | | | | \__ \ | (_) | | | | __/ - |____/ | .__/ \___| \___| \__| |_| \___| (_) \____| \___/ |_| |_| |___/ \___/ |_| \___| - |_| + ____ _ ____ _ + / ___| _ __ ___ ___ | |_ _ __ ___ / ___| ___ _ __ ___ ___ | | ___ + \___ \ | '_ \ / _ \ / __| | __| | '__| / _ \ | | / _ \ | '_ \ / __| / _ \ | | / _ \ + ___) | | |_) | | __/ | (__ | |_ | | | __/ _ | |___ | (_) | | | | | \__ \ | (_) | | | | __/ + |____/ | .__/ \___| \___| \__| |_| \___| (_) \____| \___/ |_| |_| |___/ \___/ |_| \___| + |_| diff --git a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Wrapped.Output.verified.txt b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Wrapped.Output.verified.txt index 7fa6180c3..7e9272dad 100644 --- a/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Wrapped.Output.verified.txt +++ b/test/Spectre.Console.Tests/Expectations/Widgets/Figlet/Render_Wrapped.Output.verified.txt @@ -1,12 +1,12 @@ - ____ _ ____ + ____ _ ____ / ___| _ __ ___ ___ | |_ _ __ ___ / ___| ___ \___ \ | '_ \ / _ \ / __| | __| | '__| / _ \ | | / _ \ ___) | | |_) | | __/ | (__ | |_ | | | __/ _ | |___ | (_) | |____/ | .__/ \___| \___| \__| |_| \___| (_) \____| \___/ |_| - _ - _ __ ___ ___ | | ___ - | '_ \ / __| / _ \ | | / _ \ - | | | | \__ \ | (_) | | | | __/ - |_| |_| |___/ \___/ |_| \___| - + _ + _ __ ___ ___ | | ___ + | '_ \ / __| / _ \ | | / _ \ + | | | | \__ \ | (_) | | | | __/ + |_| |_| |___/ \___/ |_| \___| +