mirror of
https://github.com/tmux/tmux.git
synced 2026-02-14 01:59:18 +00:00
Change overlay_ranges into visible_ranges.
This commit is contained in:
70
tty.c
70
tty.c
@@ -66,7 +66,8 @@ static void tty_emulate_repeat(struct tty *, enum tty_code_code,
|
||||
enum tty_code_code, u_int);
|
||||
static void tty_draw_pane(struct tty *, const struct tty_ctx *, u_int);
|
||||
static int tty_check_overlay(struct tty *, u_int, u_int);
|
||||
struct visible_ranges *tty_check_overlay_range(struct tty *, u_int, u_int, u_int);
|
||||
void tty_check_overlay_range(struct tty *, u_int, u_int, u_int,
|
||||
struct visible_ranges *);
|
||||
|
||||
#ifdef ENABLE_SIXEL
|
||||
static void tty_write_one(void (*)(struct tty *, const struct tty_ctx *),
|
||||
@@ -1160,8 +1161,6 @@ tty_clear_line(struct tty *tty, const struct grid_cell *defaults, u_int py,
|
||||
u_int px, u_int nx, u_int bg)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
struct visible_ranges *r;
|
||||
u_int i;
|
||||
|
||||
log_debug("%s: %s, %u at %u,%u", __func__, c->name, nx, px, py);
|
||||
|
||||
@@ -1199,15 +1198,6 @@ tty_clear_line(struct tty *tty, const struct grid_cell *defaults, u_int py,
|
||||
*/
|
||||
tty_cursor(tty, px, py);
|
||||
tty_repeat_space(tty, nx);
|
||||
/*
|
||||
r = tty_check_overlay_range(tty, px, py, nx);
|
||||
for (i = 0; i < r->used; i++) {
|
||||
if (r->nx[i] == 0)
|
||||
continue;
|
||||
tty_cursor(tty, r->px[i], py);
|
||||
tty_repeat_space(tty, r->nx[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* Clear a line, adjusting to visible part of pane. */
|
||||
@@ -1442,41 +1432,45 @@ tty_cell_width(const struct grid_cell *gcp, u_int atcol)
|
||||
static int
|
||||
tty_check_overlay(struct tty *tty, u_int px, u_int py)
|
||||
{
|
||||
struct visible_ranges *r;
|
||||
static struct visible_ranges r = { NULL, 0, 0 };
|
||||
|
||||
/*
|
||||
* A unit width range will always return nx[2] == 0 from a check, even
|
||||
* with multiple overlays, so it's sufficient to check just the first
|
||||
* two entries.
|
||||
*/
|
||||
r = tty_check_overlay_range(tty, px, py, 1);
|
||||
if (r->nx[0] + r->nx[1] == 0)
|
||||
if (r.size == 0) {
|
||||
r.ranges = xcalloc(2, sizeof(struct visible_range));
|
||||
r.size = 2;
|
||||
}
|
||||
|
||||
tty_check_overlay_range(tty, px, py, 1, &r);
|
||||
if (r.ranges[0].nx + r.ranges[1].nx == 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Return parts of the input range which are visible. */
|
||||
struct visible_ranges *
|
||||
tty_check_overlay_range(struct tty *tty, u_int px, u_int py, u_int nx)
|
||||
void
|
||||
tty_check_overlay_range(struct tty *tty, u_int px, u_int py, u_int nx,
|
||||
struct visible_ranges *r)
|
||||
{
|
||||
static struct visible_ranges r = {NULL, NULL, 0, 0};
|
||||
struct client *c = tty->client;
|
||||
|
||||
/* For efficiency vr is static and space reused. */
|
||||
if (r.size == 0) {
|
||||
r.px = xcalloc(1, sizeof(u_int));
|
||||
r.nx = xcalloc(1, sizeof(u_int));
|
||||
r.size = 1;
|
||||
if (r->size == 0) {
|
||||
r->ranges = xcalloc(2, sizeof(struct visible_range));
|
||||
r->size = 2;
|
||||
}
|
||||
|
||||
if (c->overlay_check == NULL) {
|
||||
r.px[0] = px;
|
||||
r.nx[0] = nx;
|
||||
r.used = 1;
|
||||
return (&r);
|
||||
r->ranges[0].px = px;
|
||||
r->ranges[0].nx = nx;
|
||||
r->used = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
return (c->overlay_check(c, c->overlay_data, px, py, nx));
|
||||
c->overlay_check(c, c->overlay_data, px, py, nx, r);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SIXEL
|
||||
@@ -2004,7 +1998,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
|
||||
{
|
||||
const struct grid_cell *gcp = ctx->cell;
|
||||
struct screen *s = ctx->s;
|
||||
struct visible_ranges *r;
|
||||
static struct visible_ranges r = { NULL, 0, 0 };
|
||||
u_int px, py, i, vis = 0;
|
||||
|
||||
px = ctx->xoff + ctx->ocx - ctx->wox;
|
||||
@@ -2021,9 +2015,9 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
|
||||
|
||||
/* Handle partially obstructed wide characters. */
|
||||
if (gcp->data.width > 1) {
|
||||
r = tty_check_overlay_range(tty, px, py, gcp->data.width);
|
||||
for (i = 0; i < r->used; i++)
|
||||
vis += r->nx[i];
|
||||
tty_check_overlay_range(tty, px, py, gcp->data.width, &r);
|
||||
for (i = 0; i < r.used; i++)
|
||||
vis += r.ranges[i].nx;
|
||||
if (vis < gcp->data.width) {
|
||||
tty_draw_line(tty, s, s->cx, s->cy, gcp->data.width,
|
||||
px, py, &ctx->defaults, ctx->palette);
|
||||
@@ -2049,7 +2043,7 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx)
|
||||
void
|
||||
tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
|
||||
{
|
||||
struct visible_ranges *r;
|
||||
struct visible_ranges r = { NULL, 0, 0 };
|
||||
u_int i, px, py, cx;
|
||||
char *cp = ctx->ptr;
|
||||
|
||||
@@ -2080,14 +2074,14 @@ 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);
|
||||
for (i = 0; i < r->used; i++) {
|
||||
if (r->nx[i] == 0)
|
||||
tty_check_overlay_range(tty, px, py, ctx->num, &r);
|
||||
for (i = 0; i < r.used; i++) {
|
||||
if (r.ranges[i].nx == 0)
|
||||
continue;
|
||||
/* Convert back to pane position for printing. */
|
||||
cx = r->px[i] - ctx->xoff + ctx->wox;
|
||||
cx = r.ranges[i].px - ctx->xoff + ctx->wox;
|
||||
tty_cursor_pane_unless_wrap(tty, ctx, cx, ctx->ocy);
|
||||
tty_putn(tty, cp + r->px[i] - px, r->nx[i], r->nx[i]);
|
||||
tty_putn(tty, cp + r.ranges[i].px - px, r.ranges[i].nx, r.ranges[i].nx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user