diff --git a/format.c b/format.c index 797fb570..7e28fc01 100644 --- a/format.c +++ b/format.c @@ -2690,6 +2690,9 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp) format_add(ft, "history_limit", "%u", gd->hlimit); format_add_cb(ft, "history_bytes", format_cb_history_bytes); + format_add(ft, "pane_written", "%zu", wp->written); + format_add(ft, "pane_skipped", "%zu", wp->skipped); + if (window_pane_index(wp, &idx) != 0) fatalx("index not found"); format_add(ft, "pane_index", "%u", idx); diff --git a/screen-redraw.c b/screen-redraw.c index c9e70590..4c017706 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -474,6 +474,7 @@ screen_redraw_pane(struct client *c, struct window_pane *wp) tty_sync_start(&c->tty); screen_redraw_draw_pane(&ctx, wp); + wp->flags &= ~PANE_REDRAW; tty_reset(&c->tty); tty_sync_end(&c->tty); @@ -563,6 +564,7 @@ screen_redraw_draw_panes(struct screen_redraw_ctx *ctx) TAILQ_FOREACH(wp, &w->panes, entry) { if (window_pane_visible(wp)) screen_redraw_draw_pane(ctx, wp); + wp->flags &= ~PANE_REDRAW; } } diff --git a/screen-write.c b/screen-write.c index bd756ce3..34895c7b 100644 --- a/screen-write.c +++ b/screen-write.c @@ -174,6 +174,10 @@ screen_write_stop(struct screen_write_ctx *ctx) log_debug("%s: %u cells (%u written, %u skipped)", __func__, ctx->cells, ctx->written, ctx->skipped); + if (ctx->wp != NULL) { + ctx->wp->written += ctx->written; + ctx->wp->skipped += ctx->skipped; + } if (ctx->sync) { screen_write_initctx(ctx, &ttyctx, 0); diff --git a/server-client.c b/server-client.c index 36d3e5f4..91db6e0d 100644 --- a/server-client.c +++ b/server-client.c @@ -1368,7 +1368,6 @@ server_client_loop(void) if (resize) server_client_check_resize(wp); } - wp->flags &= ~PANE_REDRAW; } check_window_name(w); } @@ -1679,7 +1678,7 @@ server_client_check_redraw(struct client *c) struct session *s = c->session; struct tty *tty = &c->tty; struct window_pane *wp; - int needed, flags, mode = tty->mode; + int needed, flags, mode = tty->mode, new_flags = 0; struct timeval tv = { .tv_usec = 1000 }; static struct event ev; size_t left; @@ -1687,11 +1686,12 @@ server_client_check_redraw(struct client *c) if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) return; if (c->flags & CLIENT_ALLREDRAWFLAGS) { - log_debug("%s: redraw%s%s%s%s", c->name, + log_debug("%s: redraw%s%s%s%s%s", c->name, (c->flags & CLIENT_REDRAWWINDOW) ? " window" : "", (c->flags & CLIENT_REDRAWSTATUS) ? " status" : "", (c->flags & CLIENT_REDRAWBORDERS) ? " borders" : "", - (c->flags & CLIENT_REDRAWOVERLAY) ? " overlay" : ""); + (c->flags & CLIENT_REDRAWOVERLAY) ? " overlay" : "", + (c->flags & CLIENT_REDRAWPANES) ? " panes" : ""); } /* @@ -1709,6 +1709,8 @@ server_client_check_redraw(struct client *c) break; } } + if (needed) + new_flags |= CLIENT_REDRAWPANES; } if (needed && (left = EVBUFFER_LENGTH(tty->out)) != 0) { log_debug("%s: redraw deferred (%zu left)", c->name, left); @@ -1718,19 +1720,13 @@ server_client_check_redraw(struct client *c) log_debug("redraw timer started"); evtimer_add(&ev, &tv); } - - /* - * We may have got here for a single pane redraw, but force a - * full redraw next time in case other panes have been updated. - */ - c->flags |= CLIENT_ALLREDRAWFLAGS; + c->flags |= new_flags; return; } else if (needed) log_debug("%s: redraw needed", c->name); flags = tty->flags & (TTY_BLOCK|TTY_FREEZE|TTY_NOCURSOR); tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE)) | TTY_NOCURSOR; - tty_update_mode(tty, mode, NULL); if (~c->flags & CLIENT_REDRAWWINDOW) { /* @@ -1740,13 +1736,15 @@ server_client_check_redraw(struct client *c) TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { if (wp->flags & PANE_REDRAW) { log_debug("%s: redrawing pane %%%u", __func__, wp->id); - tty_update_mode(tty, tty->mode, NULL); + tty_update_mode(tty, mode, NULL); screen_redraw_pane(c, wp); } } + c->flags &= ~CLIENT_REDRAWPANES; } if (c->flags & CLIENT_ALLREDRAWFLAGS) { + tty_update_mode(tty, mode, NULL); if (options_get_number(s->options, "set-titles")) server_client_set_title(c); screen_redraw_screen(c); diff --git a/tmux.1 b/tmux.1 index 5850dc55..e0e5ef00 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4450,6 +4450,7 @@ The following variables are available, where appropriate: .It Li "pane_pipe" Ta "" Ta "1 if pane is being piped" .It Li "pane_right" Ta "" Ta "Right of pane" .It Li "pane_search_string" Ta "" Ta "Last search string in copy mode" +.It Li "pane_skipped" Ta "" Ta "Bytes skipped as not visible in pane" .It Li "pane_start_command" Ta "" Ta "Command pane started with" .It Li "pane_synchronized" Ta "" Ta "1 if pane is synchronized" .It Li "pane_tabs" Ta "" Ta "Pane tab positions" @@ -4457,6 +4458,7 @@ The following variables are available, where appropriate: .It Li "pane_top" Ta "" Ta "Top of pane" .It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane" .It Li "pane_width" Ta "" Ta "Width of pane" +.It Li "pane_written" Ta "" Ta "Bytes written by pane (aside from redrawing)" .It Li "pid" Ta "" Ta "Server PID" .It Li "popup_key" Ta "" Ta "Key pressed in popup" .It Li "popup_mouse_x" Ta "" Ta "Mouse X position in popup" diff --git a/tmux.h b/tmux.h index 795baabc..b2e7cb64 100644 --- a/tmux.h +++ b/tmux.h @@ -936,6 +936,9 @@ struct window_pane { char *searchstr; int searchregex; + u_int written; + u_int skipped; + TAILQ_ENTRY(window_pane) entry; RB_ENTRY(window_pane) tree_entry; }; @@ -1541,12 +1544,14 @@ struct client { #define CLIENT_CONTROL_NOOUTPUT 0x4000000 #define CLIENT_DEFAULTSOCKET 0x8000000 #define CLIENT_STARTSERVER 0x10000000 +#define CLIENT_REDRAWPANES 0x20000000 #define CLIENT_ALLREDRAWFLAGS \ (CLIENT_REDRAWWINDOW| \ CLIENT_REDRAWSTATUS| \ CLIENT_REDRAWSTATUSALWAYS| \ CLIENT_REDRAWBORDERS| \ - CLIENT_REDRAWOVERLAY) + CLIENT_REDRAWOVERLAY| \ + CLIENT_REDRAWPANES) #define CLIENT_UNATTACHEDFLAGS \ (CLIENT_DEAD| \ CLIENT_SUSPENDED| \ diff --git a/tty.c b/tty.c index 92827f5d..cdfedf6c 100644 --- a/tty.c +++ b/tty.c @@ -944,6 +944,7 @@ tty_fake_bce(const struct tty *tty, struct window_pane *wp, u_int bg) static void tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx) { + struct client *c = tty->client; struct window_pane *wp = ctx->wp; struct screen *s = wp->screen; u_int i; @@ -953,6 +954,7 @@ tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx) * likely to be followed by some more scrolling. */ if (tty_large_region(tty, ctx)) { + log_debug("%s: %s, large redraw of %%%u", __func__, c->name, wp->id); wp->flags |= PANE_REDRAW; return; } @@ -1484,6 +1486,14 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *), TAILQ_FOREACH(c, &clients, entry) { if (!tty_client_ready(c, wp)) continue; + if (c->flags & CLIENT_REDRAWPANES) { + /* + * Redraw is already deferred to redraw another pane - + * redraw this one also when that happens. + */ + wp->flags |= PANE_REDRAW; + break; + } ctx->bigger = tty_window_offset(&c->tty, &ctx->ox, &ctx->oy, &ctx->sx, &ctx->sy);