From d1f2c277f8594ee7221d820cac5f90eec103feb3 Mon Sep 17 00:00:00 2001 From: Ian Hixson Date: Wed, 28 Dec 2022 14:52:06 -0800 Subject: Prevent flickering in curses 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(). --- vis.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 0ffbd39..d374d39 100644 --- a/vis.c +++ b/vis.c @@ -529,6 +529,7 @@ bool vis_window_reload(Win *win) { } bool vis_window_split(Win *original) { + vis_doupdates(original->vis, false); Win *win = window_new_file(original->vis, original->file, UI_OPTION_STATUSBAR); if (!win) return false; @@ -541,6 +542,7 @@ bool vis_window_split(Win *original) { win->file = original->file; view_options_set(win->view, view_options_get(original->view)); view_cursor_to(win->view, view_cursor_get(original->view)); + vis_doupdates(win->vis, true); return true; } @@ -599,15 +601,21 @@ void vis_resume(Vis *vis) { vis->ui->resume(vis->ui); } +void vis_doupdates(Vis *vis, bool doupdate) { + vis->ui->doupdates(vis->ui, doupdate); +} + bool vis_window_new(Vis *vis, const char *filename) { File *file = file_new(vis, filename); if (!file) return false; + vis_doupdates(vis, false); Win *win = window_new_file(vis, file, UI_OPTION_STATUSBAR|UI_OPTION_SYMBOL_EOF); if (!win) { file_free(vis, file); return false; } + vis_doupdates(vis, true); return true; } -- cgit v1.2.3