diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index 774d22060d..f5e5ee42c2 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -34,23 +34,23 @@ jobs: - name: Test run: | sed -i 's/"stopOnFail": false/"stopOnFail": true/g' UnitTests/xunit.runner.json - dotnet test --no-restore --verbosity normal --collect:"XPlat Code Coverage" --settings UnitTests/coverlet.runsettings - mv -v UnitTests/TestResults/*/*.* UnitTests/TestResults/ + dotnet test --no-restore --verbosity normal #--collect:"XPlat Code Coverage" --settings UnitTests/coverlet.runsettings + #mv -v UnitTests/TestResults/*/*.* UnitTests/TestResults/ # Note: this step is currently not writing to the gist for some reason - - name: Create Test Coverage Badge - uses: simon-k/dotnet-code-coverage-badge@v1.0.0 - id: create_coverage_badge - with: - label: Unit Test Coverage - color: brightgreen - path: UnitTests/TestResults/coverage.opencover.xml - gist-filename: code-coverage.json - # https://gist.github.com/migueldeicaza/90ef67a684cb71db1817921a970f8d27 - gist-id: 90ef67a684cb71db1817921a970f8d27 - gist-auth-token: ${{ secrets.GIST_AUTH_TOKEN }} + # - name: Create Test Coverage Badge + # uses: simon-k/dotnet-code-coverage-badge@v1.0.0 + # id: create_coverage_badge + # with: + # label: Unit Test Coverage + # color: brightgreen + # path: UnitTests/TestResults/coverage.opencover.xml + # gist-filename: code-coverage.json + # # https://gist.github.com/migueldeicaza/90ef67a684cb71db1817921a970f8d27 + # gist-id: 90ef67a684cb71db1817921a970f8d27 + # gist-auth-token: ${{ secrets.GIST_AUTH_TOKEN }} - - name: Print Code Coverage - run: | - echo "Code coverage percentage: ${{steps.create_coverage_badge.outputs.percentage}}%" - echo "Badge data: ${{steps.create_coverage_badge.outputs.badge}}" + # - name: Print Code Coverage + # run: | + # echo "Code coverage percentage: ${{steps.create_coverage_badge.outputs.percentage}}%" + # echo "Badge data: ${{steps.create_coverage_badge.outputs.badge}}" diff --git a/README.md b/README.md index 978c24ca4b..080c382691 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ ![Terminal.Gui](https://socialify.git.ci/gui-cs/Terminal.Gui/image?description=1&font=Rokkitt&forks=1&language=1&logo=https%3A%2F%2Fraw.githubusercontent.com%2Fgui-cs%2FTerminal.Gui%2Fdevelop%2Fdocfx%2Fimages%2Flogo.png&name=1&owner=1&pattern=Circuit%20Board&stargazers=1&theme=Auto) ![.NET Core](https://github.com/gui-cs/Terminal.Gui/workflows/.NET%20Core/badge.svg?branch=develop) -![Code scanning - action](https://github.com/gui-cs/Terminal.Gui/workflows/Code%20scanning%20-%20action/badge.svg) [![Version](https://img.shields.io/nuget/v/Terminal.Gui.svg)](https://www.nuget.org/packages/Terminal.Gui) ![Code Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/migueldeicaza/90ef67a684cb71db1817921a970f8d27/raw/code-coverage.json) [![Downloads](https://img.shields.io/nuget/dt/Terminal.Gui)](https://www.nuget.org/packages/Terminal.Gui) @@ -34,10 +33,10 @@ dotnet run ## Documentation * [Documentation Home](https://gui-cs.github.io/Terminal.Gui/index.html) -* [Terminal.Gui Overview](https://gui-cs.github.io/Terminal.Gui/articles/overview.html) -* [List of Views/Controls](https://gui-cs.github.io/Terminal.Gui/articles/views.html) -* [Conceptual Documentation](https://gui-cs.github.io/Terminal.Gui/articles/index.html) -* [API Documentation](https://gui-cs.github.io/Terminal.Gui) +* [Terminal.Gui Overview](https://gui-cs.github.io/Terminal.Gui/docs/overview.html) +* [List of Views/Controls](https://gui-cs.github.io/Terminal.Gui/docs/views.html) +* [Conceptual Documentation](https://gui-cs.github.io/Terminal.Gui/docs/index.html) +* [API Documentation](https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui) _The Documentation matches the most recent Nuget release from the `main` branch ([![Version](https://img.shields.io/nuget/v/Terminal.Gui.svg)](https://www.nuget.org/packages/Terminal.Gui))_ diff --git a/ReactiveExample/ReactiveExample.csproj b/ReactiveExample/ReactiveExample.csproj index 0452d960ef..55eaefa28c 100644 --- a/ReactiveExample/ReactiveExample.csproj +++ b/ReactiveExample/ReactiveExample.csproj @@ -10,8 +10,8 @@ 1.14.0-pre.1+Branch.develop.Sha.e0b7464669ef87b96b57f2285200e02bcf85d0e7--> - - + + diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 174abd94bc..c89d433d26 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -2894,9 +2894,14 @@ public virtual bool OnMouseEvent (MouseEvent mouseEvent) return false; } - var args = new MouseEventArgs (mouseEvent); - if (OnMouseClick (args)) - return true; + if ((mouseEvent.Flags & MouseFlags.Button1Clicked) != 0 || (mouseEvent.Flags & MouseFlags.Button2Clicked) != 0 + || (mouseEvent.Flags & MouseFlags.Button3Clicked) != 0 || (mouseEvent.Flags & MouseFlags.Button4Clicked) != 0) { + + var args = new MouseEventArgs (mouseEvent); + if (OnMouseClick (args)) { + return true; + } + } if (MouseEvent (mouseEvent)) return true; diff --git a/Terminal.Gui/Terminal.Gui.csproj b/Terminal.Gui/Terminal.Gui.csproj index 600ab80b3b..94f9582380 100644 --- a/Terminal.Gui/Terminal.Gui.csproj +++ b/Terminal.Gui/Terminal.Gui.csproj @@ -80,7 +80,7 @@ README.md csharp, terminal, c#, f#, gui, toolkit, console, tui Cross platform Terminal UI toolkit for .NET - Miguel de Icaza, Tig Kindel + Tig Kindel A toolkit for building rich console apps for .NET that works on Windows, Mac, and Linux/Unix. Terminal.Gui - Cross platform Terminal User Interface (TUI) toolkit for .NET @@ -100,7 +100,6 @@ true true - Miguel de Icaza, Tig Kindel (@tig), @BDisp True Terminal.Gui.snk diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 3e38092be3..3ccdc03959 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -802,8 +802,6 @@ public override bool MouseEvent (MouseEvent me) selected = top + me.Y; if (AllowsAll ()) { Source.SetMark (SelectedItem, !Source.IsMarked (SelectedItem)); - SetNeedsDisplay (); - return true; } OnSelectedChanged (); SetNeedsDisplay (); @@ -877,7 +875,7 @@ void RenderUstr (ConsoleDriver driver, ustring ustr, int col, int line, int widt /// public void Render (ListView container, ConsoleDriver driver, bool marked, int item, int col, int line, int width, int start = 0) { - var savedClip = container.ClipToBounds(); + var savedClip = container.ClipToBounds (); container.Move (col - start, line); var t = src? [item]; if (t == null) { diff --git a/UICatalog/UICatalog.csproj b/UICatalog/UICatalog.csproj index 666881eae1..d246dd6ea3 100644 --- a/UICatalog/UICatalog.csproj +++ b/UICatalog/UICatalog.csproj @@ -22,7 +22,7 @@ - + diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 48323fb1e2..d88ce47fb6 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -18,15 +18,15 @@ TRACE;DEBUG_IDISPOSABLE - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitTests/Views/ListViewTests.cs b/UnitTests/Views/ListViewTests.cs index 145caf85d0..f705dab25f 100644 --- a/UnitTests/Views/ListViewTests.cs +++ b/UnitTests/Views/ListViewTests.cs @@ -545,5 +545,24 @@ tem 2 tem 3 tem 4", output); } + + [Fact] + public void SelectedItemChanged_Event_Is_Also_Raised_With_AllowsMarking_True_By_Keyboard_Or_Mouse () + { + var itemChanged = 0; + var lv = new ListView (new List () { "Item1", "Item2", "Item3" }) { Width = 5, Height = 3, AllowsMarking = true }; + lv.SelectedItemChanged += (e) => itemChanged = e.Item; + + Assert.Equal (0, lv.SelectedItem); + Assert.Equal (lv.SelectedItem, itemChanged); + + Assert.True (lv.ProcessKey (new KeyEvent (Key.CursorDown, new KeyModifiers()))); + Assert.Equal (1, lv.SelectedItem); + Assert.Equal (lv.SelectedItem, itemChanged); + + Assert.True (lv.MouseEvent (new MouseEvent(){ X = 0, Y = 2, Flags = MouseFlags.Button1Clicked})); + Assert.Equal (2, lv.SelectedItem); + Assert.Equal (lv.SelectedItem, itemChanged); + } } } diff --git a/UnitTests/Views/ViewDisposalTest.cs b/UnitTests/Views/ViewDisposalTest.cs index 177179bab4..95b6cd6238 100644 --- a/UnitTests/Views/ViewDisposalTest.cs +++ b/UnitTests/Views/ViewDisposalTest.cs @@ -7,7 +7,7 @@ using Xunit; using Xunit.Abstractions; -namespace UnitTests.ViewsTests { +namespace Terminal.Gui.ViewTests { public class ViewDisposalTest { diff --git a/UnitTests/Views/ViewTests.cs b/UnitTests/Views/ViewTests.cs index 2f161d9065..dc366989db 100644 --- a/UnitTests/Views/ViewTests.cs +++ b/UnitTests/Views/ViewTests.cs @@ -4581,5 +4581,21 @@ public void View_Instance_Use_Attribute_Normal_On_Draw () 011110 000000", new Attribute [] { Colors.TopLevel.Normal, Colors.TopLevel.Focus }); } + + [Theory] + [InlineData (MouseFlags.Button1Pressed, MouseFlags.Button1Released, MouseFlags.Button1Clicked)] + [InlineData (MouseFlags.Button1Pressed | MouseFlags.ButtonCtrl, MouseFlags.Button1Released | MouseFlags.ButtonCtrl, MouseFlags.Button1Clicked | MouseFlags.ButtonCtrl)] + public void OnMouseClick_Is_Only_Raised_Once (MouseFlags pressed, MouseFlags released, MouseFlags clicked) + { + var mouseClicks = 0; + var view = new View (); + view.MouseClick += (_) => mouseClicks++; + + view.OnMouseEvent (new MouseEvent () { Flags = pressed }); + view.OnMouseEvent (new MouseEvent () { Flags = released }); + view.OnMouseEvent (new MouseEvent () { Flags = clicked }); + + Assert.Equal (1, mouseClicks); + } } }