diff --git a/screen-redraw.c b/screen-redraw.c index d0049098..a1b44831 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1117,11 +1117,11 @@ screen_redraw_is_visible(struct visible_ranges *r, u_int px) /* * Construct ranges array for the line at starting at px,py of width cells of - * base_wp that are unobsructed. + * base_wp that are unobsructed. All ranges are in window coordinates. */ struct visible_ranges * -screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, - u_int py, u_int width, struct visible_ranges *r) +screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px, + int py, u_int width, struct visible_ranges *r) { struct window_pane *wp; struct window *w; @@ -1131,11 +1131,25 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, u_int lb, rb, tb, bb; u_int i, s; + if (px + width <= 0 || py < 0) { + if (r == NULL) { + if (sr.ranges == NULL) + sr.ranges = xcalloc(1, sizeof *sr.ranges); + sr.size = 1; + sr.used = 0; + return (&sr); + } + r->used = 0; + return (r); + } + if (px < 0) { + px = 0; + width += px; + } + if (base_wp == NULL) { if (r != NULL) return (r); - - /* Return static range as last resort. */ if (sr.ranges == NULL) sr.ranges = xcalloc(1, sizeof *sr.ranges); sr.ranges[0].px = px; @@ -1172,10 +1186,10 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, bb = wp->yoff + wp->sy; if (!found_self || !window_pane_visible(wp) || - py < tb || - py > bb) + (u_int)py < tb || + (u_int)py > bb) continue; - if (~wp->flags & PANE_FLOATING && py == bb) + if (~wp->flags & PANE_FLOATING && (u_int)py == bb) continue; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; diff --git a/screen-write.c b/screen-write.c index fe39b353..3e57ba84 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1129,7 +1129,7 @@ screen_write_redraw_line(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, struct screen *s = ctx->s; struct grid_cell gc, ngc; u_int sx = screen_size_x(s), cx, i, n; - u_int xoff = wp->xoff, yoff = wp->yoff; + int xoff = wp->xoff, yoff = wp->yoff; struct visible_ranges *r; struct visible_range *ri; diff --git a/tmux.h b/tmux.h index 23f831cc..95af18fb 100644 --- a/tmux.h +++ b/tmux.h @@ -3359,7 +3359,7 @@ void screen_redraw_screen(struct client *); void screen_redraw_pane(struct client *, struct window_pane *, int); int screen_redraw_is_visible(struct visible_ranges *, u_int); struct visible_ranges *screen_redraw_get_visible_ranges(struct window_pane *, - u_int, u_int, u_int, struct visible_ranges *); + int, int, u_int, struct visible_ranges *); /* screen.c */ void screen_init(struct screen *, u_int, u_int, u_int); diff --git a/tty.c b/tty.c index c281e787..f201ba1d 100644 --- a/tty.c +++ b/tty.c @@ -2029,10 +2029,11 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx *ctx) px = ctx->xoff + ctx->ocx - ctx->wox; py = ctx->yoff + ctx->ocy - ctx->woy; - if (!tty_is_visible(tty, ctx, ctx->ocx, ctx->ocy, 1, 1) || - (gcp->data.width == 1 && !tty_check_overlay(tty, px, py))) + if (!tty_is_visible(tty, ctx, ctx->ocx, ctx->ocy, 1, 1)) return; + if (gcp->data.width == 1 && !tty_check_overlay(tty, px, py)) + return; if (gcp->data.width > 1) { /* could be partially obscured */ r = tty_check_overlay_range(tty, px, py, gcp->data.width); for (i = 0; i < r->used; i++)