Merge branch 'floating_panes' into floating_panes_staging

This commit is contained in:
Nicholas Marriott
2026-05-24 10:06:33 +01:00
7 changed files with 380 additions and 92 deletions

View File

@@ -289,7 +289,7 @@ layout_parse(struct window *w, const char *layout, char **cause)
if (floating_lc != NULL) if (floating_lc != NULL)
layout_assign(&wp, floating_lc, PANE_FLOATING); layout_assign(&wp, floating_lc, PANE_FLOATING);
/* Fix pane Z indexes. */ /* Fix pane z-indexes. */
while (!TAILQ_EMPTY(&w->z_index)) { while (!TAILQ_EMPTY(&w->z_index)) {
wp = TAILQ_FIRST(&w->z_index); wp = TAILQ_FIRST(&w->z_index);
TAILQ_REMOVE(&w->z_index, wp, zentry); 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); layout_print_cell(tiled_lc, __func__, 0);
/* Free the floating layout cell, no longer needed. */ /* 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); notify_window("window-layout-changed", w);

View File

@@ -78,6 +78,9 @@ layout_free_cell(struct layout_cell *lc)
{ {
struct layout_cell *lcchild; struct layout_cell *lcchild;
if (lc == NULL)
return;
switch (lc->type) { switch (lc->type) {
case LAYOUT_LEFTRIGHT: case LAYOUT_LEFTRIGHT:
case LAYOUT_TOPBOTTOM: case LAYOUT_TOPBOTTOM:
@@ -233,7 +236,7 @@ layout_make_node(struct layout_cell *lc, enum layout_type type)
lc->wp = NULL; lc->wp = NULL;
} }
/* Fix Z indexes. */ /* Fix z-indexes. */
void void
layout_fix_zindexes(struct window *w, struct layout_cell *lc) layout_fix_zindexes(struct window *w, struct layout_cell *lc)
{ {

View File

@@ -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); r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL);
if (ctx->statustop) if (ctx->statustop)
yoff += ctx->statuslines; yoff += ctx->statuslines;
for (i = 0; i < r->used; i++) { for (i = 0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (ri->nx == 0) if (ri->nx == 0)
@@ -1267,7 +1265,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
return (r); return (r);
} }
/* Draw one pane. */ /* Draw one pane. */
static void static void
screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) 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 screen *s = wp->screen;
struct colour_palette *palette = &wp->palette; struct colour_palette *palette = &wp->palette;
struct grid_cell defaults; 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_ranges *r;
struct visible_range *ri; 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) wp->xoff >= (int)ctx->ox + (int)ctx->sx)
return; return;
/* woy is window y offset in tty. */
if (ctx->statustop) if (ctx->statustop)
woy = ctx->statuslines; woy = ctx->statuslines;
else else
woy = 0; woy = 0;
for (j = 0; j < wp->sy; j++) { for (j = 0; j < wp->sy; j++) {
if (wp->yoff + (int)j < (int)ctx->oy || if (wp->yoff + (int)j < (int)ctx->oy ||
wp->yoff + (int)j >= (int)ctx->oy + (int)ctx->sy) wp->yoff + (int)j >= (int)ctx->oy + (int)ctx->sy)
continue; continue;
wy = wp->yoff + j; /* y line within window w. */ wy = wp->yoff + j; /* y line within window w */
py = woy + wy - ctx->oy; /* y line within tty. */ py = woy + wy - ctx->oy; /* y line within tty */
if (py > tty->sy) if (py > tty->sy) {
/* Continue if this line is off of tty. */ /* Continue if this line is off of tty. */
continue; 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 && if (wp->xoff >= (int)ctx->ox &&
wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) { wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) {
/* All visible. */ /* 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. */ /* Get visible ranges of line before we draw it. */
r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL); r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL);
tty_default_colours(&defaults, wp); tty_default_colours(&defaults, wp);
for (i = 0; i < r->used; i++) {
for (i=0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (ri->nx == 0) if (ri->nx == 0)
continue; continue;
px = ri->px; tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->nx,
tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->px, py, &defaults, palette);
ri->nx, px, py, &defaults, palette);
} }
} }
@@ -1442,8 +1431,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
struct visible_ranges *r; struct visible_ranges *r;
/* /*
* Size and offset of window relative to tty. * Size and offset of window relative to tty. Status at top offsets
* Status at top offsets window downward. * window downward.
*/ */
sx = ctx->sx; sx = ctx->sx;
sy = tty->sy - ctx->statuslines; sy = tty->sy - ctx->statuslines;
@@ -1451,8 +1440,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
oy = ctx->oy; oy = ctx->oy;
if (ctx->statustop) { if (ctx->statustop) {
sb_y += ctx->statuslines; sb_y += ctx->statuslines;
sy += ctx->statuslines; /* Height of window in tty. */ sy += ctx->statuslines; /* height of window */
oy += ctx->statuslines; /* Top of window in tty. */ oy += ctx->statuslines; /* top of window */
} }
gc = sb_style->gc; gc = sb_style->gc;
@@ -1460,17 +1449,20 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
slgc.fg = gc.bg; slgc.fg = gc.bg;
slgc.bg = gc.fg; slgc.bg = gc.fg;
if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) {
/* Whole sb off screen. */ /* Whole scrollbar is off screen. */
return; return;
if (sb_x < 0) }
/* Part of sb on screen. */ if (sb_x < 0) {
/* Part of scrollbar on screen. */
imin = - sb_x; imin = - sb_x;
}
imax = sb_w + sb_pad; imax = sb_w + sb_pad;
if ((int)imax + sb_x > sx) { if ((int)imax + sb_x > sx) {
if (sb_x > sx) if (sb_x > sx) {
/* Whole sb off screen. */ /* Whole scrollbar off screen. */
return; return;
}
imax = sx - sb_x; imax = sx - sb_x;
} }
jmax = sb_h; 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 * sb_y is a window coordinate; convert to tty coordinate by
* subtracting the pan offset oy. * subtracting the pan offset oy.
*/ */
sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */ sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */
if (sb_tty_y > (int)sy) {
if (sb_tty_y > (int)sy) /* Whole scrollbar is off screen. */
/* Whole sb off screen. */
return; return;
if (sb_tty_y < 0) }
if (sb_tty_y < 0) {
/* Scrollbar starts above visible area; skip those rows. */ /* Scrollbar starts above visible area; skip those rows. */
jmin = -sb_tty_y; 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; return;
}
jmax = sb_h; jmax = sb_h;
if (sb_tty_y + (int)jmax > (int)sy) if (sb_tty_y + (int)jmax > (int)sy) {
/* Clip to height of tty. */ /* Clip to height of tty. */
jmax = sy - sb_tty_y; jmax = sy - sb_tty_y;
}
for (j = jmin; j < jmax; j++) { for (j = jmin; j < jmax; j++) {
wy = sb_y + j; /* window y coordinate. */ wy = sb_y + j; /* window y coordinate */
py = sb_tty_y + j; /* tty y coordinate. */ py = sb_tty_y + j;/* tty y coordinate */
r = tty_check_overlay_range(tty, sb_x, wy, imax); r = tty_check_overlay_range(tty, sb_x, wy, imax);
r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r); r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r);
for (i = imin; i < imax; i++) { for (i = imin; i < imax; i++) {
px = sb_x + ox + i; /* tty x coordinate. */ 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 || if (wx < xoff - (int)sb_w - (int)sb_pad ||
px >= sx || px < 0 || px >= sx || px < 0 ||
wy < yoff - 1 || wy < yoff - 1 ||
py >= sy || py < 0 || py >= sy || py < 0 ||
! screen_redraw_is_visible(r, wx)) !screen_redraw_is_visible(r, wx))
continue; continue;
tty_cursor(tty, px, py); tty_cursor(tty, px, py);
if ((sb_pos == PANE_SCROLLBARS_LEFT && if ((sb_pos == PANE_SCROLLBARS_LEFT &&
i >= sb_w && i < sb_w + sb_pad) || i >= sb_w && i < sb_w + sb_pad) ||
(sb_pos == PANE_SCROLLBARS_RIGHT && (sb_pos == PANE_SCROLLBARS_RIGHT &&
i < sb_pad)) { i < sb_pad)) {
tty_cell(tty, &grid_default_cell, tty_cell(tty, &grid_default_cell,
&grid_default_cell, NULL, NULL); &grid_default_cell, NULL, NULL);
} else { } else {

View File

@@ -1115,7 +1115,9 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
struct grid_cell gc; 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); memcpy(&gc, &grid_default_cell, sizeof gc);
utf8_set(&gc.data, 'E'); 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_initctx(ctx, &ttyctx, 1, 1);
screen_write_collect_clear(ctx, 0, screen_size_y(s) - 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. */ /* Insert nx characters. */
void void
screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; 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) if (nx == 0)
nx = 1; 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = nx; 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. */ /* Delete nx characters. */
void void
screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; 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) if (nx == 0)
nx = 1; 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = nx; 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. */ /* Clear nx characters. */
void void
screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg) screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; 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) if (nx == 0)
nx = 1; 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; ctx->wp->flags |= PANE_REDRAW;
#endif #endif
screen_write_initctx(ctx, &ttyctx, 0, 0); screen_write_initctx(ctx, &ttyctx, 0, 1);
ttyctx.bg = bg; ttyctx.bg = bg;
grid_view_clear(s->grid, s->cx, s->cy, nx, 1, bg); grid_view_clear(s->grid, s->cx, s->cy, nx, 1, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = nx; 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. */ /* Insert ny lines. */
void void
screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg) screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid *gd = s->grid; struct grid *gd = s->grid;
struct tty_ctx ttyctx; 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 #ifdef ENABLE_SIXEL
u_int sy = screen_size_y(s); sy = screen_size_y(s);
#else
sy = screen_size_y(s);
#endif #endif
if (ny == 0) 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; 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; 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; 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. */ /* Delete ny lines. */
void void
screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg) screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid *gd = s->grid; struct grid *gd = s->grid;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
u_int sy = screen_size_y(s); 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) if (ny == 0)
ny = 1; 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; 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; 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = ny; 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. */ /* Clear line at cursor. */
@@ -1483,8 +1717,12 @@ screen_write_cursormove(struct screen_write_ctx *ctx, int px, int py,
void void
screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg) screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; 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) { if (s->cy == s->rupper) {
#ifdef ENABLE_SIXEL #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); screen_write_initctx(ctx, &ttyctx, 1, 0);
ttyctx.bg = bg; 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) } else if (s->cy > 0)
screen_write_set_cursor(ctx, -1, s->cy - 1); screen_write_set_cursor(ctx, -1, s->cy - 1);
} }
/* Set scroll region. */ /* Set scroll region. */
@@ -1601,10 +1862,13 @@ screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines, u_int bg)
void void
screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg) screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid *gd = s->grid; struct grid *gd = s->grid;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
u_int i; 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); screen_write_initctx(ctx, &ttyctx, 1, 1);
ttyctx.bg = bg; 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__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.n = lines; 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). */ /* 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_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); 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); tty_write(tty_cmd_sixelimage, &ttyctx);
screen_write_cursormove(ctx, 0, cy + y, 0); screen_write_cursormove(ctx, 0, cy + y, 0);

2
tmux.1
View File

@@ -8343,7 +8343,7 @@ was created but is not linked to the current session.
The window with ID The window with ID
.Ar window\-id , .Ar window\-id ,
which is not linked to the current session, was closed. 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 The window with ID
.Ar window\-id , .Ar window\-id ,
which is not linked to the current session, was renamed. which is not linked to the current session, was renamed.

9
tty.c
View File

@@ -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, r = tty_check_overlay_range(tty, ctx->xoff,
ctx->yoff + py, nx); 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++) { for (i = 0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (ri->nx == 0) continue; 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 (tty_clamp_line(tty, ctx, 0, py, nx, &px, &x, &rx, &ry)) {
if (wp) { 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++) { for (i=0; i < r->used; i++) {
ri = &r->ranges[i]; ri = &r->ranges[i];
if (ri->nx == 0) if (ri->nx == 0)
continue; 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, x + ri->px, ry, &ctx->defaults,
ctx->palette); ctx->palette);
} }
@@ -2094,8 +2092,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
tty_margin_off(tty); tty_margin_off(tty);
tty_cursor_pane_unless_wrap(tty, ctx, ctx->ocx, ctx->ocy); 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); ctx->s->hyperlinks);
if (ctx->flags & TTY_CTX_CELL_INVALIDATE) if (ctx->flags & TTY_CTX_CELL_INVALIDATE)

View File

@@ -347,10 +347,8 @@ window_destroy(struct window *w)
window_unzoom(w, 0); window_unzoom(w, 0);
RB_REMOVE(windows, &windows, w); RB_REMOVE(windows, &windows, w);
if (w->layout_root != NULL) layout_free_cell(w->layout_root);
layout_free_cell(w->layout_root); layout_free_cell(w->saved_layout_root);
if (w->saved_layout_root != NULL)
layout_free_cell(w->saved_layout_root);
free(w->old_layout); free(w->old_layout);
window_destroy_panes(w); window_destroy_panes(w);