From 6ee48f51ce6b3736f38fbc3ed9a8c5590f2b2a63 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov <74899441+aleks-ivanov@users.noreply.github.com> Date: Tue, 15 Jun 2021 14:39:53 +0300 Subject: [PATCH 1/7] Create Codespace configuration (#2) --- .devcontainer/devcontainer.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..98314c1e3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "Terminal.Gui Codespace", + "image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0.201.7-5.0", + "extensions": [ + "eamodio.gitlens", + "ms-dotnettools.csharp", + "VisualStudioExptTeam.vscodeintellicode", + "ms-vscode.powershell", + "cschleiden.vscode-github-actions", + "redhat.vscode-yaml", + "bierner.markdown-preview-github-styles", + "ban.spellright", + "jmrog.vscode-nuget-package-manager", + "coenraads.bracket-pair-colorizer", + "vscode-icons-team.vscode-icons", + "editorconfig.editorconfig" + ], + "postCreateCommand": "dotnet restore && dotnet build --configuration Release --no-restore && dotnet test --no-restore --verbosity normal --collect:'XPlat Code Coverage' --settings UnitTests/coverlet.runsettings", +} \ No newline at end of file From a366e57e08e62b1bde2f39c17dc37fca74cff8a5 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov <74899441+aleks-ivanov@users.noreply.github.com> Date: Tue, 15 Jun 2021 15:13:40 +0300 Subject: [PATCH 2/7] add pwsh as default terminal --- .devcontainer/devcontainer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 98314c1e3..d510d83d1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,9 @@ { "name": "Terminal.Gui Codespace", "image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0.201.7-5.0", + "settings": { + "terminal.integrated.defaultProfile.linux": "pwsh" + }, "extensions": [ "eamodio.gitlens", "ms-dotnettools.csharp", @@ -16,4 +19,4 @@ "editorconfig.editorconfig" ], "postCreateCommand": "dotnet restore && dotnet build --configuration Release --no-restore && dotnet test --no-restore --verbosity normal --collect:'XPlat Code Coverage' --settings UnitTests/coverlet.runsettings", -} \ No newline at end of file +} From cf19eb8e8e47e1ab32a3ba4031aa69d6a2dbfa4f Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov <74899441+aleks-ivanov@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:21:42 +0300 Subject: [PATCH 3/7] add explicit configuration to test command --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d510d83d1..ef70ae95b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,5 +18,5 @@ "vscode-icons-team.vscode-icons", "editorconfig.editorconfig" ], - "postCreateCommand": "dotnet restore && dotnet build --configuration Release --no-restore && dotnet test --no-restore --verbosity normal --collect:'XPlat Code Coverage' --settings UnitTests/coverlet.runsettings", + "postCreateCommand": "dotnet restore && dotnet build --configuration Release --no-restore && dotnet test --configuration Debug --no-restore --verbosity normal --collect:'XPlat Code Coverage' --settings UnitTests/coverlet.runsettings", } From 5680812f6e79746f643fb6f0454c5098b26dc259 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov <74899441+aleks-ivanov@users.noreply.github.com> Date: Tue, 15 Jun 2021 17:13:07 +0300 Subject: [PATCH 4/7] add credentials --- .devcontainer/devcontainer.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ef70ae95b..2d4f2dce7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,3 +20,5 @@ ], "postCreateCommand": "dotnet restore && dotnet build --configuration Release --no-restore && dotnet test --configuration Debug --no-restore --verbosity normal --collect:'XPlat Code Coverage' --settings UnitTests/coverlet.runsettings", } + +// Built with ❤ by [Pipeline Foundation](https://pipeline.foundation) From 565e58880a71c764a99c6b4ebe0e6a51986ebce8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Jun 2021 14:07:54 +0000 Subject: [PATCH 5/7] Bump ReportGenerator from 4.8.9 to 4.8.10 Bumps [ReportGenerator](https://github.com/danielpalme/ReportGenerator) from 4.8.9 to 4.8.10. - [Release notes](https://github.com/danielpalme/ReportGenerator/releases) - [Commits](https://github.com/danielpalme/ReportGenerator/compare/v4.8.9...v4.8.10) --- updated-dependencies: - dependency-name: ReportGenerator dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- UnitTests/UnitTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index cf72fc76f..7c9428e50 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -16,7 +16,7 @@ - + From 21714b64b8bcf9d95c0956cc0cc257db0cba1f3a Mon Sep 17 00:00:00 2001 From: BDisp Date: Fri, 18 Jun 2021 18:34:16 +0100 Subject: [PATCH 6/7] Fixes #1341. Now if AutoSize is true the Bounds size is always updated by using the Dim.Fill or the Dim.Absolute. --- Terminal.Gui/Core/View.cs | 10 +++++--- UnitTests/GraphViewTests.cs | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 4104b2a59..f721feedf 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -1988,8 +1988,10 @@ namespace Terminal.Gui { get => textFormatter.Text; set { textFormatter.Text = value; - ResizeView (autoSize); - if (textFormatter.Size != Bounds.Size) { + var canResize = ResizeView (autoSize); + if (canResize && textFormatter.Size != Bounds.Size) { + Bounds = new Rect (new Point (Bounds.X, Bounds.Y), textFormatter.Size); + } else if (!canResize && textFormatter.Size != Bounds.Size) { textFormatter.Size = Bounds.Size; } SetNeedsLayout (); @@ -2085,7 +2087,9 @@ namespace Terminal.Gui { var aSize = autoSize; Rect nBounds = TextFormatter.CalcRect (Bounds.X, Bounds.Y, Text, textFormatter.Direction); - + if (textFormatter.Size != nBounds.Size) { + textFormatter.Size = nBounds.Size; + } if ((textFormatter.Size != Bounds.Size || textFormatter.Size != nBounds.Size) && (((width == null || width is Dim.DimAbsolute) && (Bounds.Width == 0 || autoSize && Bounds.Width != nBounds.Width)) diff --git a/UnitTests/GraphViewTests.cs b/UnitTests/GraphViewTests.cs index 0dde704a1..51273a981 100644 --- a/UnitTests/GraphViewTests.cs +++ b/UnitTests/GraphViewTests.cs @@ -1382,6 +1382,56 @@ namespace Terminal.Gui.Views { // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown (); } + + [Theory] + [InlineData (true)] + [InlineData (false)] + public void LabelChangeText_RendersCorrectly (bool useFill) + { + var driver = new FakeDriver (); + Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true))); + driver.Init (() => { }); + + // create a wide window + var mount = new View () { + Width = 100, + Height = 100 + }; + + try { + // Create a label with a short text + var lbl1 = new Label ("ff"); + + // Specify that the label should be very wide + if (useFill) { + lbl1.Width = Dim.Fill (); + } else { + lbl1.Width = 100; + } + + //put label into view + mount.Add (lbl1); + + // render view + lbl1.ColorScheme = new ColorScheme (); + Assert.Equal (1, lbl1.Height); + mount.Redraw (mount.Bounds); + + // should have the initial text + GraphViewTests.AssertDriverContentsAre ("ff", null); + + // change the text and redraw + lbl1.Text = "ff1234"; + mount.Redraw (mount.Bounds); + + // should have the new text rendered + GraphViewTests.AssertDriverContentsAre ("ff1234", null); + + + } finally { + Application.Shutdown (); + } + } } public class AxisIncrementToRenderTests { From a9d8ff19d8c02f342c91f7ab5cde83efb9a8df7d Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 19 Jun 2021 00:26:57 +0100 Subject: [PATCH 7/7] Fixes #1344. Setting showBothScrollIndicator to false on the constructor don't throws NullReferenceException anymore. --- Terminal.Gui/Views/ScrollBarView.cs | 10 ++-- UnitTests/ScrollBarViewTests.cs | 75 ++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/Terminal.Gui/Views/ScrollBarView.cs b/Terminal.Gui/Views/ScrollBarView.cs index 1b7a15205..c89070783 100644 --- a/Terminal.Gui/Views/ScrollBarView.cs +++ b/Terminal.Gui/Views/ScrollBarView.cs @@ -298,11 +298,15 @@ namespace Terminal.Gui { } var pending = CheckBothScrollBars (this); - CheckBothScrollBars (otherScrollBarView, pending); + if (otherScrollBarView != null) { + CheckBothScrollBars (otherScrollBarView, pending); + } SetWidthHeight (); SetRelativeLayout (Bounds); - OtherScrollBarView.SetRelativeLayout (OtherScrollBarView.Bounds); + if (otherScrollBarView != null) { + OtherScrollBarView.SetRelativeLayout (OtherScrollBarView.Bounds); + } if (showBothScrollIndicator) { if (contentBottomRightCorner != null) { @@ -321,7 +325,7 @@ namespace Terminal.Gui { if (showScrollIndicator) { Redraw (Bounds); } - if (otherScrollBarView.showScrollIndicator) { + if (otherScrollBarView != null && otherScrollBarView.showScrollIndicator) { otherScrollBarView.Redraw (otherScrollBarView.Bounds); } } diff --git a/UnitTests/ScrollBarViewTests.cs b/UnitTests/ScrollBarViewTests.cs index 7cda55699..36fccd7c8 100644 --- a/UnitTests/ScrollBarViewTests.cs +++ b/UnitTests/ScrollBarViewTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using Xunit; @@ -6,7 +7,7 @@ using Xunit; namespace Terminal.Gui.Views { public class ScrollBarViewTests { - // This class enables test functions annoated with the [InitShutdown] attribute + // This class enables test functions annotated with the [InitShutdown] attribute // to have a function called before the test function is called and after. // // This is necessary because a) Application is a singleton and Init/Shutdown must be called @@ -55,7 +56,7 @@ namespace Terminal.Gui.Views { private static HostView _hostView; private ScrollBarView _scrollBar; - private bool _added; + private bool _added; private void AddHandlers () { @@ -444,5 +445,75 @@ namespace Terminal.Gui.Views { Assert.Equal ("Dim.Absolute(1)", _scrollBar.OtherScrollBarView.Height.ToString ()); Assert.Equal (1, _scrollBar.OtherScrollBarView.Bounds.Height); } + + [Fact] + public void Constructor_ShowBothScrollIndicator_False_Refresh_Does_Not_Throws_An_Object_Null_Exception () + { + var exception = Record.Exception (() => { + Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true))); + + var top = Application.Top; + + var win = new Window () { + X = 0, + Y = 0, + Width = Dim.Fill (), + Height = Dim.Fill () + }; + + List source = new List (); + + for (int i = 0; i < 50; i++) { + source.Add ($"item {i}"); + } + + var listView = new ListView (source) { + X = 0, + Y = 0, + Width = Dim.Fill (), + Height = Dim.Fill () + }; + win.Add (listView); + + var newScrollBarView = new ScrollBarView (listView, true, false) { + KeepContentAlwaysInViewport = true + }; + win.Add (newScrollBarView); + + newScrollBarView.ChangedPosition += () => { + listView.TopItem = newScrollBarView.Position; + if (listView.TopItem != newScrollBarView.Position) { + newScrollBarView.Position = listView.TopItem; + } + Assert.Equal (newScrollBarView.Position, listView.TopItem); + listView.SetNeedsDisplay (); + }; + + listView.DrawContent += (e) => { + newScrollBarView.Size = listView.Source.Count - 1; + Assert.Equal (newScrollBarView.Size, listView.Source.Count); + newScrollBarView.Position = listView.TopItem; + Assert.Equal (newScrollBarView.Position, listView.TopItem); + newScrollBarView.Refresh (); + }; + + top.Ready += () => { + newScrollBarView.Position = 45; + Assert.Equal (newScrollBarView.Position, newScrollBarView.Size - listView.TopItem + (listView.TopItem - listView.Bounds.Height)); + Assert.Equal (newScrollBarView.Position, listView.TopItem); + Assert.Equal (27, newScrollBarView.Position); + Assert.Equal (27, listView.TopItem); + Application.RequestStop (); + }; + + top.Add (win); + + Application.Run (); + + Application.Shutdown (); + + }); + Assert.Null (exception); + } } }