diff --git a/README.md b/README.md index aca3821be..c0424f750 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ Use NuGet to install the `Terminal.Gui` NuGet package: https://www.nuget.org/pac ## Running and Building -* *`Terminal.Gui`* - Build and run using the .NET SDK command line tools (`doetnet build` in the root directory) or with Visual Studio 2019. +* *`Terminal.Gui`* - Build and run using the .NET SDK command line tools (`dotnet build` in the root directory) or with Visual Studio 2019. ## Contributing diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs index 1db1383cb..a9da8d9f0 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs @@ -166,11 +166,36 @@ namespace Terminal.Gui { } } + bool IMainLoopDriver.EventsPending (bool wait) + { + int pollTimeout = 0; + int n; + + if (CkeckTimeout (wait, ref pollTimeout)) + return true; + + UpdatePollMap (); + + while (true) { + n = poll (pollmap, (uint)pollmap.Length, 0); + if (n > 0) { + break; + } + if (mainLoop.idleHandlers.Count > 0 || CkeckTimeout (wait, ref pollTimeout)) { + return true; + } + } + int ic; + lock (mainLoop.idleHandlers) + ic = mainLoop.idleHandlers.Count; + return n > 0 || mainLoop.timeouts.Count > 0 && ((mainLoop.timeouts.Keys [0] - DateTime.UtcNow.Ticks) < 0) || ic > 0; + } + + bool CkeckTimeout (bool wait, ref int pollTimeout) { long now = DateTime.UtcNow.Ticks; - int pollTimeout, n; if (mainLoop.timeouts.Count > 0) { pollTimeout = (int)((mainLoop.timeouts.Keys [0] - now) / TimeSpan.TicksPerMillisecond); if (pollTimeout < 0) @@ -182,24 +207,7 @@ namespace Terminal.Gui { if (!wait) pollTimeout = 0; - UpdatePollMap (); - - while (true) { - if (wait && pollTimeout == -1) { - pollTimeout = 0; - } - n = poll (pollmap, (uint)pollmap.Length, pollTimeout); - if (n > 0) { - break; - } - if (mainLoop.timeouts.Count > 0 || mainLoop.idleHandlers.Count > 0) { - return true; - } - } - int ic; - lock (mainLoop.idleHandlers) - ic = mainLoop.idleHandlers.Count; - return n > 0 || mainLoop.timeouts.Count > 0 && ((mainLoop.timeouts.Keys [0] - DateTime.UtcNow.Ticks) < 0) || ic > 0; + return false; } void IMainLoopDriver.MainIteration () diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index d5aecf6e3..3c53b7bf0 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -36,19 +36,21 @@ namespace UICatalog { // Demonstrate using Dim to create a vertical ruler that always measures the parent window's height // TODO: Either build a custom control for this or implement linewrap in Label #352 - //var verticalRuler = new Label ("") { - // X = 0, - // Y = 0, - // Width = 1, - // Height = Dim.Fill (), - // ColorScheme = Colors.Error - //}; + const string vrule = "|\n1\n2\n3\n4\n5\n6\n7\n8\n9\n"; - //Application.OnResized += () => { - // verticalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height)]; - //}; + var verticalRuler = new Label ("") { + X = 0, + Y = 0, + Width = 1, + Height = Dim.Fill (), + ColorScheme = Colors.Error + }; - //Win.Add (verticalRuler); + Application.Resized += (sender, a) => { + verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height*2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height*2)]; + }; + + Win.Add (verticalRuler); // Demonstrate At - Absolute Layout using Pos var absoluteButton = new Button ("Absolute At(2,1)") {