diff --git a/screen-redraw.c b/screen-redraw.c index 522fd14d..4301d823 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -704,7 +704,7 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx) /* Left not visible. */ l = ctx->ox - xoff; x = 0; - width = size - i; + width = size - l; } else { /* Right not visible. */ l = 0; @@ -712,7 +712,8 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx) width = size - x; } - r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL); + r = tty_check_overlay_range(tty, x, yoff, width); + r = screen_redraw_get_visible_ranges(wp, x, yoff, width, r); if (ctx->statustop) yoff += ctx->statuslines; for (i = 0; i < r->used; i++) { @@ -1275,15 +1276,40 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) struct screen *s = wp->screen; struct colour_palette *palette = &wp->palette; struct grid_cell defaults; - u_int i, j, woy, wx, wy, py, width; + u_int j, k, woy, wx, wy, py, width; struct visible_ranges *r; struct visible_range *ri; + /* There are 3 coordinate spaces: + * window: (0 to w->sx-1, 0 to w->sy-1) + * tty: (0 to tty->sx-1, 0 to tty->sy-1) + * pane: (0 to wp->sx-1, 0 to wp->sy-1) + * + * Transformations: + * window <-> tty (x-axis): + * window_x = tty_x + ctx->ox + * tty_x = window_x - ctx->ox + * + * window <-> tty (y-axis): + * woy = (ctx->statustop) ? ctx->statuslines : 0 + * window_y = tty_y + ctx->oy - woy + * tty_y = woy + window_y - ctx->oy + * + * window <-> pane (x-axis): + * window_x = pane_x + wp->xoff + * pane_x = window_x - wp->xoff + * + * window <-> pane (y-axis): + * window_y = pane_y + wp->yoff + * pane_y = window_y - wp->yoff + */ + if (wp->base.mode & MODE_SYNC) screen_write_stop_sync(wp); log_debug("%s: %s @%u %%%u", __func__, c->name, w->id, wp->id); + /* Check if pane completely not visible. */ if (wp->xoff + (int)wp->sx <= ctx->ox || wp->xoff >= (int)ctx->ox + (int)ctx->sx) return; @@ -1305,37 +1331,36 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) if (wp->xoff >= (int)ctx->ox && wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) { /* All visible. */ - i = 0; wx = (u_int)(wp->xoff - (int)ctx->ox); width = wp->sx; } else if (wp->xoff < (int)ctx->ox && wp->xoff + (int)wp->sx > (int)ctx->ox + (int)ctx->sx) { /* Both left and right not visible. */ - i = ctx->ox; wx = 0; width = ctx->sx; } else if (wp->xoff < (int)ctx->ox) { /* Left not visible. */ - i = (u_int)((int)ctx->ox - wp->xoff); wx = 0; - width = wp->sx - i; + width = wp->sx - ((u_int)((int)ctx->ox - wp->xoff)); } else { /* Right not visible. */ - i = 0; wx = (u_int)(wp->xoff - (int)ctx->ox); width = ctx->sx - wx; } - log_debug("%s: %s %%%u line %u,%u at %u,%u, width %u", - __func__, c->name, wp->id, i, j, wx, wy, width); /* Get visible ranges of line before we draw it. */ - r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL); + r = tty_check_overlay_range(tty, wx, wy, width); + r = screen_redraw_get_visible_ranges(wp, wx, wy, width, r); tty_default_colours(&defaults, wp); - for (i = 0; i < r->used; i++) { - ri = &r->ranges[i]; + for (k = 0; k < r->used; k++) { + ri = &r->ranges[k]; if (ri->nx == 0) continue; - tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->nx, + log_debug("%s: %s %%%u range pane (%u,%u) width %u, tty (%u,%u) width %u", + __func__, c->name, wp->id, + ri->px + (int)ctx->ox - wp->xoff, j, ri->nx, + ri->px, py, ri->nx); + tty_draw_line(tty, s, ri->px + (int)ctx->ox - wp->xoff, j, ri->nx, ri->px, py, &defaults, palette); } } @@ -1496,13 +1521,13 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, } for (j = jmin; j < jmax; j++) { - wy = sb_y + j; /* window y coordinate */ - py = sb_tty_y + j;/* tty y coordinate */ + wy = sb_y + j; /* window y coordinate */ + py = sb_tty_y + j; /* tty y coordinate */ r = tty_check_overlay_range(tty, sb_x, wy, imax); r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r); for (i = imin; i < imax; i++) { px = sb_x + ox + i; /* tty x coordinate */ - wx = sb_x + i; /* window x coordinate */ + wx = sb_x + i; /* window x coordinate */ if (wx < xoff - (int)sb_w - (int)sb_pad || px >= sx || px < 0 || wy < yoff - 1 || diff --git a/tty-draw.c b/tty-draw.c index 865fff60..24d8b711 100644 --- a/tty-draw.c +++ b/tty-draw.c @@ -46,10 +46,6 @@ static void tty_draw_line_clear(struct tty *tty, u_int px, u_int py, u_int nx, const struct grid_cell *defaults, u_int bg, int wrapped) { - struct visible_ranges *r; - struct visible_range *rr; - u_int i; - /* Nothing to clear. */ if (nx == 0) return; @@ -82,20 +78,14 @@ tty_draw_line_clear(struct tty *tty, u_int px, u_int py, u_int nx, } /* Couldn't use an escape sequence, use spaces. */ - r = tty_check_overlay_range(tty, px, py, nx); - for (i = 0; i < r->used; i++) { - rr = &r->ranges[i]; - if (rr->nx != 0) { - if (rr->px != 0 || !wrapped) - tty_cursor(tty, rr->px, py); - if (rr->nx == 1) - tty_putc(tty, ' '); - else if (rr->nx == 2) - tty_putn(tty, " ", 2, 2); - else - tty_repeat_space(tty, rr->nx); - } - } + if (px != 0 || !wrapped) + tty_cursor(tty, px, py); + if (nx == 1) + tty_putc(tty, ' '); + else if (nx == 2) + tty_putn(tty, " ", 2, 2); + else + tty_repeat_space(tty, nx); } /* Draw a line from screen to tty. */ diff --git a/tty.c b/tty.c index 65c629c3..9d3ea5fb 100644 --- a/tty.c +++ b/tty.c @@ -1306,9 +1306,7 @@ tty_clear_area(struct tty *tty, const struct tty_ctx *ctx, u_int py, { struct client *c = tty->client; const struct grid_cell *defaults = &ctx->defaults; - struct visible_ranges *r; - struct visible_range *ri; - u_int i, yy, oy = 0; + u_int yy; char tmp[64]; log_debug("%s: %s, %u,%u at %u,%u", __func__, c->name, nx, ny, px, py); @@ -1373,17 +1371,8 @@ tty_clear_area(struct tty *tty, const struct tty_ctx *ctx, u_int py, } /* Couldn't use an escape sequence, loop over the lines. */ - if (c->session->statusat == 0) - oy = c->session->statuslines; - for (yy = py; yy < py + ny; yy++) { - r = tty_check_overlay_range(tty, px, yy - oy, nx); - for (i = 0; i < r->used; i++) { - ri = &r->ranges[i]; - if (ri->nx == 0) - continue; - tty_clear_line(tty, defaults, yy, ri->px, ri->nx, bg); - } - } + for (yy = py; yy < py + ny; yy++) + tty_clear_line(tty, defaults, yy, px, nx, bg); } /* Clear an area in a pane. */