martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 259 forks source link

Prevent flickering in curses #1061

Closed mujo-hash closed 11 months ago

mujo-hash commented 1 year ago

Reading from curs_refresh(3X) from curses, calling doupdate() repeatedly will cause 'several bursts of output to the screen'. wnoutrefresh() has the smarts to only copy the changed lines to the copied virtual screen, but doupdate() does not.

There have been several bug reports related to flickering but all seems to be inconsistenly reproducible due to different terminal buffering behavior. See #1032, #327

Unfortunately, when I am using a slow display, I still notice flickering, so this commit changes the routines for opening new windows and splitting windows to wait until the last change is finished before calling doupdate().

mujo-hash commented 1 year ago

I've noticed a few rendering bugs with this patch, particularly among themes that use transparency, so I'm not sure it's good enough to merge, but it works well enough for my needs.

erf commented 11 months ago

I've been using vis with this patch with a transparent terminal and seem to work fine for me, but i can't really notice any different in flickering (i don't experience flickering now).

rnpnr commented 11 months ago

Sounds good. I think it also makes sense conceptually to wait until updates are complete before redrawing the window. I've been working in vis for days with multiple windows opening and closing and I haven't noticed any misbehavior so I can't see a reason not to apply this.

rnpnr commented 11 months ago

Applied in d1f2c27, thanks for the patch!

Small tip for next time: put any changes on a separate branch so I can force push to it after rebasing on top of master and Github will automatically close this as merged.