termui
termui copied to clipboard
Screen blinking on each refresh
Hello! When I refresh data on the screen via ui.Render(...) I see blinking. How can I avoid this?
I currently have this very same problem. Is there a way to for example "slow down" the number of refreshes commands the ui can receive every second so that there is less stuttering ?
Say a way to make all event handles "inactive" for x milliseconds ?
This bug is still happening.
Maybe by not clearing screen on every render but only clearing widget area might improve on blinking
edit) that is how it is now hmm
Update, I was able to fix blinking entirely. The reason behind it was ui.TerminalDimensions(), or termbox.sync() So, I stored terminal dimension instead of requesting everything.
I have been having this same issue in my project - Pi-CLI. Turns out in my own draw function, I was checking for the terminal dimensions and resizing. This means there was a grid redraw every single time the main draw function was called. This is unnecessary.
Putting all of the resize code into the <Resize>
event and only resizing if a <Resize>
event is received from the uiEvents
channel fixed it for me. No more flickering/flashing.
uiEvents := ui.PollEvents()
for {
select {
case e := <-uiEvents:
switch e.ID {
// respond to terminal resize events
case "<Resize>":
payload := e.Payload.(ui.Resize)
grid.SetRect(0, 0, payload.Width, payload.Height)
ui.Render(grid)
break
}
// refresh event
case <-ticker:
draw() // IN NO WAY RESPONSIBLE FOR RESIZING THE GRID
}
}