Use a union for the data passed around in tty_ctx instead of void *.

This commit is contained in:
nicm
2026-05-22 09:21:32 +00:00
parent d5ee330d20
commit 36bc351557
3 changed files with 49 additions and 37 deletions

33
tty.c
View File

@@ -1555,7 +1555,7 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
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
@@ -1578,7 +1578,7 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
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
@@ -1587,7 +1587,7 @@ tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx)
tty_default_attributes(tty, &ctx->defaults, ctx->palette, ctx->bg,
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
@@ -1614,7 +1614,7 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
tty_margin_off(tty);
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;
}
@@ -1642,7 +1642,7 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
tty_margin_off(tty);
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;
}
@@ -1775,19 +1775,19 @@ tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx)
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
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))
tty_cursor(tty, 0, tty->rlower);
else
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');
} else {
if (tty->cy == UINT_MAX)
tty_cursor(tty, 0, 0);
else
tty_cursor(tty, 0, tty->cy);
tty_putcode_i(tty, TTYC_INDN, ctx->num);
tty_putcode_i(tty, TTYC_INDN, ctx->n);
}
}
@@ -1818,9 +1818,9 @@ tty_cmd_scrolldown(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper);
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 {
for (i = 0; i < ctx->num; i++)
for (i = 0; i < ctx->n; i++)
tty_putcode(tty, TTYC_RI);
}
}
@@ -1970,14 +1970,15 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
struct visible_ranges *r;
struct visible_range *rr;
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;
if ((ctx->flags & TTY_CTX_WINDOW_BIGGER) &&
(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) ||
!tty_full_width(tty, ctx) ||
(tty->term->flags & TERM_NOAM) ||
@@ -2000,7 +2001,7 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
px = ctx->xoff + ctx->ocx - ctx->wox;
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++) {
rr = &r->ranges[i];
if (rr->nx != 0) {
@@ -2014,7 +2015,7 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
void
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
@@ -2043,7 +2044,7 @@ void
tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
{
tty->flags |= TTY_NOBLOCK;
tty_add(tty, ctx->ptr, ctx->num);
tty_add(tty, ctx->data.data, ctx->data.size);
tty_invalidate(tty);
}