cmd: eliminate flickering with synchronized output

This commit is contained in:
Jeremy Schlatter 2025-02-17 20:01:03 -08:00
parent 5930aaeb1a
commit f9c7ead160
No known key found for this signature in database
GPG Key ID: 4D081B793DF81368

View File

@ -83,11 +83,14 @@ func (p *Progress) render() {
p.mu.Lock()
defer p.mu.Unlock()
// buffer the terminal update to minimize cursor flickering
// https://gitlab.gnome.org/GNOME/vte/-/issues/2837#note_2269501
// buffer output to minimize flickering on all terminals
p.buf.Reset()
defer p.buf.WriteTo(p.w)
// eliminate flickering on terminals that support synchronized output
fmt.Fprint(&p.buf, "\033[?2026h")
defer fmt.Fprint(&p.buf, "\033[?2026l")
fmt.Fprint(&p.buf, "\033[?25l")
defer fmt.Fprint(&p.buf, "\033[?25h")