Add support for applications to use synchronized output mode (DECSET

2026) to prevent screen tearing during rapid updates. When an
application sends SM ?2026, tmux buffers output until RM ?2026 is received
or a 1-second timeout expires.

From Chris Lloyd with the assistance of Claude Code, GitHub issue 4744.
This commit is contained in:
nicm
2025-12-17 11:49:29 +00:00
parent ce7eb22e3a
commit 1c7e164c22
7 changed files with 87 additions and 1 deletions

10
input.c
View File

@@ -898,6 +898,8 @@ input_free(struct input_ctx *ictx)
evbuffer_free(ictx->since_ground);
event_del(&ictx->ground_timer);
screen_write_stop_sync(ictx->wp);
free(ictx);
}
@@ -1897,6 +1899,11 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx)
case 2031:
screen_write_mode_clear(sctx, MODE_THEME_UPDATES);
break;
case 2026: /* synchronized output */
screen_write_stop_sync(ictx->wp);
if (ictx->wp != NULL)
ictx->wp->flags |= PANE_REDRAW;
break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
@@ -1995,6 +2002,9 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
case 2031:
screen_write_mode_set(sctx, MODE_THEME_UPDATES);
break;
case 2026: /* synchronized output */
screen_write_start_sync(ictx->wp);
break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;