Skip to content

Commit

Permalink
Merge pull request #1 from migueldeicaza/master
Browse files Browse the repository at this point in the history
update to latest master for scrollbar
  • Loading branch information
tznind authored Jan 23, 2021
2 parents 92c2171 + 77add78 commit 52360cf
Show file tree
Hide file tree
Showing 32 changed files with 2,507 additions and 901 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ You can force the use of `System.Console` on Unix as well; see `Core.cs`.
## Showcase & Examples

* **[UI Catalog](https://github.com/migueldeicaza/gui.cs/tree/master/UICatalog)** - The UI Catalog project provides an easy to use and extend sample illustrating the capabilities of **Terminal.Gui**. Run `dotnet run` in the `UICatalog` directory to run the UI Catalog.
* **[Reactive Example](https://github.com/migueldeicaza/gui.cs/tree/master/ReactiveExample)** - A sample app that shows how to use `System.Reactive` and `ReactiveUI` with `Terminal.Gui`. The app uses the MVVM architecture that may seem familiar to folks coming from WPF, Xamarin Forms, UWP, Avalonia, or Windows Forms. In this app, we implement the data bindings using ReactiveUI `WhenAnyValue` syntax and [Pharmacist](https://github.com/reactiveui/pharmacist) — a tool that converts all events in a NuGet package into observable wrappers.
* **[Reactive Example](https://github.com/migueldeicaza/gui.cs/tree/master/ReactiveExample)** - A sample app that shows how to use `System.Reactive` and `ReactiveUI` with `Terminal.Gui`. The app uses the MVVM architecture that may seem familiar to folks coming from WPF, Xamarin Forms, UWP, Avalonia, or Windows Forms. In this app, we implement the data bindings using ReactiveUI `WhenAnyValue` syntax and [Pharmacist](https://github.com/reactiveui/pharmacist) — a tool that converts all events in a NuGet package into observable wrappers.
* **[Example (aka `demo.cs`)](https://github.com/migueldeicaza/gui.cs/tree/master/Example)** - Run `dotnet run` in the `Example` directory to run the simple demo.
* **[Standalone Example](https://github.com/migueldeicaza/gui.cs/tree/master/StandaloneExample)** - A trivial .NET core sample application can be found in the `StandaloneExample` directory. Run `dotnet run` in directory to test.
* **[F# Example](https://github.com/migueldeicaza/gui.cs/tree/master/FSharpExample)** - An example showing how to build a Terminal.Gui app using F#.
Expand Down Expand Up @@ -185,6 +185,14 @@ The example above shows how to add views using both styles of layout supported b

Use NuGet to install the `Terminal.Gui` NuGet package: https://www.nuget.org/packages/Terminal.Gui

### Installation in .NET Core Projects

To install Terminal.Gui into a .NET Core project, use the `dotnet` CLI tool with following command.

```
dotnet package add Terminal.Gui
```

## Running and Building

* Windows, Mac, and Linux - Build and run using the .NET SDK command line tools (`dotnet build` in the root directory). Run `UICatalog` with `dotnet ./UICatalog/bin/Debug/net5.0/UICatalog.dll` or by directly executing `./UICatalog/bin/Debug/net5.0/UICatalog.exe`.
Expand Down
43 changes: 23 additions & 20 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,24 +269,7 @@ MouseEvent ToDriverMouse (Curses.MouseEvent cev)
}

if ((mouseFlag & MouseFlags.ReportMousePosition) == 0) {
Task.Run (async () => {
while (IsButtonPressed && LastMouseButtonPressed != null) {
await Task.Delay (100);
var me = new MouseEvent () {
X = cev.X,
Y = cev.Y,
Flags = mouseFlag
};

var view = Application.wantContinuousButtonPressedView;
if (view == null)
break;
if (IsButtonPressed && LastMouseButtonPressed != null && (mouseFlag & MouseFlags.ReportMousePosition) == 0) {
mouseHandler (me);
//mainLoop.Driver.Wakeup ();
}
}
});
ProcessContinuousButtonPressedAsync (cev, mouseFlag).ConfigureAwait (false);
}


Expand Down Expand Up @@ -342,7 +325,7 @@ MouseEvent ToDriverMouse (Curses.MouseEvent cev)
};
}

private MouseFlags ProcessButtonClickedEvent (Curses.MouseEvent cev)
MouseFlags ProcessButtonClickedEvent (Curses.MouseEvent cev)
{
LastMouseButtonPressed = cev.ButtonState;
var mf = GetButtonState (cev, true);
Expand All @@ -358,7 +341,7 @@ private MouseFlags ProcessButtonClickedEvent (Curses.MouseEvent cev)
return mf;
}

private MouseFlags ProcessButtonReleasedEvent (Curses.MouseEvent cev)
MouseFlags ProcessButtonReleasedEvent (Curses.MouseEvent cev)
{
var mf = MapCursesButton (cev.ButtonState);
if (!cancelButtonClicked && LastMouseButtonPressed == null && !isReportMousePosition) {
Expand All @@ -371,6 +354,26 @@ private MouseFlags ProcessButtonReleasedEvent (Curses.MouseEvent cev)
return mf;
}

async Task ProcessContinuousButtonPressedAsync (Curses.MouseEvent cev, MouseFlags mouseFlag)
{
while (IsButtonPressed && LastMouseButtonPressed != null) {
await Task.Delay (100);
var me = new MouseEvent () {
X = cev.X,
Y = cev.Y,
Flags = mouseFlag
};

var view = Application.wantContinuousButtonPressedView;
if (view == null)
break;
if (IsButtonPressed && LastMouseButtonPressed != null && (mouseFlag & MouseFlags.ReportMousePosition) == 0) {
mouseHandler (me);
//mainLoop.Driver.Wakeup ();
}
}
}

MouseFlags GetButtonState (Curses.MouseEvent cev, bool pressed = false)
{
MouseFlags mf = default;
Expand Down
1 change: 1 addition & 0 deletions Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandle

keyHandler (new KeyEvent (map, keyModifiers));
keyUpHandler (new KeyEvent (map, keyModifiers));
keyModifiers = new KeyModifiers ();
};
}

Expand Down
Loading

0 comments on commit 52360cf

Please sign in to comment.