diff --git a/layout-custom.c b/layout-custom.c index a52c46be..062a2197 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -289,7 +289,7 @@ layout_parse(struct window *w, const char *layout, char **cause) if (floating_lc != NULL) layout_assign(&wp, floating_lc, PANE_FLOATING); - /* Fix pane Z indexes. */ + /* Fix pane z-indexes. */ while (!TAILQ_EMPTY(&w->z_index)) { wp = TAILQ_FIRST(&w->z_index); TAILQ_REMOVE(&w->z_index, wp, zentry); @@ -305,8 +305,7 @@ layout_parse(struct window *w, const char *layout, char **cause) layout_print_cell(tiled_lc, __func__, 0); /* Free the floating layout cell, no longer needed. */ - if (floating_lc != NULL) - layout_free_cell(floating_lc); + layout_free_cell(floating_lc); notify_window("window-layout-changed", w); diff --git a/layout.c b/layout.c index 7c687e51..8ee80261 100644 --- a/layout.c +++ b/layout.c @@ -78,6 +78,9 @@ layout_free_cell(struct layout_cell *lc) { struct layout_cell *lcchild; + if (lc == NULL) + return; + switch (lc->type) { case LAYOUT_LEFTRIGHT: case LAYOUT_TOPBOTTOM: @@ -233,7 +236,7 @@ layout_make_node(struct layout_cell *lc, enum layout_type type) lc->wp = NULL; } -/* Fix Z indexes. */ +/* Fix z-indexes. */ void layout_fix_zindexes(struct window *w, struct layout_cell *lc) { diff --git a/screen-redraw.c b/screen-redraw.c index 745c30c5..522fd14d 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -713,10 +713,8 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx) } r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL); - if (ctx->statustop) yoff += ctx->statuslines; - for (i = 0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) @@ -1267,7 +1265,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, return (r); } - /* Draw one pane. */ static void screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) @@ -1278,7 +1275,7 @@ 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, px, py, width; + u_int i, j, woy, wx, wy, py, width; struct visible_ranges *r; struct visible_range *ri; @@ -1291,25 +1288,20 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) wp->xoff >= (int)ctx->ox + (int)ctx->sx) return; - /* woy is window y offset in tty. */ if (ctx->statustop) woy = ctx->statuslines; else woy = 0; - for (j = 0; j < wp->sy; j++) { if (wp->yoff + (int)j < (int)ctx->oy || wp->yoff + (int)j >= (int)ctx->oy + (int)ctx->sy) continue; - wy = wp->yoff + j; /* y line within window w. */ - py = woy + wy - ctx->oy; /* y line within tty. */ - if (py > tty->sy) + wy = wp->yoff + j; /* y line within window w */ + py = woy + wy - ctx->oy; /* y line within tty */ + if (py > tty->sy) { /* Continue if this line is off of tty. */ continue; - - /* Note: i is apparenty not used now that the vr array - * returns where in s to read from. - */ + } if (wp->xoff >= (int)ctx->ox && wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) { /* All visible. */ @@ -1338,16 +1330,13 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) /* Get visible ranges of line before we draw it. */ r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL); - tty_default_colours(&defaults, wp); - - for (i=0; i < r->used; i++) { + for (i = 0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) continue; - px = ri->px; - tty_draw_line(tty, s, ri->px - wp->xoff, j, - ri->nx, px, py, &defaults, palette); + tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->nx, + ri->px, py, &defaults, palette); } } @@ -1442,8 +1431,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, struct visible_ranges *r; /* - * Size and offset of window relative to tty. - * Status at top offsets window downward. + * Size and offset of window relative to tty. Status at top offsets + * window downward. */ sx = ctx->sx; sy = tty->sy - ctx->statuslines; @@ -1451,8 +1440,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, oy = ctx->oy; if (ctx->statustop) { sb_y += ctx->statuslines; - sy += ctx->statuslines; /* Height of window in tty. */ - oy += ctx->statuslines; /* Top of window in tty. */ + sy += ctx->statuslines; /* height of window */ + oy += ctx->statuslines; /* top of window */ } gc = sb_style->gc; @@ -1460,17 +1449,20 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, slgc.fg = gc.bg; slgc.bg = gc.fg; - if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) - /* Whole sb off screen. */ + if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) { + /* Whole scrollbar is off screen. */ return; - if (sb_x < 0) - /* Part of sb on screen. */ + } + if (sb_x < 0) { + /* Part of scrollbar on screen. */ imin = - sb_x; + } imax = sb_w + sb_pad; if ((int)imax + sb_x > sx) { - if (sb_x > sx) - /* Whole sb off screen. */ + if (sb_x > sx) { + /* Whole scrollbar off screen. */ return; + } imax = sx - sb_x; } jmax = sb_h; @@ -1484,41 +1476,44 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, * sb_y is a window coordinate; convert to tty coordinate by * subtracting the pan offset oy. */ - sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */ - - if (sb_tty_y > (int)sy) - /* Whole sb off screen. */ + sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */ + if (sb_tty_y > (int)sy) { + /* Whole scrollbar is off screen. */ return; - if (sb_tty_y < 0) + } + if (sb_tty_y < 0) { /* Scrollbar starts above visible area; skip those rows. */ jmin = -sb_tty_y; - if (sb_tty_y + (int)sb_h <= 0) - /* Whole sb above visible area. */ + } + if (sb_tty_y + (int)sb_h <= 0) { + /* Whole scrollbar above visible area. */ return; + } jmax = sb_h; - if (sb_tty_y + (int)jmax > (int)sy) + if (sb_tty_y + (int)jmax > (int)sy) { /* Clip to height of tty. */ jmax = sy - sb_tty_y; + } 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. */ + px = sb_x + ox + i; /* tty 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 || py >= sy || py < 0 || - ! screen_redraw_is_visible(r, wx)) + !screen_redraw_is_visible(r, wx)) continue; tty_cursor(tty, px, py); if ((sb_pos == PANE_SCROLLBARS_LEFT && i >= sb_w && i < sb_w + sb_pad) || (sb_pos == PANE_SCROLLBARS_RIGHT && - i < sb_pad)) { + i < sb_pad)) { tty_cell(tty, &grid_default_cell, &grid_default_cell, NULL, NULL); } else { diff --git a/screen-write.c b/screen-write.c index 63f3f890..9a09d190 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1115,7 +1115,9 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx) struct screen *s = ctx->s; struct tty_ctx ttyctx; struct grid_cell gc; - u_int xx, yy; + u_int xx, yy, sx, xoff, yoff, cx, i, n; + struct visible_ranges *r; + struct visible_range *ri; memcpy(&gc, &grid_default_cell, sizeof gc); utf8_set(&gc.data, 'E'); @@ -1138,15 +1140,45 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx) screen_write_initctx(ctx, &ttyctx, 1, 1); screen_write_collect_clear(ctx, 0, screen_size_y(s) - 1); - tty_write(tty_cmd_alignmenttest, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_alignmenttest, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + for (yy = 0; yy < screen_size_y(s); yy++) { + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + yy, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + ttyctx.ocx = cx; + ttyctx.ocy = yy; + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } + } } /* Insert nx characters. */ void screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) { - struct screen *s = ctx->s; - struct tty_ctx ttyctx; + struct screen *s = ctx->s; + struct tty_ctx ttyctx; + u_int sx, xoff, yoff, cx, n, i; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; if (nx == 0) nx = 1; @@ -1171,15 +1203,44 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = nx; - tty_write(tty_cmd_insertcharacter, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_insertcharacter, &ttyctx); + return; + } + + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + sx = screen_size_x(s); + + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff + s->cx, yoff + s->cy, sx - s->cx, NULL); + + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(s->grid, cx, s->cy, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } } /* Delete nx characters. */ void screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) { - struct screen *s = ctx->s; - struct tty_ctx ttyctx; + struct screen *s = ctx->s; + struct tty_ctx ttyctx; + u_int sx, xoff, yoff, cx, n, i; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; if (nx == 0) nx = 1; @@ -1204,15 +1265,44 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = nx; - tty_write(tty_cmd_deletecharacter, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_deletecharacter, &ttyctx); + return; + } + + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + sx = screen_size_x(s); + + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff + s->cx, yoff + s->cy, sx - s->cx, NULL); + + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(s->grid, cx, s->cy, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } } /* Clear nx characters. */ void screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) { - struct screen *s = ctx->s; - struct tty_ctx ttyctx; + struct screen *s = ctx->s; + struct tty_ctx ttyctx; + u_int sx, xoff, yoff, cx, n, i; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; if (nx == 0) nx = 1; @@ -1230,26 +1320,57 @@ screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) ctx->wp->flags |= PANE_REDRAW; #endif - screen_write_initctx(ctx, &ttyctx, 0, 0); + screen_write_initctx(ctx, &ttyctx, 0, 1); ttyctx.bg = bg; grid_view_clear(s->grid, s->cx, s->cy, nx, 1, bg); screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = nx; - tty_write(tty_cmd_clearcharacter, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_clearcharacter, &ttyctx); + return; + } + + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + sx = screen_size_x(s); + + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff + s->cx, yoff + s->cy, sx - s->cx, NULL); + + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(s->grid, cx, s->cy, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } } /* Insert ny lines. */ void screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg) { - struct screen *s = ctx->s; - struct grid *gd = s->grid; - struct tty_ctx ttyctx; + struct screen *s = ctx->s; + struct grid *gd = s->grid; + struct tty_ctx ttyctx; + u_int sx, sy, xoff, yoff, y, cx, i, n; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; #ifdef ENABLE_SIXEL - u_int sy = screen_size_y(s); + sy = screen_size_y(s); +#else + sy = screen_size_y(s); #endif if (ny == 0) @@ -1273,7 +1394,34 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = ny; - tty_write(tty_cmd_insertline, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_insertline, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + for (y = s->cy; y < sy; y++) { + screen_write_set_cursor(ctx, 0, y); + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + y, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(gd, cx, y, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } + } return; } @@ -1293,17 +1441,49 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = ny; - tty_write(tty_cmd_insertline, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_insertline, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + for (y = s->cy; y <= s->rlower; y++) { + screen_write_set_cursor(ctx, 0, y); + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + y, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(gd, cx, y, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } + } } /* Delete ny lines. */ void screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg) { - struct screen *s = ctx->s; - struct grid *gd = s->grid; - struct tty_ctx ttyctx; - u_int sy = screen_size_y(s); + struct screen *s = ctx->s; + struct grid *gd = s->grid; + struct tty_ctx ttyctx; + u_int sx, sy, xoff, yoff, y, cx, i, n; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; + + sy = screen_size_y(s); if (ny == 0) ny = 1; @@ -1326,7 +1506,34 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = ny; - tty_write(tty_cmd_deleteline, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_deleteline, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + for (y = s->cy; y < sy; y++) { + screen_write_set_cursor(ctx, 0, y); + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + y, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(gd, cx, y, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } + } return; } @@ -1345,7 +1552,34 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = ny; - tty_write(tty_cmd_deleteline, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_deleteline, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + for (y = s->cy; y <= s->rlower; y++) { + screen_write_set_cursor(ctx, 0, y); + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + y, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(gd, cx, y, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } + } } /* Clear line at cursor. */ @@ -1483,8 +1717,12 @@ screen_write_cursormove(struct screen_write_ctx *ctx, int px, int py, void screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg) { - struct screen *s = ctx->s; - struct tty_ctx ttyctx; + struct screen *s = ctx->s; + struct tty_ctx ttyctx; + u_int sx, xoff, yoff, cx, i, n; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; if (s->cy == s->rupper) { #ifdef ENABLE_SIXEL @@ -1498,10 +1736,33 @@ screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg) screen_write_initctx(ctx, &ttyctx, 1, 0); ttyctx.bg = bg; - tty_write(tty_cmd_reverseindex, &ttyctx); + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_reverseindex, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + screen_write_set_cursor(ctx, 0, s->rupper); + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + s->rupper, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(s->grid, cx, s->rupper, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } } else if (s->cy > 0) screen_write_set_cursor(ctx, -1, s->cy - 1); - } /* Set scroll region. */ @@ -1601,10 +1862,13 @@ screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines, u_int bg) void screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg) { - struct screen *s = ctx->s; - struct grid *gd = s->grid; - struct tty_ctx ttyctx; - u_int i; + struct screen *s = ctx->s; + struct grid *gd = s->grid; + struct tty_ctx ttyctx; + u_int sx, xoff, yoff, y, cx, i, n; + struct visible_ranges *r; + struct visible_range *ri; + struct grid_cell gc; screen_write_initctx(ctx, &ttyctx, 1, 1); ttyctx.bg = bg; @@ -1624,7 +1888,34 @@ screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg) screen_write_collect_flush(ctx, 0, __func__); ttyctx.n = lines; - tty_write(tty_cmd_scrolldown, &ttyctx); + + if (~ttyctx.flags & TTY_CTX_PANE_OBSCURED || ctx->wp == NULL) { + tty_write(tty_cmd_scrolldown, &ttyctx); + return; + } + + sx = screen_size_x(s); + xoff = ctx->wp->xoff; + yoff = ctx->wp->yoff; + + for (y = s->rupper; y <= s->rlower; y++) { + screen_write_set_cursor(ctx, 0, y); + r = screen_redraw_get_visible_ranges(ctx->wp, + xoff, yoff + y, sx, NULL); + for (i = 0; i < r->used; i++) { + ri = &r->ranges[i]; + if (ri->nx == 0) + continue; + + cx = ri->px - xoff; + for (n = 0; n < ri->nx && cx < sx; n++, cx++) { + grid_view_get_cell(gd, cx, y, &gc); + screen_write_set_cursor(ctx, cx, -1); + ttyctx.cell = &gc; + tty_write(tty_cmd_cell, &ttyctx); + } + } + } } /* Carriage return (cursor to start of line). */ @@ -2755,9 +3046,14 @@ screen_write_sixelimage(struct screen_write_ctx *ctx, struct sixel_image *si, } screen_write_collect_flush(ctx, 0, __func__); - screen_write_initctx(ctx, &ttyctx, 0, 0); + screen_write_initctx(ctx, &ttyctx, 0, 1); ttyctx.image = image_store(s, si); + if ((ttyctx.flags & TTY_CTX_PANE_OBSCURED) && ctx->wp != NULL) { + ctx->wp->flags |= PANE_REDRAW; + return; + } + tty_write(tty_cmd_sixelimage, &ttyctx); screen_write_cursormove(ctx, 0, cy + y, 0); diff --git a/tmux.1 b/tmux.1 index 787f76b3..e3978629 100644 --- a/tmux.1 +++ b/tmux.1 @@ -8343,7 +8343,7 @@ was created but is not linked to the current session. The window with ID .Ar window\-id , which is not linked to the current session, was closed. -.It Ic %unlinked\-window\-renamed Ar window\-id +.It Ic %unlinked\-window\-renamed Ar window\-id Ar new\-name The window with ID .Ar window\-id , which is not linked to the current session, was renamed. diff --git a/tty.c b/tty.c index a5b33d5e..65c629c3 100644 --- a/tty.c +++ b/tty.c @@ -1421,8 +1421,6 @@ tty_draw_pane(struct tty *tty, const struct tty_ctx *ctx, u_int py) */ r = tty_check_overlay_range(tty, ctx->xoff, ctx->yoff + py, nx); - r = screen_redraw_get_visible_ranges(wp, - ctx->xoff, ctx->yoff + py, nx, r); for (i = 0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) continue; @@ -1451,12 +1449,12 @@ tty_draw_pane(struct tty *tty, const struct tty_ctx *ctx, u_int py) } if (tty_clamp_line(tty, ctx, 0, py, nx, &px, &x, &rx, &ry)) { if (wp) { - r = tty_check_overlay_range(tty, i, py, rx); + r = tty_check_overlay_range(tty, px, py, rx); for (i=0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) continue; - tty_draw_line(tty, s, i, py, ri->nx, + tty_draw_line(tty, s, ri->px, py, ri->nx, x + ri->px, ry, &ctx->defaults, ctx->palette); } @@ -2094,8 +2092,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) tty_margin_off(tty); tty_cursor_pane_unless_wrap(tty, ctx, ctx->ocx, ctx->ocy); - if (screen_redraw_is_visible(r, px)) - tty_cell(tty, ctx->cell, &ctx->defaults, ctx->palette, + tty_cell(tty, ctx->cell, &ctx->defaults, ctx->palette, ctx->s->hyperlinks); if (ctx->flags & TTY_CTX_CELL_INVALIDATE) diff --git a/window.c b/window.c index de6049ee..bd710733 100644 --- a/window.c +++ b/window.c @@ -347,10 +347,8 @@ window_destroy(struct window *w) window_unzoom(w, 0); RB_REMOVE(windows, &windows, w); - if (w->layout_root != NULL) - layout_free_cell(w->layout_root); - if (w->saved_layout_root != NULL) - layout_free_cell(w->saved_layout_root); + layout_free_cell(w->layout_root); + layout_free_cell(w->saved_layout_root); free(w->old_layout); window_destroy_panes(w);