Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2026-05-22 12:01:06 +01:00
3 changed files with 49 additions and 37 deletions

View File

@@ -1131,7 +1131,7 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
grid_view_insert_cells(s->grid, s->cx, s->cy, nx, bg); grid_view_insert_cells(s->grid, s->cx, s->cy, nx, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = nx; ttyctx.n = nx;
tty_write(tty_cmd_insertcharacter, &ttyctx); tty_write(tty_cmd_insertcharacter, &ttyctx);
} }
@@ -1164,7 +1164,7 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
grid_view_delete_cells(s->grid, s->cx, s->cy, nx, bg); grid_view_delete_cells(s->grid, s->cx, s->cy, nx, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = nx; ttyctx.n = nx;
tty_write(tty_cmd_deletecharacter, &ttyctx); tty_write(tty_cmd_deletecharacter, &ttyctx);
} }
@@ -1197,7 +1197,7 @@ screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx, u_int 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.num = nx; ttyctx.n = nx;
tty_write(tty_cmd_clearcharacter, &ttyctx); tty_write(tty_cmd_clearcharacter, &ttyctx);
} }
@@ -1233,7 +1233,7 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
grid_view_insert_lines(gd, s->cy, ny, bg); grid_view_insert_lines(gd, s->cy, ny, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = ny; ttyctx.n = ny;
tty_write(tty_cmd_insertline, &ttyctx); tty_write(tty_cmd_insertline, &ttyctx);
return; return;
} }
@@ -1253,7 +1253,7 @@ 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.num = ny; ttyctx.n = ny;
tty_write(tty_cmd_insertline, &ttyctx); tty_write(tty_cmd_insertline, &ttyctx);
} }
@@ -1286,7 +1286,7 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
grid_view_delete_lines(gd, s->cy, ny, bg); grid_view_delete_lines(gd, s->cy, ny, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = ny; ttyctx.n = ny;
tty_write(tty_cmd_deleteline, &ttyctx); tty_write(tty_cmd_deleteline, &ttyctx);
return; return;
} }
@@ -1305,7 +1305,7 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
grid_view_delete_lines_region(gd, s->rlower, s->cy, ny, bg); grid_view_delete_lines_region(gd, s->rlower, s->cy, ny, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = ny; ttyctx.n = ny;
tty_write(tty_cmd_deleteline, &ttyctx); tty_write(tty_cmd_deleteline, &ttyctx);
} }
@@ -1567,7 +1567,7 @@ screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg)
grid_view_scroll_region_down(gd, s->rupper, s->rlower, bg); grid_view_scroll_region_down(gd, s->rupper, s->rlower, bg);
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = lines; ttyctx.n = lines;
tty_write(tty_cmd_scrolldown, &ttyctx); tty_write(tty_cmd_scrolldown, &ttyctx);
} }
@@ -1847,7 +1847,7 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only,
ctx->scrolled = s->rlower - s->rupper + 1; ctx->scrolled = s->rlower - s->rupper + 1;
screen_write_initctx(ctx, &ttyctx, 1); screen_write_initctx(ctx, &ttyctx, 1);
ttyctx.num = ctx->scrolled; ttyctx.n = ctx->scrolled;
ttyctx.bg = ctx->bg; ttyctx.bg = ctx->bg;
tty_write(tty_cmd_scrollup, &ttyctx); tty_write(tty_cmd_scrollup, &ttyctx);
@@ -1875,15 +1875,15 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only,
if (ci->type == CLEAR) { if (ci->type == CLEAR) {
screen_write_initctx(ctx, &ttyctx, 1); screen_write_initctx(ctx, &ttyctx, 1);
ttyctx.bg = ci->bg; ttyctx.bg = ci->bg;
ttyctx.num = ci->used; ttyctx.n = ci->used;
tty_write(tty_cmd_clearcharacter, &ttyctx); tty_write(tty_cmd_clearcharacter, &ttyctx);
} else { } else {
screen_write_initctx(ctx, &ttyctx, 0); screen_write_initctx(ctx, &ttyctx, 0);
ttyctx.cell = &ci->gc; ttyctx.cell = &ci->gc;
if (ci->wrapped) if (ci->wrapped)
ttyctx.flags |= TTY_CTX_WRAPPED; ttyctx.flags |= TTY_CTX_WRAPPED;
ttyctx.ptr = cl->data + ci->x; ttyctx.data.data = cl->data + ci->x;
ttyctx.num = ci->used; ttyctx.data.size = ci->used;
tty_write(tty_cmd_cells, &ttyctx); tty_write(tty_cmd_cells, &ttyctx);
} }
items++; items++;
@@ -2176,7 +2176,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
/* Create space for character in insert mode. */ /* Create space for character in insert mode. */
if (s->mode & MODE_INSERT) { if (s->mode & MODE_INSERT) {
screen_write_collect_flush(ctx, 0, __func__); screen_write_collect_flush(ctx, 0, __func__);
ttyctx.num = width; ttyctx.n = width;
tty_write(tty_cmd_insertcharacter, &ttyctx); tty_write(tty_cmd_insertcharacter, &ttyctx);
} }
@@ -2388,9 +2388,9 @@ screen_write_setselection(struct screen_write_ctx *ctx, const char *clip,
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
screen_write_initctx(ctx, &ttyctx, 0); screen_write_initctx(ctx, &ttyctx, 0);
ttyctx.ptr = str; ttyctx.sel.clip = clip;
ttyctx.ptr2 = (void *)clip; ttyctx.sel.data = str;
ttyctx.num = len; ttyctx.sel.size = len;
tty_write(tty_cmd_setselection, &ttyctx); tty_write(tty_cmd_setselection, &ttyctx);
} }
@@ -2405,8 +2405,8 @@ screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len,
screen_write_initctx(ctx, &ttyctx, 0); screen_write_initctx(ctx, &ttyctx, 0);
if (allow_invisible_panes) if (allow_invisible_panes)
ttyctx.flags |= TTY_CTX_INVISIBLE_PANES; ttyctx.flags |= TTY_CTX_INVISIBLE_PANES;
ttyctx.ptr = str; ttyctx.data.data = str;
ttyctx.num = len; ttyctx.data.size = len;
tty_write(tty_cmd_rawstring, &ttyctx); tty_write(tty_cmd_rawstring, &ttyctx);
} }

