Terminal.Gui: Application views do not refresh when the cursor is moved.
Describe the bug Application views do not refresh when the cursor is moved. Affected versions are all above 1.9.0
Screenshots
To Reproduce
using Terminal.Gui;
namespace Test
{
public class Program
{
static readonly List<string> GlobalList = new() { "1" };
static readonly ListView GlobalListView = new() { Width = Dim.Fill(), Height = Dim.Fill() };
static object? _token = null;
static void Main()
{
Application.Init();
var startButton = new Button("Start");
var stopButton = new Button("Stop") { Y = 1 };
var container = new View() { X = Pos.Center(), Y = Pos.Center(), Width = 8, Height = 8, ColorScheme = Colors.Error };
startButton.Clicked += Start;
stopButton.Clicked += Stop;
GlobalListView.SetSource(GlobalList);
container.Add(GlobalListView);
Application.Top.Add(container);
Application.Top.Add(startButton, stopButton);
Application.Run();
return;
}
private static void Start()
{
_token = Application.MainLoop.AddTimeout(TimeSpan.FromMilliseconds(100), Add);
}
private static void Stop()
{
Application.MainLoop.RemoveTimeout(_token);
}
private static bool Add(MainLoop mainLoop)
{
GlobalList.Add(new Random().Next(100).ToString());
GlobalListView.MoveDown();
return true;
}
}
}
Expected behavior Application views should refresh
Desktop MacOS Ventura
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 31
Commits related to this issue
- Fixes #2860. Application views do not refresh when the cursor is moved with CursesDriver. — committed to BDisp/Terminal.Gui by BDisp 9 months ago
- Fixes #2860. Application views do not refresh when the cursor is moved with CursesDriver. — committed to BDisp/Terminal.Gui by BDisp 9 months ago
The bug is still not fixed completly.
No issue with resizing before.
And only
pollTimeout = 0will help when you exit the cursor from terminal. The app will continue to refresh the views.I will also try to reproduce it on Intel Ventura, currently im on Silicon.
After running with #2848, I see no more problem present. Good job @BDisp
This is necessary for waiting a while after a
Esckey is detected to check if it was pressed alone or if it’s part of a escape sequence, likeKey.Homeor mouse event, etc.Well, I think the culprit is the
pollmethod waiting infinitely ifpollTimeout=-1until some action is detected. I did the fix in the #2848. I also did some change to your code: Avoid initialize a view twice because if you useDebug.AssertwithResponder.Instancesto validate all instances it will fail. So, only declare the fields or initialize with all properties or initialize only withnew();and setting the properties in theMain().You don’t need to use the
return;in avoid Main. Instead replace it withApplication.Shutdown();Also for accurating that the timeout action is running on the UI thread, change the
Addmethod to call theApplication.MainLoop.Invoke:I appreciate you can run to check if the issue still persist or not. If it’s fix I’ll also do a commit to the
v2as well. Thanks.Yes, the report list refreshes with no pauses
@BDisp I see a steady stream of ReportMousePosition events getting reported when I move in the same way.