From 3d3cdaeddaf7a3036d3b930f7237d06217566dda Mon Sep 17 00:00:00 2001 From: Patrick Motard Date: Sat, 6 Dec 2025 15:42:14 -0600 Subject: [PATCH] Add content positioning and cursor offset for box mode Adjust content and cursor positioning when box mode is active: - screen_write_set_client_cb(): Apply +1 offset to xoff/yoff for content positioning inside the border - server_client_reset_state(): Account for box mode offset when calculating cursor position - tty_window_offset1(): Account for box mode offset in view offset calculation This ensures content is rendered inside the border area and the cursor appears at the correct position. --- screen-write.c | 6 ++++++ server-client.c | 19 +++++++++++++++---- tty.c | 6 ++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/screen-write.c b/screen-write.c index a2755d35..ab0e6571 100644 --- a/screen-write.c +++ b/screen-write.c @@ -161,6 +161,12 @@ screen_write_set_client_cb(struct tty_ctx *ttyctx, struct client *c) ttyctx->xoff = ttyctx->rxoff = wp->xoff; ttyctx->yoff = ttyctx->ryoff = wp->yoff; + /* Apply box mode offset for content positioning. */ + if (window_pane_box_mode(wp)) { + ttyctx->xoff += 1; + ttyctx->yoff += 1; + } + if (status_at_line(c) == 0) ttyctx->yoff += status_line_size(c); diff --git a/server-client.c b/server-client.c index 7f1942c7..c54adb76 100644 --- a/server-client.c +++ b/server-client.c @@ -2949,14 +2949,25 @@ server_client_reset_state(struct client *c) } cx = c->prompt_cursor; } else if (c->overlay_draw == NULL) { + u_int pxoff, pyoff; + cursor = 0; tty_window_offset(tty, &ox, &oy, &sx, &sy); - if (wp->xoff + s->cx >= ox && wp->xoff + s->cx <= ox + sx && - wp->yoff + s->cy >= oy && wp->yoff + s->cy <= oy + sy) { + + /* Account for box mode offset. */ + pxoff = wp->xoff; + pyoff = wp->yoff; + if (window_pane_box_mode(wp)) { + pxoff += 1; + pyoff += 1; + } + + if (pxoff + s->cx >= ox && pxoff + s->cx <= ox + sx && + pyoff + s->cy >= oy && pyoff + s->cy <= oy + sy) { cursor = 1; - cx = wp->xoff + s->cx - ox; - cy = wp->yoff + s->cy - oy; + cx = pxoff + s->cx - ox; + cy = pyoff + s->cy - oy; if (status_at_line(c) == 0) cy += status_line_size(c); diff --git a/tty.c b/tty.c index 605ab1ec..5ec96f5c 100644 --- a/tty.c +++ b/tty.c @@ -995,6 +995,12 @@ tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy) cx = wp->xoff + wp->screen->cx; cy = wp->yoff + wp->screen->cy; + /* Account for box mode offset. */ + if (window_pane_box_mode(wp)) { + cx += 1; + cy += 1; + } + if (cx < *sx) *ox = 0; else if (cx > w->sx - *sx)