17
tmux.h
View File

@@ -1741,9 +1741,20 @@ struct tty_ctx {
#define TTY_CTX_CELL_DRAW_LINE 0x20 #define TTY_CTX_CELL_DRAW_LINE 0x20
#define TTY_CTX_CELL_INVALIDATE 0x40 #define TTY_CTX_CELL_INVALIDATE 0x40
u_int num; union {
void *ptr; u_int n;
void *ptr2;
struct {
const char *data;
size_t size;
} data;
struct {
const char *clip;
const char *data;
size_t size;
} sel;
};
/* /*
* Cursor and region position before the screen was updated - this is * Cursor and region position before the screen was updated - this is

33
tty.c
View File

@@ -1625,7 +1625,7 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->n);
} }
void void
@@ -1648,7 +1648,7 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->num); tty_emulate_repeat(tty, TTYC_DCH, TTYC_DCH1, ctx->n);
} }
void void
@@ -1657,7 +1657,7 @@ tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg, tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg,
ctx->s->hyperlinks); ctx->s->hyperlinks);
tty_clear_pane_line(tty, ctx, ctx->ocy, ctx->ocx, ctx->num, ctx->bg); tty_clear_pane_line(tty, ctx, ctx->ocy, ctx->ocx, ctx->n, ctx->bg);
} }
void void
@@ -1684,7 +1684,7 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
tty_margin_off(tty); tty_margin_off(tty);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->num); tty_emulate_repeat(tty, TTYC_IL, TTYC_IL1, ctx->n);
tty->cx = tty->cy = UINT_MAX; tty->cx = tty->cy = UINT_MAX;
} }
@@ -1712,7 +1712,7 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
tty_margin_off(tty); tty_margin_off(tty);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->num); tty_emulate_repeat(tty, TTYC_DL, TTYC_DL1, ctx->n);
tty->cx = tty->cy = UINT_MAX; tty->cx = tty->cy = UINT_MAX;
} }
@@ -1845,19 +1845,19 @@ tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx)
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_margin_pane(tty, ctx); tty_margin_pane(tty, ctx);
if (ctx->num == 1 || !tty_term_has(tty->term, TTYC_INDN)) { if (ctx->n == 1 || !tty_term_has(tty->term, TTYC_INDN)) {
if (!tty_use_margin(tty)) if (!tty_use_margin(tty))
tty_cursor(tty, 0, tty->rlower); tty_cursor(tty, 0, tty->rlower);
else else
tty_cursor(tty, tty->rright, tty->rlower); tty_cursor(tty, tty->rright, tty->rlower);
for (i = 0; i < ctx->num; i++) for (i = 0; i < ctx->n; i++)
tty_putc(tty, '\n'); tty_putc(tty, '\n');
} else { } else {
if (tty->cy == UINT_MAX) if (tty->cy == UINT_MAX)
tty_cursor(tty, 0, 0); tty_cursor(tty, 0, 0);
else else
tty_cursor(tty, 0, tty->cy); tty_cursor(tty, 0, tty->cy);
tty_putcode_i(tty, TTYC_INDN, ctx->num); tty_putcode_i(tty, TTYC_INDN, ctx->n);
} }
} }
@@ -1888,9 +1888,9 @@ tty_cmd_scrolldown(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
if (tty_term_has(tty->term, TTYC_RIN)) if (tty_term_has(tty->term, TTYC_RIN))
tty_putcode_i(tty, TTYC_RIN, ctx->num); tty_putcode_i(tty, TTYC_RIN, ctx->n);
else { else {
for (i = 0; i < ctx->num; i++) for (i = 0; i < ctx->n; i++)
tty_putcode(tty, TTYC_RI); tty_putcode(tty, TTYC_RI);
} }
} }
@@ -2040,14 +2040,15 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
struct visible_ranges *r; struct visible_ranges *r;
struct visible_range *rr; struct visible_range *rr;
u_int i, px, py, cx; u_int i, px, py, cx;
char *cp = ctx->ptr; const char *cp = ctx->data.data;
size_t n = ctx->data.size;
if (!tty_is_visible(tty, ctx, ctx->ocx, ctx->ocy, ctx->num, 1)) if (!tty_is_visible(tty, ctx, ctx->ocx, ctx->ocy, n, 1))
return; return;
if ((ctx->flags & TTY_CTX_WINDOW_BIGGER) && if ((ctx->flags & TTY_CTX_WINDOW_BIGGER) &&
(ctx->xoff + ctx->ocx < ctx->wox || (ctx->xoff + ctx->ocx < ctx->wox ||
ctx->xoff + ctx->ocx + ctx->num > ctx->wox + ctx->wsx)) { ctx->xoff + ctx->ocx + n > ctx->wox + ctx->wsx)) {
if ((~ctx->flags & TTY_CTX_WRAPPED) || if ((~ctx->flags & TTY_CTX_WRAPPED) ||
!tty_full_width(tty, ctx) || !tty_full_width(tty, ctx) ||
(tty->term->flags & TERM_NOAM) || (tty->term->flags & TERM_NOAM) ||
@@ -2070,7 +2071,7 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
px = ctx->xoff + ctx->ocx - ctx->wox; px = ctx->xoff + ctx->ocx - ctx->wox;
py = ctx->yoff + ctx->ocy - ctx->woy; py = ctx->yoff + ctx->ocy - ctx->woy;
r = tty_check_overlay_range(tty, px, py, ctx->num); r = tty_check_overlay_range(tty, px, py, n);
for (i = 0; i < r->used; i++) { for (i = 0; i < r->used; i++) {
rr = &r->ranges[i]; rr = &r->ranges[i];
if (rr->nx != 0) { if (rr->nx != 0) {
@@ -2084,7 +2085,7 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
void void
tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx) tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx)
{ {
tty_set_selection(tty, ctx->ptr2, ctx->ptr, ctx->num); tty_set_selection(tty, ctx->sel.clip, ctx->sel.data, ctx->sel.size);
} }
void void
@@ -2113,7 +2114,7 @@ void
tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx) tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
{ {
tty->flags |= TTY_NOBLOCK; tty->flags |= TTY_NOBLOCK;
tty_add(tty, ctx->ptr, ctx->num); tty_add(tty, ctx->data.data, ctx->data.size);
tty_invalidate(tty); tty_invalidate(tty);
} }