Merge branch 'develop' into v1_showcase

This commit is contained in:
Tig
2023-09-29 11:18:18 -06:00
committed by GitHub
4 changed files with 40 additions and 14 deletions

View File

@@ -142,6 +142,7 @@ namespace Terminal.Gui {
Curses.raw ();
Curses.noecho ();
Curses.refresh ();
ProcessWinChange ();
}
private void ProcessWinChange ()

View File

@@ -82,7 +82,6 @@ namespace Terminal.Gui {
bool poll_dirty = true;
int [] wakeupPipes = new int [2];
static IntPtr ignore = Marshal.AllocHGlobal (1);
static IntPtr readHandle = Marshal.AllocHGlobal (1);
MainLoop mainLoop;
bool winChanged;
@@ -97,8 +96,8 @@ namespace Terminal.Gui {
{
this.mainLoop = mainLoop;
pipe (wakeupPipes);
AddWatch (wakeupPipes [1], Condition.PollIn, ml => {
read (wakeupPipes [1], ignore, readHandle);
AddWatch (wakeupPipes [0], Condition.PollIn, ml => {
read (wakeupPipes [1], ignore, (IntPtr)1);
return true;
});
}
@@ -176,6 +175,18 @@ namespace Terminal.Gui {
if (mainLoop.timeouts.Count > 0) {
pollTimeout = (int)((mainLoop.timeouts.Keys [0] - now) / TimeSpan.TicksPerMillisecond);
if (pollTimeout < 0) {
// This avoids 'poll' waiting infinitely if 'pollTimeout < 0' until some action is detected
// This can occur after IMainLoopDriver.Wakeup is executed where the pollTimeout is less than 0
// and no event occurred in elapsed time when the 'poll' is start running again.
/*
The 'poll' function in the C standard library uses a signed integer as the timeout argument, where:
- A positive value specifies a timeout in milliseconds.
- A value of 0 means the poll function will return immediately, checking for events and not waiting.
- A value of -1 means the poll function will wait indefinitely until an event occurs or an error occurs.
- A negative value other than -1 typically indicates an error.
*/
pollTimeout = 0;
return true;
}
} else

View File

@@ -5,10 +5,10 @@
// Ross Ferguson (ross.c.ferguson@btinternet.com)
//
using NStack;
using System;
using System.Collections;
using System.Collections.Generic;
using NStack;
namespace Terminal.Gui {
/// <summary>
@@ -39,10 +39,7 @@ namespace Terminal.Gui {
private void Initialize (ComboBox container, bool hideDropdownListOnClick)
{
if (container == null)
throw new ArgumentNullException ("ComboBox container cannot be null.", nameof (container));
this.container = container;
this.container = container ?? throw new ArgumentNullException (nameof(container), "ComboBox container cannot be null.");
HideDropdownListOnClick = hideDropdownListOnClick;
}
@@ -236,7 +233,7 @@ namespace Terminal.Gui {
readonly TextField search;
readonly ComboListView listview;
bool autoHide = true;
int minimumHeight = 2;
readonly int minimumHeight = 2;
/// <summary>
/// Public constructor
@@ -721,7 +718,19 @@ namespace Terminal.Gui {
return text;
}
set {
search.Text = text = value;
SetSearchText (value);
}
}
/// <summary>
/// Current search text
/// </summary>
public ustring SearchText {
get {
return search.Text;
}
set {
SetSearchText (value);
}
}
@@ -775,7 +784,7 @@ namespace Terminal.Gui {
private void Reset (bool keepSearchText = false)
{
if (!keepSearchText) {
search.Text = text = "";
SetSearchText (string.Empty);
}
ResetSearchSet ();
@@ -788,6 +797,11 @@ namespace Terminal.Gui {
}
}
private void SetSearchText (ustring value)
{
search.Text = text = value;
}
private void ResetSearchSet (bool noCopy = false)
{
searchset.Clear ();
@@ -843,7 +857,7 @@ namespace Terminal.Gui {
listview.SetSource (searchset);
listview.Clear (); // Ensure list shrinks in Dialog as you type
listview.Height = CalculatetHeight ();
this.SuperView?.BringSubviewToFront (this);
SuperView?.BringSubviewToFront (this);
}
/// <summary>
@@ -857,7 +871,7 @@ namespace Terminal.Gui {
OnOpenSelectedItem ();
}
var rect = listview.ViewToScreen (listview.Bounds);
Reset (SelectedItem > -1);
Reset (keepSearchText: true);
listview.Clear (rect);
listview.TabStop = false;
SuperView?.SendSubviewToBack (this);

View File

@@ -157,7 +157,7 @@ namespace UICatalog.Scenarios {
LogJob ($"Returned from task Thread:{Thread.CurrentThread.ManagedThreadId} {DateTime.Now}");
_itemsList.SetSource (items);
LogJob ($"Finished populate list view Thread:{Thread.CurrentThread.ManagedThreadId} {DateTime.Now}");
_btnActionCancel.Text = "Load Items";
_btnActionCancel.Text = "Cancelable Load Items";
} else {
LogJob ("Task was canceled!");
}