Change how sync works to always send the end sequence after all output

is done when we are returning to the event loop (since we always move
the cursor at that point). Also a man fix from jmc.
This commit is contained in:
nicm 2020-04-20 14:59:31 +00:00
parent 135bb1edee
commit 2083a6ea20
7 changed files with 29 additions and 25 deletions

View File

@ -458,7 +458,6 @@ screen_redraw_screen(struct client *c)
}
tty_reset(&c->tty);
tty_sync_end(&c->tty);
}
/* Redraw a single pane. */
@ -476,7 +475,6 @@ screen_redraw_pane(struct client *c, struct window_pane *wp)
screen_redraw_draw_pane(&ctx, wp);
tty_reset(&c->tty);
tty_sync_end(&c->tty);
}
/* Draw a border cell. */

View File

@ -119,7 +119,6 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx,
ttyctx->orupper = s->rupper;
if (sync && !ctx->sync && ttyctx->wp != NULL) {
log_debug("%s: starting sync", __func__);
tty_write(tty_cmd_syncstart, ttyctx);
ctx->sync = 1;
}
@ -184,8 +183,6 @@ screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
void
screen_write_stop(struct screen_write_ctx *ctx)
{
struct tty_ctx ttyctx;
screen_write_collect_end(ctx);
screen_write_collect_flush(ctx, 0, __func__);
@ -196,12 +193,6 @@ screen_write_stop(struct screen_write_ctx *ctx)
ctx->wp->skipped += ctx->skipped;
}
if (ctx->sync) {
screen_write_initctx(ctx, &ttyctx, 0);
tty_write(tty_cmd_syncend, &ttyctx);
log_debug("%s: ending sync", __func__);
}
free(ctx->item);
}

View File

@ -1541,7 +1541,7 @@ server_client_reset_state(struct client *c)
struct window_pane *wp = w->active, *loop;
struct screen *s;
struct options *oo = c->session->options;
int mode, cursor;
int mode, cursor, flags;
u_int cx = 0, cy = 0, ox, oy, sx, sy;
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
@ -1606,6 +1606,16 @@ server_client_reset_state(struct client *c)
/* Set the terminal mode and reset attributes. */
tty_update_mode(&c->tty, mode, s);
tty_reset(&c->tty);
/*
* All writing must be done, send a sync end (if it was started). It
* may have been started by redrawing so needs to go out even if the
* block flag is set.
*/
flags = (c->tty.flags & TTY_BLOCK);
c->tty.flags &= ~TTY_BLOCK;
tty_sync_end(&c->tty);
c->tty.flags |= flags;
}
/* Repeat time callback. */

2
tmux.1
View File

@ -5534,7 +5534,7 @@ The server crashed or otherwise exited without telling the client the reason.
.Sh TERMINFO EXTENSIONS
.Nm
understands some unofficial extensions to
.Xr terminfo 5.
.Xr terminfo 5 .
It is not normally necessary to set these manually, instead the
.Ic terminal-features
option should be used.

1
tmux.h
View File

@ -1992,7 +1992,6 @@ 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;

View File

@ -1150,7 +1150,7 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
"cstyle,"
"margins,"
"sync,"
"title,",
"title",
",");
} else if (strncmp(tmp, "TMUX ", 5) == 0) {
tty_add_features(&c->term_features,

26
tty.c
View File

@ -1427,18 +1427,30 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s,
void
tty_sync_start(struct tty *tty)
{
if ((~tty->flags & TTY_SYNCING) && tty_term_has(tty->term, TTYC_SYNC)) {
if (tty->flags & TTY_BLOCK)
return;
if (tty->flags & TTY_SYNCING)
return;
tty->flags |= TTY_SYNCING;
if (tty_term_has(tty->term, TTYC_SYNC)) {
log_debug("%s sync start", tty->client->name);
tty_putcode1(tty, TTYC_SYNC, 1);
tty->flags |= TTY_SYNCING;
}
}
void
tty_sync_end(struct tty *tty)
{
if ((tty->flags & TTY_SYNCING) && tty_term_has(tty->term, TTYC_SYNC)) {
if (tty->flags & TTY_BLOCK)
return;
if (~tty->flags & TTY_SYNCING)
return;
tty->flags &= ~TTY_SYNCING;
if (tty_term_has(tty->term, TTYC_SYNC)) {
log_debug("%s sync end", tty->client->name);
tty_putcode1(tty, TTYC_SYNC, 2);
tty->flags &= ~TTY_SYNCING;
}
}
@ -1952,12 +1964,6 @@ 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)
{