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.
This commit is contained in:
Patrick Motard 2025-12-06 15:42:14 -06:00
parent 487e641e39
commit 3d3cdaedda
3 changed files with 27 additions and 4 deletions

View File

@ -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);

View File

@ -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);

6
tty.c
View File

@ -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)