diff options
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 6 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tty-term.c | 7 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 28 |
7 files changed, 64 insertions, 10 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index cf2d88ff07f..436126f80a5 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.66 2020/03/24 08:09:44 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.67 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -435,6 +435,7 @@ screen_redraw_screen(struct client *c) flags = screen_redraw_update(c, c->flags); screen_redraw_set_context(c, &ctx); + tty_sync_start(&c->tty); if (flags & (CLIENT_REDRAWWINDOW|CLIENT_REDRAWBORDERS)) { if (ctx.pane_status != PANE_STATUS_OFF) @@ -448,7 +449,9 @@ screen_redraw_screen(struct client *c) screen_redraw_draw_status(&ctx); if (c->overlay_draw != NULL && (flags & CLIENT_REDRAWOVERLAY)) c->overlay_draw(c, &ctx); + tty_reset(&c->tty); + tty_sync_end(&c->tty); } /* Redraw a single pane. */ @@ -461,9 +464,12 @@ screen_redraw_pane(struct client *c, struct window_pane *wp) return; screen_redraw_set_context(c, &ctx); + tty_sync_start(&c->tty); screen_redraw_draw_pane(&ctx, wp); + tty_reset(&c->tty); + tty_sync_end(&c->tty); } /* Draw a border cell. */ diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index b065f27a024..a084d170efb 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.161 2020/04/15 16:11:23 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.162 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -100,7 +100,8 @@ void screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp, struct screen *s) { - u_int y; + struct tty_ctx ttyctx; + u_int y; memset(ctx, 0, sizeof *ctx); @@ -129,18 +130,26 @@ screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp, screen_size_y(ctx->s)); } } + + screen_write_initctx(ctx, &ttyctx); + tty_write(tty_cmd_syncstart, &ttyctx); } /* Finish writing. */ void screen_write_stop(struct screen_write_ctx *ctx) { + struct tty_ctx ttyctx; + screen_write_collect_end(ctx); screen_write_collect_flush(ctx, 0); log_debug("%s: %u cells (%u written, %u skipped)", __func__, ctx->cells, ctx->written, ctx->skipped); + screen_write_initctx(ctx, &ttyctx); + tty_write(tty_cmd_syncend, &ttyctx); + free(ctx->item); free(ctx->list); /* flush will have emptied */ } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index edf007fe257..7f3d9f6727b 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.740 2020/04/13 07:25:33 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.741 2020/04/16 13:35:24 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 13 2020 $ +.Dd $Mdocdate: April 16 2020 $ .Dt TMUX 1 .Os .Sh NAME @@ -5511,6 +5511,8 @@ $ printf '\e033[4 q' If .Em Se is not set, \&Ss with argument 0 will be used to reset the cursor style instead. +.It Em \&Sync +Show that the terminal supports synchronized updates. .It Em \&Tc Indicate that the terminal supports the .Ql direct colour diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 89f7d0c2513..10922e704e6 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.995 2020/04/16 07:28:36 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.996 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -452,6 +452,7 @@ enum tty_code_code { TTYC_SMUL, TTYC_SMXX, TTYC_SS, + TTYC_SYNC, TTYC_TC, TTYC_TSL, TTYC_U8, @@ -1181,6 +1182,7 @@ struct tty_term { #define TERM_DECSLRM 0x4 #define TERM_DECFRA 0x8 #define TERM_RGBCOLOURS 0x10 +#define TERM_SYNC 0x20 int flags; LIST_ENTRY(tty_term) entry; @@ -1949,6 +1951,8 @@ void tty_set_title(struct tty *, const char *); void tty_update_mode(struct tty *, int, struct screen *); void tty_draw_line(struct tty *, struct window_pane *, struct screen *, u_int, u_int, u_int, u_int, u_int); +void tty_sync_start(struct tty *); +void tty_sync_end(struct tty *); int tty_open(struct tty *, char **); void tty_close(struct tty *); void tty_free(struct tty *); @@ -1976,6 +1980,8 @@ void tty_cmd_scrolldown(struct tty *, const struct tty_ctx *); void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *); void tty_cmd_setselection(struct tty *, const struct tty_ctx *); void tty_cmd_rawstring(struct tty *, const struct tty_ctx *); +void tty_cmd_syncstart(struct tty *, const struct tty_ctx *); +void tty_cmd_syncend(struct tty *, const struct tty_ctx *); /* tty-term.c */ extern struct tty_terms tty_terms; diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index e75574820d7..ff4d8fd93df 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.122 2020/01/28 11:39:51 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.123 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1117,7 +1117,7 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len, /* Set terminal flags. */ if (strncmp(tmp, "ITERM2 ", 7) == 0) - flags |= (TERM_DECSLRM|TERM_256COLOURS|TERM_RGBCOLOURS); + flags |= (TERM_DECSLRM|TERM_256COLOURS|TERM_RGBCOLOURS|TERM_SYNC); if (strncmp(tmp, "TMUX ", 5) == 0) flags |= (TERM_256COLOURS|TERM_RGBCOLOURS); log_debug("%s: received DSR %.*s", c->name, (int)*size, buf); diff --git a/usr.bin/tmux/tty-term.c b/usr.bin/tmux/tty-term.c index 8a08f31fdd3..ef95f6a1913 100644 --- a/usr.bin/tmux/tty-term.c +++ b/usr.bin/tmux/tty-term.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-term.c,v 1.71 2020/01/28 11:39:51 nicm Exp $ */ +/* $OpenBSD: tty-term.c,v 1.72 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -260,6 +260,7 @@ static const struct tty_term_code_entry tty_term_codes[] = { [TTYC_SMUL] = { TTYCODE_STRING, "smul" }, [TTYC_SMXX] = { TTYCODE_STRING, "smxx" }, [TTYC_SS] = { TTYCODE_STRING, "Ss" }, + [TTYC_SYNC] = { TTYCODE_FLAG, "Sync" }, [TTYC_TC] = { TTYCODE_FLAG, "Tc" }, [TTYC_TSL] = { TTYCODE_STRING, "tsl" }, [TTYC_U8] = { TTYCODE_NUMBER, "U8" }, @@ -532,6 +533,10 @@ tty_term_find(char *name, int fd, char **cause) tty_term_has(term, TTYC_SETRGBB))) term->flags |= TERM_RGBCOLOURS; + /* Set flag if terminal has synchronized updates. */ + if (tty_term_flag(term, TTYC_SYNC)) + term->flags |= TERM_SYNC; + /* * Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1 * rather than $COLUMNS (the cursor can never be beyond $COLUMNS - 1). diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 4b2be318a9c..d1a858ee191 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.347 2020/04/09 12:16:16 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.348 2020/04/16 13:35:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1426,6 +1426,20 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s, tty_update_mode(tty, tty->mode, s); } +void +tty_sync_start(struct tty *tty) +{ + if ((tty->term->flags|tty->term_flags) & TERM_SYNC) + tty_puts(tty, "\033P=1s\033\\"); +} + +void +tty_sync_end(struct tty *tty) +{ + if ((tty->term->flags|tty->term_flags) & TERM_SYNC) + tty_puts(tty, "\033P=2s\033\\"); +} + static int tty_client_ready(struct client *c, struct window_pane *wp) { @@ -1919,6 +1933,18 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx) tty_invalidate(tty); } +void +tty_cmd_syncstart(struct tty *tty, __unused const struct tty_ctx *ctx) +{ + tty_sync_start(tty); +} + +void +tty_cmd_syncend(struct tty *tty, __unused const struct tty_ctx *ctx) +{ + tty_sync_end(tty); +} + static void tty_cell(struct tty *tty, const struct grid_cell *gc, struct window_pane *wp) { |