Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Terminal consistently flickers when scrolling through paginated list of options #436

Open
aq17 opened this issue Jul 18, 2022 · 4 comments
Labels

Comments

@aq17
Copy link

aq17 commented Jul 18, 2022

What operating system and terminal are you using?
MacOS+default terminal, also saw same issue on Windows+PowerShell

An example that showcases the bug.
(short clip to fit 10mb limit, but continues as you scroll down the list and paginate)
https://user-images.githubusercontent.com/54565933/179568187-b4d8e098-a23b-4484-b988-ca143dda607a.mov

What did you expect to see?
No flickering when scrolling through paginated list

What did you see instead?
Flickering when scrolling through paginated list

@jquick
Copy link

jquick commented Aug 2, 2022

I have this issue also, using Alacrity terminal

@ekini
Copy link

ekini commented Aug 2, 2022

Same behaviour on Linux (Wayland) in "foot" terminal.

@mislav
Copy link
Collaborator

mislav commented Aug 3, 2022

I also experience this and wanted to find ways to mitigate. This is the redrawing logic:

survey/renderer.go

Lines 135 to 145 in e47352f

func (r *Renderer) resetPrompt(lines int) {
// clean out current line in case tmpl didnt end in newline
cursor := r.NewCursor()
cursor.HorizontalAbsolute(0)
terminal.EraseLine(r.stdio.Out, terminal.ERASE_LINE_ALL)
// clean up what we left behind last time
for i := 0; i < lines; i++ {
cursor.PreviousLine(1)
terminal.EraseLine(r.stdio.Out, terminal.ERASE_LINE_ALL)
}
}

Perhaps there is a way to redraw the last N lines in a terminal in a way that doesn't cause flickering. Ideas welcome!

@dnkl
Copy link

dnkl commented Aug 3, 2022

Perhaps there is a way to redraw the last N lines in a terminal in a way that doesn't cause flickering. Ideas welcome!

There are application synchronized updates: https://gitlab.freedesktop.org/terminal-wg/specifications/-/merge_requests/2

TL;DR application emits one escape at the beginning of a "frame" (update) and another one when done.

Note that there are two variants; the DCS initially suggested in the MR, which was the first one implemented by terminals. Later, it was generally agreed that a "private mode" was better, and the 2026 private mode was added.

Another option is writing the erase commands into a buffer, and doing a single actual terminal write.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants