Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'

* refs/remotes/tmux-openbsd/master:
  Include menus when working out what parts of a pane are visible to avoid overwriting them, GitHub issue 5593.
  Modify display-message -c target-client to use the data relative to target-client, GitHub issue 5613 from Michael Grant.
  Quote session_alert in status-format[2], GitHub issue 5671.
  Only skip collecting text except for right margin when autowrap is off, from Jang-Ho Hwang.
  Change to the new working directory even if getcwd fails, GitHub issue 5658.
This commit is contained in:
tmux update bot
2026-10-02 19:21:31 +00:00
5 changed files with 128 additions and 115 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: screen-write.c,v 1.296 2026/10/02 12:53:26 nicm Exp $ */
/* $OpenBSD: screen-write.c,v 1.298 2026/10/02 15:20:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -189,11 +189,12 @@ screen_write_set_client_cb(struct tty_ctx *ttyctx, struct client *c)
return (1);
}
/* Return 1 if there is a floating window pane overlapping this pane. */
/* Return 1 if a menu or floating pane overlaps this pane. */
static int
screen_write_pane_is_obscured(struct screen_write_ctx *ctx)
{
struct window_pane *wp = ctx->wp;
struct menu_data *md;
if (ctx->wp == NULL)
return (0);
@@ -204,6 +205,16 @@ screen_write_pane_is_obscured(struct screen_write_ctx *ctx)
}
ctx->flags |= SCREEN_WRITE_CHECKED_IF_OBSCURED;
md = wp->window->menu;
if (md != NULL &&
(int)menu_x(md) < wp->xoff + (int)wp->sx &&
(int)(menu_x(md) + menu_width(md)) > wp->xoff &&
(int)menu_y(md) < wp->yoff + (int)wp->sy &&
(int)(menu_y(md) + menu_height(md)) > wp->yoff) {
ctx->flags |= SCREEN_WRITE_OBSCURED;
return (1);
}
if (ctx->wp->xoff < 0 ||
ctx->wp->yoff < 0 ||
ctx->wp->xoff + ctx->wp->sx > ctx->wp->window->sx ||
@@ -2522,13 +2533,18 @@ screen_write_collect_flush_line(struct screen_write_ctx *ctx, u_int y)
ttyctx.n = w_length;
tty_write(tty_cmd_clearcharacter, &ttyctx);
} else {
screen_write_initctx(ctx, &ttyctx, 0, 0);
ttyctx.cell = &ci->gc;
if (ci->wrapped)
ttyctx.flags |= TTY_CTX_WRAPPED;
ttyctx.data.data = cl->data + w_start;
ttyctx.data.size = w_length;
tty_write(tty_cmd_cells, &ttyctx);
screen_write_initctx(ctx, &ttyctx, 0, 1);
if (ttyctx.flags & TTY_CTX_PANE_OBSCURED) {
ttyctx.n = w_length;
tty_write(tty_cmd_redrawline, &ttyctx);
} else {
ttyctx.cell = &ci->gc;
if (ci->wrapped)
ttyctx.flags |= TTY_CTX_WRAPPED;
ttyctx.data.data = cl->data + w_start;
ttyctx.data.size = w_length;
tty_write(tty_cmd_cells, &ttyctx);
}
}
items++;
written = 1;
@@ -2756,6 +2772,10 @@ screen_write_collect_add(struct screen_write_ctx *ctx,
* Don't need to check that the attributes and whatnot are still the
* same - input_parse will end the collection when anything that isn't
* a plain character is encountered.
*
* Without wrapping, collect up to but not including the last column.
* Leave that cell to screen_write_cell so repeated writes overwrite it
* and the cursor remains at the right edge.
*/
collect = 1;
@@ -2765,7 +2785,8 @@ screen_write_collect_add(struct screen_write_ctx *ctx,
collect = 0;
else if (gc->attr & GRID_ATTR_CHARSET)
collect = 0;
else if (~s->mode & MODE_WRAP)
else if ((~s->mode & MODE_WRAP) &&
s->cx + ctx->item->used >= sx - 1)
collect = 0;
else if (s->mode & MODE_INSERT)
collect = 0;
@@ -2931,6 +2952,11 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
/* Create space for character in insert mode. */
if (s->mode & MODE_INSERT) {
screen_write_collect_flush(ctx, 0, __func__);
if (wp != NULL && screen_write_pane_is_obscured(ctx)) {
if (screen_write_should_draw_line(ctx, s->cy))
screen_write_redraw_line(ctx, &ttyctx, s->cy);
return;
}
ttyctx.n = width;
if (screen_write_should_draw_line(ctx, s->cy))
tty_write(tty_cmd_insertcharacter, &ttyctx);