Merge branch 'master' into command_parser

This commit is contained in:
Nicholas Marriott
2026-07-01 12:51:34 +01:00
2 changed files with 36 additions and 21 deletions

View File

@@ -214,6 +214,20 @@ screen_write_pane_is_obscured(struct screen_write_ctx *ctx)
return (0); return (0);
} }
/* Should we draw to TTY for this screen? */
static int
screen_write_should_draw(struct screen_write_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
struct screen *s = ctx->s;
if (s->mode & MODE_SYNC)
return (0);
if (wp != NULL && (wp->flags & (PANE_REDRAW|PANE_DROP)))
return (0);
return (1);
}
/* Set up context for TTY command. */ /* Set up context for TTY command. */
static void static void
screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx,
@@ -1021,7 +1035,7 @@ screen_write_start_sync(struct window_pane *wp)
void void
screen_write_stop_sync(struct window_pane *wp) screen_write_stop_sync(struct window_pane *wp)
{ {
if (wp == NULL) if (wp == NULL || (~wp->base.mode & MODE_SYNC))
return; return;
if (event_initialized(&wp->sync_timer)) if (event_initialized(&wp->sync_timer))
@@ -1183,7 +1197,7 @@ screen_write_redraw_line(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx,
struct visible_ranges *r; struct visible_ranges *r;
struct visible_range *ri; struct visible_range *ri;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
r = window_visible_ranges(wp, xoff, yoff + yy, sx, NULL); r = window_visible_ranges(wp, xoff, yoff + yy, sx, NULL);
@@ -1266,7 +1280,7 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
screen_write_initctx(ctx, &ttyctx, 1, 1); screen_write_initctx(ctx, &ttyctx, 1, 1);
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_alignmenttest, &ttyctx); tty_write(tty_cmd_alignmenttest, &ttyctx);
@@ -1307,7 +1321,7 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = nx; ttyctx.n = nx;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_insertcharacter, &ttyctx); tty_write(tty_cmd_insertcharacter, &ttyctx);
@@ -1348,7 +1362,7 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = nx; ttyctx.n = nx;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_deletecharacter, &ttyctx); tty_write(tty_cmd_deletecharacter, &ttyctx);
@@ -1389,7 +1403,7 @@ screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = nx; ttyctx.n = nx;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_clearcharacter, &ttyctx); tty_write(tty_cmd_clearcharacter, &ttyctx);
@@ -1430,7 +1444,7 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; ttyctx.n = ny;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_insertline, &ttyctx); tty_write(tty_cmd_insertline, &ttyctx);
@@ -1457,7 +1471,7 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; ttyctx.n = ny;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_insertline, &ttyctx); tty_write(tty_cmd_insertline, &ttyctx);
@@ -1498,7 +1512,7 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; ttyctx.n = ny;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_deleteline, &ttyctx); tty_write(tty_cmd_deleteline, &ttyctx);
@@ -1525,7 +1539,7 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; ttyctx.n = ny;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_deleteline, &ttyctx); tty_write(tty_cmd_deleteline, &ttyctx);
@@ -1672,7 +1686,7 @@ screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg)
screen_write_initctx(ctx, &ttyctx, 1, 1); screen_write_initctx(ctx, &ttyctx, 1, 1);
ttyctx.bg = bg; ttyctx.bg = bg;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_reverseindex, &ttyctx); tty_write(tty_cmd_reverseindex, &ttyctx);
@@ -1805,7 +1819,7 @@ screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg)
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = lines; ttyctx.n = lines;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) {
tty_write(tty_cmd_scrolldown, &ttyctx); tty_write(tty_cmd_scrolldown, &ttyctx);
@@ -1858,7 +1872,7 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx, u_int bg)
screen_write_collect_clear(ctx, s->cy + 1, sy - (s->cy + 1)); screen_write_collect_clear(ctx, s->cy + 1, sy - (s->cy + 1));
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED) {
tty_write(tty_cmd_clearendofscreen, &ttyctx); tty_write(tty_cmd_clearendofscreen, &ttyctx);
@@ -1933,7 +1947,7 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx, u_int bg)
screen_write_collect_clear(ctx, 0, s->cy); screen_write_collect_clear(ctx, 0, s->cy);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED) {
tty_write(tty_cmd_clearstartofscreen, &ttyctx); tty_write(tty_cmd_clearstartofscreen, &ttyctx);
@@ -2006,7 +2020,7 @@ screen_write_clearscreen(struct screen_write_ctx *ctx, u_int bg)
screen_write_collect_clear(ctx, 0, sy); screen_write_collect_clear(ctx, 0, sy);
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED) { if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED) {
tty_write(tty_cmd_clearscreen, &ttyctx); tty_write(tty_cmd_clearscreen, &ttyctx);
@@ -2324,7 +2338,7 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only,
struct screen_write_citem *ci, *tmp; struct screen_write_citem *ci, *tmp;
struct screen_write_cline *cl; struct screen_write_cline *cl;
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
goto discard; goto discard;
if (ctx->scrolled != 0) { if (ctx->scrolled != 0) {
@@ -2663,12 +2677,12 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
if (s->mode & MODE_INSERT) { if (s->mode & MODE_INSERT) {
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = width; ttyctx.n = width;
if (~s->mode & MODE_SYNC) if (screen_write_should_draw(ctx))
tty_write(tty_cmd_insertcharacter, &ttyctx); tty_write(tty_cmd_insertcharacter, &ttyctx);
} }
/* If not writing, done now. */ /* If not writing, done now. */
if (skip || s->mode & MODE_SYNC) if (skip || !screen_write_should_draw(ctx))
return; return;
/* Do a full line redraw if needed. */ /* Do a full line redraw if needed. */
@@ -2688,7 +2702,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
for (i = 0, vis = 0; i < r->used; i++) for (i = 0, vis = 0; i < r->used; i++)
vis += r->ranges[i].nx; vis += r->ranges[i].nx;
if (vis >= width) { if (vis >= width) {
if (~s->mode & MODE_SYNC) if (screen_write_should_draw(ctx))
tty_write(tty_cmd_cell, &ttyctx); tty_write(tty_cmd_cell, &ttyctx);
return; return;
} }
@@ -2698,7 +2712,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
* spaces in the visible regions. * spaces in the visible regions.
*/ */
utf8_set(&tmp_gc.data, ' '); utf8_set(&tmp_gc.data, ' ');
if (s->mode & MODE_SYNC) if (!screen_write_should_draw(ctx))
return; return;
for (i = 0; i < r->used; i++) { for (i = 0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
@@ -2841,7 +2855,7 @@ screen_write_combine(struct screen_write_ctx *ctx, const struct grid_cell *gc)
ttyctx.cell = &last; ttyctx.cell = &last;
if (force_wide) if (force_wide)
ttyctx.flags |= TTY_CTX_CELL_INVALIDATE; ttyctx.flags |= TTY_CTX_CELL_INVALIDATE;
if (~s->mode & MODE_SYNC) if (screen_write_should_draw(ctx))
tty_write(tty_cmd_cell, &ttyctx); tty_write(tty_cmd_cell, &ttyctx);
screen_write_set_cursor(ctx, cx, cy); screen_write_set_cursor(ctx, cx, cy);

View File

@@ -589,6 +589,7 @@ tty_default_features(int *feat, const char *name, u_int version)
"cstyle," "cstyle,"
"extkeys," "extkeys,"
"focus," "focus,"
"overline,"
"hyperlinks," "hyperlinks,"
"osc7," "osc7,"
"sync," "sync,"