rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
10.8k stars 562 forks source link

Artefacts on screen #973

Closed chemax closed 5 months ago

chemax commented 5 months ago

My gist Hi. 1) Thank you for great lib. 2) Can someone help me, maybe, please. When I try to recreate table in my grid, I have some artifacts. How I can fix it?

I'm attach my code and video example. Please, help)

https://github.com/rivo/tview/assets/1465506/072590c5-2a77-49f7-a194-6eddeb06374c

digitallyserviced commented 5 months ago

The gist is not a complete runnable. It is difficult to test.

Wrap any screen changes/updates in the app.QueueUpdateDraw(func(){}) handler so that the screen updates happen on the main UI thread and the re-draw is called.

chemax commented 5 months ago

The gist is not a complete runnable. It is difficult to test.

Wrap any screen changes/updates in the app.QueueUpdateDraw(func(){}) handler so that the screen updates happen on the main UI thread and the re-draw is called.

Thank you for help and sorry for my bad example. I will try to create runnable example some later. I was try to execute QueueUpdateDraw, but my app just frozen, when I try it like this:

t.App.QueueUpdateDraw(func() {
grid.AddItem(secretsTable, 1, 1, 1, 1, 0, 100, true)
})
chemax commented 5 months ago

app.Sync() solve my problem. Thank you for tview.

digitallyserviced commented 5 months ago

@chemax

t.App.QueueUpdateDraw(func() {
grid.AddItem(secretsTable, 1, 1, 1, 1, 0, 100, true)
})

If you are locking up when doing this, then make sure you are doing ALL your UI updates in the callback. Instead of say calling it for each additem, make sure you put your for loops inside of the callback.