aboutsummaryrefslogtreecommitdiff
path: root/ui-terminal.c
diff options
context:
space:
mode:
authorIan Hixson <mujo@sdf.org>2022-12-28 14:52:06 -0800
committerRandy Palamar <palamar@ualberta.ca>2023-08-01 09:56:53 -0600
commitd1f2c277f8594ee7221d820cac5f90eec103feb3 (patch)
tree8d64e20ca9f1a0623ba02d043b271cbdee816426 /ui-terminal.c
parent32e20a2df0fc5d0f61c8292d3f6241476a356476 (diff)
downloadvis-d1f2c277f8594ee7221d820cac5f90eec103feb3.tar.gz
vis-d1f2c277f8594ee7221d820cac5f90eec103feb3.tar.xz
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().
Diffstat (limited to 'ui-terminal.c')
-rw-r--r--ui-terminal.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ui-terminal.c b/ui-terminal.c
index f3b9f04..27afb26 100644
--- a/ui-terminal.c
+++ b/ui-terminal.c
@@ -48,6 +48,7 @@ typedef struct {
CellStyle *styles; /* each window has UI_STYLE_MAX different style definitions */
size_t cells_size; /* #bytes allocated for 2D grid (grows only) */
Cell *cells; /* 2D grid of cells, at least as large as current terminal size */
+ bool doupdate; /* Whether to update the screen after refreshing contents */
} UiTerm;
struct UiTermWin {
@@ -347,6 +348,11 @@ static void ui_arrange(Ui *ui, enum UiLayout layout) {
}
}
+static void ui_doupdates(Ui *ui, bool doupdate) {
+ UiTerm *tui = (UiTerm*)ui;
+ tui->doupdate = doupdate;
+}
+
static void ui_draw(Ui *ui) {
debug("ui-draw\n");
UiTerm *tui = (UiTerm*)ui;
@@ -684,6 +690,7 @@ Ui *ui_term_new(void) {
}
tui->styles_size = styles_size;
tui->styles = styles;
+ tui->doupdate = true;
Ui *ui = (Ui*)tui;
*ui = (Ui) {
.init = ui_init,
@@ -699,6 +706,7 @@ Ui *ui_term_new(void) {
.draw = ui_draw,
.redraw = ui_redraw,
.arrange = ui_arrange,
+ .doupdates = ui_doupdates,
.die = ui_die,
.info = ui_info,
.info_hide = ui_info_hide,