merged latest master

This commit is contained in:
Charlie Kindel
2020-05-27 09:22:42 -06:00
3 changed files with 41 additions and 31 deletions

View File

@@ -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

View File

@@ -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 ()

View File

@@ -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)") {