mirror of
https://github.com/tmux/tmux.git
synced 2026-04-16 03:56:28 +00:00
Clamp width to terminal width, also change calculation of end of screen
(it is OK to be outside the screen). Fixes problem reported by Dane Jensen in GitHub issue 4969.
This commit is contained in:
19
tty-draw.c
19
tty-draw.c
@@ -143,6 +143,14 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
|||||||
log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__, px, py, nx,
|
log_debug("%s: px=%u py=%u nx=%u atx=%u aty=%u", __func__, px, py, nx,
|
||||||
atx, aty);
|
atx, aty);
|
||||||
|
|
||||||
|
/* There is no point in drawing more than the end of the terminal. */
|
||||||
|
if (atx >= tty->sx)
|
||||||
|
return;
|
||||||
|
if (atx + nx >= tty->sx)
|
||||||
|
nx = tty->sx - atx;
|
||||||
|
if (nx == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clamp the width to cellsize - note this is not cellused, because
|
* Clamp the width to cellsize - note this is not cellused, because
|
||||||
* there may be empty background cells after it (from BCE).
|
* there may be empty background cells after it (from BCE).
|
||||||
@@ -150,15 +158,8 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
|||||||
cellsize = grid_get_line(gd, gd->hsize + py)->cellsize;
|
cellsize = grid_get_line(gd, gd->hsize + py)->cellsize;
|
||||||
if (screen_size_x(s) > cellsize)
|
if (screen_size_x(s) > cellsize)
|
||||||
ex = cellsize;
|
ex = cellsize;
|
||||||
else {
|
else
|
||||||
ex = screen_size_x(s);
|
ex = screen_size_x(s);
|
||||||
if (px > ex)
|
|
||||||
return;
|
|
||||||
if (px + nx > ex)
|
|
||||||
nx = ex - px;
|
|
||||||
}
|
|
||||||
if (ex < nx)
|
|
||||||
ex = nx;
|
|
||||||
log_debug("%s: drawing %u-%u,%u (end %u) at %u,%u; defaults: fg=%d, "
|
log_debug("%s: drawing %u-%u,%u (end %u) at %u,%u; defaults: fg=%d, "
|
||||||
"bg=%d", __func__, px, px + nx, py, ex, atx, aty, defaults->fg,
|
"bg=%d", __func__, px, px + nx, py, ex, atx, aty, defaults->fg,
|
||||||
defaults->bg);
|
defaults->bg);
|
||||||
@@ -252,7 +253,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Work out the the empty width. */
|
/* Work out the the empty width. */
|
||||||
if (i >= ex)
|
if (px >= ex || i >= ex - px)
|
||||||
empty = 1;
|
empty = 1;
|
||||||
else if (gcp->bg != last.bg)
|
else if (gcp->bg != last.bg)
|
||||||
empty = 0;
|
empty = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user