termui icon indicating copy to clipboard operation
termui copied to clipboard

Screen blinking on each refresh

Open miolini opened this issue 9 years ago • 5 comments

Hello! When I refresh data on the screen via ui.Render(...) I see blinking. How can I avoid this?

miolini avatar Jan 12 '16 22:01 miolini

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 ?

ghost avatar Oct 17 '16 16:10 ghost

This bug is still happening.

joesixpack avatar Feb 07 '20 09:02 joesixpack

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

SeungheonOh avatar Jul 24 '20 01:07 SeungheonOh

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.

SeungheonOh avatar Jul 24 '20 04:07 SeungheonOh

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

Reeceeboii avatar Mar 01 '21 23:03 Reeceeboii