1
0
mirror of https://github.com/tmux/tmux.git synced 2025-03-29 02:08:48 +00:00

Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2016-10-13 22:01:12 +01:00
commit ad5a561adb
13 changed files with 280 additions and 204 deletions

View File

@ -47,7 +47,7 @@ grid_view_set_cell(struct grid *gd, u_int px, u_int py,
/* Clear into history. */ /* Clear into history. */
void void
grid_view_clear_history(struct grid *gd) grid_view_clear_history(struct grid *gd, u_int bg)
{ {
struct grid_line *gl; struct grid_line *gl;
u_int yy, last; u_int yy, last;
@ -56,28 +56,33 @@ grid_view_clear_history(struct grid *gd)
last = 0; last = 0;
for (yy = 0; yy < gd->sy; yy++) { for (yy = 0; yy < gd->sy; yy++) {
gl = &gd->linedata[grid_view_y(gd, yy)]; gl = &gd->linedata[grid_view_y(gd, yy)];
if (gl->cellsize != 0) if (gl->cellused != 0)
last = yy + 1; last = yy + 1;
} }
if (last == 0) if (last == 0) {
grid_view_clear(gd, 0, 0, gd->sx, gd->sy, bg);
return; return;
}
/* Scroll the lines into the history. */ /* Scroll the lines into the history. */
for (yy = 0; yy < last; yy++) { for (yy = 0; yy < last; yy++) {
grid_collect_history(gd); grid_collect_history(gd, bg);
grid_scroll_history(gd); grid_scroll_history(gd, bg);
} }
if (last < gd->sy)
grid_view_clear(gd, 0, 0, gd->sx, gd->sy - last, bg);
gd->hscrolled = 0; gd->hscrolled = 0;
} }
/* Clear area. */ /* Clear area. */
void void
grid_view_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny) grid_view_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny,
u_int bg)
{ {
px = grid_view_x(gd, px); px = grid_view_x(gd, px);
py = grid_view_y(gd, py); py = grid_view_y(gd, py);
grid_clear(gd, px, py, nx, ny); grid_clear(gd, px, py, nx, ny, bg);
} }
/* Scroll region up. */ /* Scroll region up. */
@ -85,9 +90,9 @@ void
grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower) grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower)
{ {
if (gd->flags & GRID_HISTORY) { if (gd->flags & GRID_HISTORY) {
grid_collect_history(gd); grid_collect_history(gd, 8);
if (rupper == 0 && rlower == gd->sy - 1) if (rupper == 0 && rlower == gd->sy - 1)
grid_scroll_history(gd); grid_scroll_history(gd, 8);
else { else {
rupper = grid_view_y(gd, rupper); rupper = grid_view_y(gd, rupper);
rlower = grid_view_y(gd, rlower); rlower = grid_view_y(gd, rlower);
@ -96,7 +101,7 @@ grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower)
} else { } else {
rupper = grid_view_y(gd, rupper); rupper = grid_view_y(gd, rupper);
rlower = grid_view_y(gd, rlower); rlower = grid_view_y(gd, rlower);
grid_move_lines(gd, rupper, rupper + 1, rlower - rupper); grid_move_lines(gd, rupper, rupper + 1, rlower - rupper, 8);
} }
} }
@ -107,12 +112,12 @@ grid_view_scroll_region_down(struct grid *gd, u_int rupper, u_int rlower)
rupper = grid_view_y(gd, rupper); rupper = grid_view_y(gd, rupper);
rlower = grid_view_y(gd, rlower); rlower = grid_view_y(gd, rlower);
grid_move_lines(gd, rupper + 1, rupper, rlower - rupper); grid_move_lines(gd, rupper + 1, rupper, rlower - rupper, 8);
} }
/* Insert lines. */ /* Insert lines. */
void void
grid_view_insert_lines(struct grid *gd, u_int py, u_int ny) grid_view_insert_lines(struct grid *gd, u_int py, u_int ny, u_int bg)
{ {
u_int sy; u_int sy;
@ -120,13 +125,13 @@ grid_view_insert_lines(struct grid *gd, u_int py, u_int ny)
sy = grid_view_y(gd, gd->sy); sy = grid_view_y(gd, gd->sy);
grid_move_lines(gd, py + ny, py, sy - py - ny); grid_move_lines(gd, py + ny, py, sy - py - ny, bg);
} }
/* Insert lines in region. */ /* Insert lines in region. */
void void
grid_view_insert_lines_region(struct grid *gd, u_int rlower, u_int py, grid_view_insert_lines_region(struct grid *gd, u_int rlower, u_int py,
u_int ny) u_int ny, u_int bg)
{ {
u_int ny2; u_int ny2;
@ -135,13 +140,13 @@ grid_view_insert_lines_region(struct grid *gd, u_int rlower, u_int py,
py = grid_view_y(gd, py); py = grid_view_y(gd, py);
ny2 = rlower + 1 - py - ny; ny2 = rlower + 1 - py - ny;
grid_move_lines(gd, rlower + 1 - ny2, py, ny2); grid_move_lines(gd, rlower + 1 - ny2, py, ny2, bg);
grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2); grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2, bg);
} }
/* Delete lines. */ /* Delete lines. */
void void
grid_view_delete_lines(struct grid *gd, u_int py, u_int ny) grid_view_delete_lines(struct grid *gd, u_int py, u_int ny, u_int bg)
{ {
u_int sy; u_int sy;
@ -149,14 +154,14 @@ grid_view_delete_lines(struct grid *gd, u_int py, u_int ny)
sy = grid_view_y(gd, gd->sy); sy = grid_view_y(gd, gd->sy);
grid_move_lines(gd, py, py + ny, sy - py - ny); grid_move_lines(gd, py, py + ny, sy - py - ny, bg);
grid_clear(gd, 0, sy - ny, gd->sx, py + ny - (sy - ny)); grid_clear(gd, 0, sy - ny, gd->sx, py + ny - (sy - ny), bg);
} }
/* Delete lines inside scroll region. */ /* Delete lines inside scroll region. */
void void
grid_view_delete_lines_region(struct grid *gd, u_int rlower, u_int py, grid_view_delete_lines_region(struct grid *gd, u_int rlower, u_int py,
u_int ny) u_int ny, u_int bg)
{ {
u_int ny2; u_int ny2;
@ -165,13 +170,13 @@ grid_view_delete_lines_region(struct grid *gd, u_int rlower, u_int py,
py = grid_view_y(gd, py); py = grid_view_y(gd, py);
ny2 = rlower + 1 - py - ny; ny2 = rlower + 1 - py - ny;
grid_move_lines(gd, py, py + ny, ny2); grid_move_lines(gd, py, py + ny, ny2, bg);
grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2); grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2, bg);
} }
/* Insert characters. */ /* Insert characters. */
void void
grid_view_insert_cells(struct grid *gd, u_int px, u_int py, u_int nx) grid_view_insert_cells(struct grid *gd, u_int px, u_int py, u_int nx, u_int bg)
{ {
u_int sx; u_int sx;
@ -181,14 +186,14 @@ grid_view_insert_cells(struct grid *gd, u_int px, u_int py, u_int nx)
sx = grid_view_x(gd, gd->sx); sx = grid_view_x(gd, gd->sx);
if (px == sx - 1) if (px == sx - 1)
grid_clear(gd, px, py, 1, 1); grid_clear(gd, px, py, 1, 1, bg);
else else
grid_move_cells(gd, px + nx, px, py, sx - px - nx); grid_move_cells(gd, px + nx, px, py, sx - px - nx, bg);
} }
/* Delete characters. */ /* Delete characters. */
void void
grid_view_delete_cells(struct grid *gd, u_int px, u_int py, u_int nx) grid_view_delete_cells(struct grid *gd, u_int px, u_int py, u_int nx, u_int bg)
{ {
u_int sx; u_int sx;
@ -197,8 +202,8 @@ grid_view_delete_cells(struct grid *gd, u_int px, u_int py, u_int nx)
sx = grid_view_x(gd, gd->sx); sx = grid_view_x(gd, gd->sx);
grid_move_cells(gd, px, px + nx, py, sx - px - nx); grid_move_cells(gd, px, px + nx, py, sx - px - nx, bg);
grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1); grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1, bg);
} }
/* Convert cells into a string. */ /* Convert cells into a string. */

106
grid.c
View File

@ -43,7 +43,8 @@ const struct grid_cell_entry grid_default_entry = {
0, { .data = { 0, 8, 8, ' ' } } 0, { .data = { 0, 8, 8, ' ' } }
}; };
static void grid_expand_line(struct grid *, u_int, u_int); static void grid_expand_line(struct grid *, u_int, u_int, u_int);
static void grid_empty_line(struct grid *, u_int, u_int);
static void grid_reflow_copy(struct grid_line *, u_int, struct grid_line *, static void grid_reflow_copy(struct grid_line *, u_int, struct grid_line *,
u_int, u_int); u_int, u_int);
@ -60,9 +61,10 @@ static void grid_string_cells_code(const struct grid_cell *,
/* Copy default into a cell. */ /* Copy default into a cell. */
static void static void
grid_clear_cell(struct grid *gd, u_int px, u_int py) grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)
{ {
gd->linedata[py].celldata[px] = grid_default_entry; gd->linedata[py].celldata[px] = grid_default_entry;
gd->linedata[py].celldata[px].data.bg = bg;
} }
/* Check grid y position. */ /* Check grid y position. */
@ -162,7 +164,7 @@ grid_compare(struct grid *ga, struct grid *gb)
* and shift up. * and shift up.
*/ */
void void
grid_collect_history(struct grid *gd) grid_collect_history(struct grid *gd, u_int bg)
{ {
u_int yy; u_int yy;
@ -173,7 +175,7 @@ grid_collect_history(struct grid *gd)
if (yy < 1) if (yy < 1)
yy = 1; yy = 1;
grid_move_lines(gd, 0, yy, gd->hsize + gd->sy - yy); grid_move_lines(gd, 0, yy, gd->hsize + gd->sy - yy, bg);
gd->hsize -= yy; gd->hsize -= yy;
if (gd->hscrolled > gd->hsize) if (gd->hscrolled > gd->hsize)
gd->hscrolled = gd->hsize; gd->hscrolled = gd->hsize;
@ -184,14 +186,14 @@ grid_collect_history(struct grid *gd)
* allocate a new line at the bottom and move the history size indicator. * allocate a new line at the bottom and move the history size indicator.
*/ */
void void
grid_scroll_history(struct grid *gd) grid_scroll_history(struct grid *gd, u_int bg)
{ {
u_int yy; u_int yy;
yy = gd->hsize + gd->sy; yy = gd->hsize + gd->sy;
gd->linedata = xreallocarray(gd->linedata, yy + 1, gd->linedata = xreallocarray(gd->linedata, yy + 1,
sizeof *gd->linedata); sizeof *gd->linedata);
memset(&gd->linedata[yy], 0, sizeof gd->linedata[yy]); grid_empty_line(gd, yy, bg);
gd->hscrolled++; gd->hscrolled++;
gd->hsize++; gd->hsize++;
@ -201,8 +203,8 @@ grid_scroll_history(struct grid *gd)
void void
grid_clear_history(struct grid *gd) grid_clear_history(struct grid *gd)
{ {
grid_clear_lines(gd, 0, gd->hsize); grid_clear_lines(gd, 0, gd->hsize, 8);
grid_move_lines(gd, 0, gd->hsize, gd->sy); grid_move_lines(gd, 0, gd->hsize, gd->sy, 8);
gd->hscrolled = 0; gd->hscrolled = 0;
gd->hsize = 0; gd->hsize = 0;
@ -247,7 +249,7 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower)
/* Expand line to fit to cell. */ /* Expand line to fit to cell. */
static void static void
grid_expand_line(struct grid *gd, u_int py, u_int sx) grid_expand_line(struct grid *gd, u_int py, u_int sx, u_int bg)
{ {
struct grid_line *gl; struct grid_line *gl;
u_int xx; u_int xx;
@ -258,10 +260,19 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx)
gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata); gl->celldata = xreallocarray(gl->celldata, sx, sizeof *gl->celldata);
for (xx = gl->cellsize; xx < sx; xx++) for (xx = gl->cellsize; xx < sx; xx++)
grid_clear_cell(gd, xx, py); grid_clear_cell(gd, xx, py, bg);
gl->cellsize = sx; gl->cellsize = sx;
} }
/* Empty a line and set background colour if needed. */
static void
grid_empty_line(struct grid *gd, u_int py, u_int bg)
{
memset(&gd->linedata[py], 0, sizeof gd->linedata[py]);
if (bg != 8)
grid_expand_line(gd, py, gd->sx, bg);
}
/* Peek at grid line. */ /* Peek at grid line. */
const struct grid_line * const struct grid_line *
grid_peek_line(struct grid *gd, u_int py) grid_peek_line(struct grid *gd, u_int py)
@ -317,11 +328,14 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
if (grid_check_y(gd, py) != 0) if (grid_check_y(gd, py) != 0)
return; return;
grid_expand_line(gd, py, px + 1); grid_expand_line(gd, py, px + 1, 8);
gl = &gd->linedata[py]; gl = &gd->linedata[py];
gce = &gl->celldata[px]; gce = &gl->celldata[px];
if (px + 1 > gl->cellused)
gl->cellused = px + 1;
extended = (gce->flags & GRID_FLAG_EXTENDED); extended = (gce->flags & GRID_FLAG_EXTENDED);
if (!extended && (gc->data.size != 1 || gc->data.width != 1)) if (!extended && (gc->data.size != 1 || gc->data.width != 1))
extended = 1; extended = 1;
@ -358,7 +372,7 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
/* Clear area. */ /* Clear area. */
void void
grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny) grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg)
{ {
u_int xx, yy; u_int xx, yy;
@ -366,7 +380,7 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)
return; return;
if (px == 0 && nx == gd->sx) { if (px == 0 && nx == gd->sx) {
grid_clear_lines(gd, py, ny); grid_clear_lines(gd, py, ny, bg);
return; return;
} }
@ -376,23 +390,23 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)
return; return;
for (yy = py; yy < py + ny; yy++) { for (yy = py; yy < py + ny; yy++) {
if (px >= gd->linedata[yy].cellsize) if (px + nx >= gd->sx && px < gd->linedata[yy].cellused)
gd->linedata[yy].cellused = px;
if (px > gd->linedata[yy].cellsize && bg == 8)
continue; continue;
if (px + nx >= gd->linedata[yy].cellsize) { if (px + nx >= gd->linedata[yy].cellsize && bg == 8) {
gd->linedata[yy].cellsize = px; gd->linedata[yy].cellsize = px;
continue; continue;
} }
for (xx = px; xx < px + nx; xx++) { grid_expand_line(gd, yy, px + nx, bg);
if (xx >= gd->linedata[yy].cellsize) for (xx = px; xx < px + nx; xx++)
break; grid_clear_cell(gd, xx, yy, bg);
grid_clear_cell(gd, xx, yy);
}
} }
} }
/* Clear lines. This just frees and truncates the lines. */ /* Clear lines. This just frees and truncates the lines. */
void void
grid_clear_lines(struct grid *gd, u_int py, u_int ny) grid_clear_lines(struct grid *gd, u_int py, u_int ny, u_int bg)
{ {
struct grid_line *gl; struct grid_line *gl;
u_int yy; u_int yy;
@ -409,13 +423,13 @@ grid_clear_lines(struct grid *gd, u_int py, u_int ny)
gl = &gd->linedata[yy]; gl = &gd->linedata[yy];
free(gl->celldata); free(gl->celldata);
free(gl->extddata); free(gl->extddata);
memset(gl, 0, sizeof *gl); grid_empty_line(gd, yy, bg);
} }
} }
/* Move a group of lines. */ /* Move a group of lines. */
void void
grid_move_lines(struct grid *gd, u_int dy, u_int py, u_int ny) grid_move_lines(struct grid *gd, u_int dy, u_int py, u_int ny, u_int bg)
{ {
u_int yy; u_int yy;
@ -435,7 +449,7 @@ grid_move_lines(struct grid *gd, u_int dy, u_int py, u_int ny)
for (yy = dy; yy < dy + ny; yy++) { for (yy = dy; yy < dy + ny; yy++) {
if (yy >= py && yy < py + ny) if (yy >= py && yy < py + ny)
continue; continue;
grid_clear_lines(gd, yy, 1); grid_clear_lines(gd, yy, 1, bg);
} }
memmove(&gd->linedata[dy], &gd->linedata[py], memmove(&gd->linedata[dy], &gd->linedata[py],
@ -443,15 +457,15 @@ grid_move_lines(struct grid *gd, u_int dy, u_int py, u_int ny)
/* Wipe any lines that have been moved (without freeing them). */ /* Wipe any lines that have been moved (without freeing them). */
for (yy = py; yy < py + ny; yy++) { for (yy = py; yy < py + ny; yy++) {
if (yy >= dy && yy < dy + ny) if (yy < dy || yy >= dy + ny)
continue; grid_empty_line(gd, yy, bg);
memset(&gd->linedata[yy], 0, sizeof gd->linedata[yy]);
} }
} }
/* Move a group of cells. */ /* Move a group of cells. */
void void
grid_move_cells(struct grid *gd, u_int dx, u_int px, u_int py, u_int nx) grid_move_cells(struct grid *gd, u_int dx, u_int px, u_int py, u_int nx,
u_int bg)
{ {
struct grid_line *gl; struct grid_line *gl;
u_int xx; u_int xx;
@ -463,8 +477,8 @@ grid_move_cells(struct grid *gd, u_int dx, u_int px, u_int py, u_int nx)
return; return;
gl = &gd->linedata[py]; gl = &gd->linedata[py];
grid_expand_line(gd, py, px + nx); grid_expand_line(gd, py, px + nx, 8);
grid_expand_line(gd, py, dx + nx); grid_expand_line(gd, py, dx + nx, 8);
memmove(&gl->celldata[dx], &gl->celldata[px], memmove(&gl->celldata[dx], &gl->celldata[px],
nx * sizeof *gl->celldata); nx * sizeof *gl->celldata);
@ -472,7 +486,7 @@ grid_move_cells(struct grid *gd, u_int dx, u_int px, u_int py, u_int nx)
for (xx = px; xx < px + nx; xx++) { for (xx = px; xx < px + nx; xx++) {
if (xx >= dx && xx < dx + nx) if (xx >= dx && xx < dx + nx)
continue; continue;
grid_clear_cell(gd, xx, py); grid_clear_cell(gd, xx, py, bg);
} }
} }
@ -748,7 +762,7 @@ grid_duplicate_lines(struct grid *dst, u_int dy, struct grid *src, u_int sy,
ny = dst->hsize + dst->sy - dy; ny = dst->hsize + dst->sy - dy;
if (sy + ny > src->hsize + src->sy) if (sy + ny > src->hsize + src->sy)
ny = src->hsize + src->sy - sy; ny = src->hsize + src->sy - sy;
grid_clear_lines(dst, dy, ny); grid_clear_lines(dst, dy, ny, 8);
for (yy = 0; yy < ny; yy++) { for (yy = 0; yy < ny; yy++) {
srcl = &src->linedata[sy]; srcl = &src->linedata[sy];
@ -810,28 +824,28 @@ grid_reflow_join(struct grid *dst, u_int *py, struct grid_line *src_gl,
u_int left, to_copy, ox, nx; u_int left, to_copy, ox, nx;
/* How much is left on the old line? */ /* How much is left on the old line? */
left = new_x - dst_gl->cellsize; left = new_x - dst_gl->cellused;
/* Work out how much to append. */ /* Work out how much to append. */
to_copy = src_gl->cellsize; to_copy = src_gl->cellused;
if (to_copy > left) if (to_copy > left)
to_copy = left; to_copy = left;
ox = dst_gl->cellsize; ox = dst_gl->cellused;
nx = ox + to_copy; nx = ox + to_copy;
/* Resize the destination line. */ /* Resize the destination line. */
dst_gl->celldata = xreallocarray(dst_gl->celldata, nx, dst_gl->celldata = xreallocarray(dst_gl->celldata, nx,
sizeof *dst_gl->celldata); sizeof *dst_gl->celldata);
dst_gl->cellsize = nx; dst_gl->cellsize = dst_gl->cellused = nx;
/* Append as much as possible. */ /* Append as much as possible. */
grid_reflow_copy(dst_gl, ox, src_gl, 0, to_copy); grid_reflow_copy(dst_gl, ox, src_gl, 0, to_copy);
/* If there is any left in the source, split it. */ /* If there is any left in the source, split it. */
if (src_gl->cellsize > to_copy) { if (src_gl->cellused > to_copy) {
dst_gl->flags |= GRID_LINE_WRAPPED; dst_gl->flags |= GRID_LINE_WRAPPED;
src_gl->cellsize -= to_copy; src_gl->cellused -= to_copy;
grid_reflow_split(dst, py, src_gl, new_x, to_copy); grid_reflow_split(dst, py, src_gl, new_x, to_copy);
} }
} }
@ -845,22 +859,22 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
u_int to_copy; u_int to_copy;
/* Loop and copy sections of the source line. */ /* Loop and copy sections of the source line. */
while (src_gl->cellsize > 0) { while (src_gl->cellused > 0) {
/* Create new line. */ /* Create new line. */
if (*py >= dst->hsize + dst->sy) if (*py >= dst->hsize + dst->sy)
grid_scroll_history(dst); grid_scroll_history(dst, 8);
dst_gl = &dst->linedata[*py]; dst_gl = &dst->linedata[*py];
(*py)++; (*py)++;
/* How much should we copy? */ /* How much should we copy? */
to_copy = new_x; to_copy = new_x;
if (to_copy > src_gl->cellsize) if (to_copy > src_gl->cellused)
to_copy = src_gl->cellsize; to_copy = src_gl->cellused;
/* Expand destination line. */ /* Expand destination line. */
dst_gl->celldata = xreallocarray(NULL, to_copy, dst_gl->celldata = xreallocarray(NULL, to_copy,
sizeof *dst_gl->celldata); sizeof *dst_gl->celldata);
dst_gl->cellsize = to_copy; dst_gl->cellsize = dst_gl->cellused = to_copy;
dst_gl->flags |= GRID_LINE_WRAPPED; dst_gl->flags |= GRID_LINE_WRAPPED;
/* Copy the data. */ /* Copy the data. */
@ -868,7 +882,7 @@ grid_reflow_split(struct grid *dst, u_int *py, struct grid_line *src_gl,
/* Move offset and reduce old line size. */ /* Move offset and reduce old line size. */
offset += to_copy; offset += to_copy;
src_gl->cellsize -= to_copy; src_gl->cellused -= to_copy;
} }
/* Last line is not wrapped. */ /* Last line is not wrapped. */
@ -884,7 +898,7 @@ grid_reflow_move(struct grid *dst, u_int *py, struct grid_line *src_gl)
/* Create new line. */ /* Create new line. */
if (*py >= dst->hsize + dst->sy) if (*py >= dst->hsize + dst->sy)
grid_scroll_history(dst); grid_scroll_history(dst, 8);
dst_gl = &dst->linedata[*py]; dst_gl = &dst->linedata[*py];
(*py)++; (*py)++;
@ -916,7 +930,7 @@ grid_reflow(struct grid *dst, struct grid *src, u_int new_x)
src_gl = src->linedata + line; src_gl = src->linedata + line;
if (!previous_wrapped) { if (!previous_wrapped) {
/* Wasn't wrapped. If smaller, move to destination. */ /* Wasn't wrapped. If smaller, move to destination. */
if (src_gl->cellsize <= new_x) if (src_gl->cellused <= new_x)
grid_reflow_move(dst, &py, src_gl); grid_reflow_move(dst, &py, src_gl);
else else
grid_reflow_split(dst, &py, src_gl, new_x, 0); grid_reflow_split(dst, &py, src_gl, new_x, 0);

28
input.c
View File

@ -1283,7 +1283,8 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_clearcharacter(sctx, input_get(ictx, 0, 1, 1)); screen_write_clearcharacter(sctx, input_get(ictx, 0, 1, 1));
break; break;
case INPUT_CSI_DCH: case INPUT_CSI_DCH:
screen_write_deletecharacter(sctx, input_get(ictx, 0, 1, 1)); screen_write_deletecharacter(sctx, input_get(ictx, 0, 1, 1),
ictx->cell.cell.bg);
break; break;
case INPUT_CSI_DECSTBM: case INPUT_CSI_DECSTBM:
n = input_get(ictx, 0, 1, 1); n = input_get(ictx, 0, 1, 1);
@ -1291,7 +1292,8 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_scrollregion(sctx, n - 1, m - 1); screen_write_scrollregion(sctx, n - 1, m - 1);
break; break;
case INPUT_CSI_DL: case INPUT_CSI_DL:
screen_write_deleteline(sctx, input_get(ictx, 0, 1, 1)); screen_write_deleteline(sctx, input_get(ictx, 0, 1, 1),
ictx->cell.cell.bg);
break; break;
case INPUT_CSI_DSR: case INPUT_CSI_DSR:
switch (input_get(ictx, 0, 0, 0)) { switch (input_get(ictx, 0, 0, 0)) {
@ -1309,13 +1311,13 @@ input_csi_dispatch(struct input_ctx *ictx)
case INPUT_CSI_ED: case INPUT_CSI_ED:
switch (input_get(ictx, 0, 0, 0)) { switch (input_get(ictx, 0, 0, 0)) {
case 0: case 0:
screen_write_clearendofscreen(sctx); screen_write_clearendofscreen(sctx, ictx->cell.cell.bg);
break; break;
case 1: case 1:
screen_write_clearstartofscreen(sctx); screen_write_clearstartofscreen(sctx);
break; break;
case 2: case 2:
screen_write_clearscreen(sctx); screen_write_clearscreen(sctx, ictx->cell.cell.bg);
break; break;
case 3: case 3:
switch (input_get(ictx, 1, 0, 0)) { switch (input_get(ictx, 1, 0, 0)) {
@ -1336,13 +1338,13 @@ input_csi_dispatch(struct input_ctx *ictx)
case INPUT_CSI_EL: case INPUT_CSI_EL:
switch (input_get(ictx, 0, 0, 0)) { switch (input_get(ictx, 0, 0, 0)) {
case 0: case 0:
screen_write_clearendofline(sctx); screen_write_clearendofline(sctx, ictx->cell.cell.bg);
break; break;
case 1: case 1:
screen_write_clearstartofline(sctx); screen_write_clearstartofline(sctx, ictx->cell.cell.bg);
break; break;
case 2: case 2:
screen_write_clearline(sctx); screen_write_clearline(sctx, ictx->cell.cell.bg);
break; break;
default: default:
log_debug("%s: unknown '%c'", __func__, ictx->ch); log_debug("%s: unknown '%c'", __func__, ictx->ch);
@ -1354,10 +1356,12 @@ input_csi_dispatch(struct input_ctx *ictx)
screen_write_cursormove(sctx, n - 1, s->cy); screen_write_cursormove(sctx, n - 1, s->cy);
break; break;
case INPUT_CSI_ICH: case INPUT_CSI_ICH:
screen_write_insertcharacter(sctx, input_get(ictx, 0, 1, 1)); screen_write_insertcharacter(sctx, input_get(ictx, 0, 1, 1),
ictx->cell.cell.bg);
break; break;
case INPUT_CSI_IL: case INPUT_CSI_IL:
screen_write_insertline(sctx, input_get(ictx, 0, 1, 1)); screen_write_insertline(sctx, input_get(ictx, 0, 1, 1),
ictx->cell.cell.bg);
break; break;
case INPUT_CSI_RCP: case INPUT_CSI_RCP:
memcpy(&ictx->cell, &ictx->old_cell, sizeof ictx->cell); memcpy(&ictx->cell, &ictx->old_cell, sizeof ictx->cell);
@ -1445,7 +1449,8 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx)
break; break;
case 3: /* DECCOLM */ case 3: /* DECCOLM */
screen_write_cursormove(&ictx->ctx, 0, 0); screen_write_cursormove(&ictx->ctx, 0, 0);
screen_write_clearscreen(&ictx->ctx); screen_write_clearscreen(&ictx->ctx,
ictx->cell.cell.bg);
break; break;
case 7: /* DECAWM */ case 7: /* DECAWM */
screen_write_mode_clear(&ictx->ctx, MODE_WRAP); screen_write_mode_clear(&ictx->ctx, MODE_WRAP);
@ -1522,7 +1527,8 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
break; break;
case 3: /* DECCOLM */ case 3: /* DECCOLM */
screen_write_cursormove(&ictx->ctx, 0, 0); screen_write_cursormove(&ictx->ctx, 0, 0);
screen_write_clearscreen(&ictx->ctx); screen_write_clearscreen(&ictx->ctx,
ictx->cell.cell.bg);
break; break;
case 7: /* DECAWM */ case 7: /* DECAWM */
screen_write_mode_set(&ictx->ctx, MODE_WRAP); screen_write_mode_set(&ictx->ctx, MODE_WRAP);

View File

@ -295,7 +295,7 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
screen_write_start(&ctx, NULL, &wp->status_screen); screen_write_start(&ctx, NULL, &wp->status_screen);
screen_write_cursormove(&ctx, 0, 0); screen_write_cursormove(&ctx, 0, 0);
screen_write_clearline(&ctx); screen_write_clearline(&ctx, 8);
screen_write_cnputs(&ctx, outlen, &gc, "%s", out); screen_write_cnputs(&ctx, outlen, &gc, "%s", out);
screen_write_stop(&ctx); screen_write_stop(&ctx);

View File

@ -147,7 +147,7 @@ screen_write_reset(struct screen_write_ctx *ctx)
s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD|MODE_FOCUSON); s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD|MODE_FOCUSON);
s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_UTF8|MODE_MOUSE_SGR); s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_UTF8|MODE_MOUSE_SGR);
screen_write_clearscreen(ctx); screen_write_clearscreen(ctx, 8);
screen_write_cursormove(ctx, 0, 0); screen_write_cursormove(ctx, 0, 0);
} }
@ -601,7 +601,7 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
/* Insert nx characters. */ /* Insert nx characters. */
void void
screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx) screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
@ -618,15 +618,16 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
if (s->cx <= screen_size_x(s) - 1) if (s->cx <= screen_size_x(s) - 1)
grid_view_insert_cells(s->grid, s->cx, s->cy, nx); grid_view_insert_cells(s->grid, s->cx, s->cy, nx, bg);
ttyctx.num = nx; ttyctx.num = nx;
ttyctx.bg = bg;
tty_write(tty_cmd_insertcharacter, &ttyctx); tty_write(tty_cmd_insertcharacter, &ttyctx);
} }
/* Delete nx characters. */ /* Delete nx characters. */
void void
screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx) screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
@ -643,9 +644,10 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
if (s->cx <= screen_size_x(s) - 1) if (s->cx <= screen_size_x(s) - 1)
grid_view_delete_cells(s->grid, s->cx, s->cy, nx); grid_view_delete_cells(s->grid, s->cx, s->cy, nx, bg);
ttyctx.num = nx; ttyctx.num = nx;
ttyctx.bg = bg;
tty_write(tty_cmd_deletecharacter, &ttyctx); tty_write(tty_cmd_deletecharacter, &ttyctx);
} }
@ -668,7 +670,7 @@ screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx)
if (s->cx <= screen_size_x(s) - 1) { if (s->cx <= screen_size_x(s) - 1) {
screen_dirty_clear(s, s->cx, s->cy, s->cx + nx - 1, s->cy); screen_dirty_clear(s, s->cx, s->cy, s->cx + nx - 1, s->cy);
grid_view_clear(s->grid, s->cx, s->cy, nx, 1); grid_view_clear(s->grid, s->cx, s->cy, nx, 1, 8);
} else } else
return; return;
@ -678,7 +680,7 @@ screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx)
/* Insert ny lines. */ /* Insert ny lines. */
void void
screen_write_insertline(struct screen_write_ctx *ctx, u_int ny) screen_write_insertline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
@ -695,9 +697,10 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
screen_write_flush(ctx); screen_write_flush(ctx);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
grid_view_insert_lines(s->grid, s->cy, ny); grid_view_insert_lines(s->grid, s->cy, ny, bg);
ttyctx.num = ny; ttyctx.num = ny;
ttyctx.bg = bg;
tty_write(tty_cmd_insertline, &ttyctx); tty_write(tty_cmd_insertline, &ttyctx);
return; return;
} }
@ -711,17 +714,20 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
if (s->cy < s->rupper || s->cy > s->rlower) if (s->cy < s->rupper || s->cy > s->rlower)
grid_view_insert_lines(s->grid, s->cy, ny); grid_view_insert_lines(s->grid, s->cy, ny, bg);
else else {
grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny); grid_view_insert_lines_region(s->grid, s->rlower, s->cy, ny,
bg);
}
ttyctx.num = ny; ttyctx.num = ny;
ttyctx.bg = bg;
tty_write(tty_cmd_insertline, &ttyctx); tty_write(tty_cmd_insertline, &ttyctx);
} }
/* Delete ny lines. */ /* Delete ny lines. */
void void
screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny) screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
@ -738,9 +744,10 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
screen_write_flush(ctx); screen_write_flush(ctx);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
grid_view_delete_lines(s->grid, s->cy, ny); grid_view_delete_lines(s->grid, s->cy, ny, bg);
ttyctx.num = ny; ttyctx.num = ny;
ttyctx.bg = bg;
tty_write(tty_cmd_deleteline, &ttyctx); tty_write(tty_cmd_deleteline, &ttyctx);
return; return;
} }
@ -754,17 +761,20 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
if (s->cy < s->rupper || s->cy > s->rlower) if (s->cy < s->rupper || s->cy > s->rlower)
grid_view_delete_lines(s->grid, s->cy, ny); grid_view_delete_lines(s->grid, s->cy, ny, bg);
else else {
grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny); grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny,
bg);
}
ttyctx.num = ny; ttyctx.num = ny;
ttyctx.bg = bg;
tty_write(tty_cmd_deleteline, &ttyctx); tty_write(tty_cmd_deleteline, &ttyctx);
} }
/* Clear line at cursor. */ /* Clear line at cursor. */
void void
screen_write_clearline(struct screen_write_ctx *ctx) screen_write_clearline(struct screen_write_ctx *ctx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid_line *gl; struct grid_line *gl;
@ -772,20 +782,21 @@ screen_write_clearline(struct screen_write_ctx *ctx)
u_int sx = screen_size_x(s); u_int sx = screen_size_x(s);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
ttyctx.bg = bg;
gl = &s->grid->linedata[s->grid->hsize + s->cy]; gl = &s->grid->linedata[s->grid->hsize + s->cy];
if (gl->cellsize != 0) { if (gl->cellsize == 0 && bg == 8)
screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, 0, s->cy, sx, 1);
} else
return; return;
screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, 0, s->cy, sx, 1, bg);
tty_write(tty_cmd_clearline, &ttyctx); tty_write(tty_cmd_clearline, &ttyctx);
} }
/* Clear to end of line from cursor. */ /* Clear to end of line from cursor. */
void void
screen_write_clearendofline(struct screen_write_ctx *ctx) screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid_line *gl; struct grid_line *gl;
@ -793,33 +804,35 @@ screen_write_clearendofline(struct screen_write_ctx *ctx)
u_int sx = screen_size_x(s); u_int sx = screen_size_x(s);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
ttyctx.bg = bg;
gl = &s->grid->linedata[s->grid->hsize + s->cy]; gl = &s->grid->linedata[s->grid->hsize + s->cy];
if (s->cx <= sx - 1 && s->cx < gl->cellsize) { if (s->cx > sx - 1 || (s->cx >= gl->cellsize && bg == 8))
screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
} else
return; return;
screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1, bg);
tty_write(tty_cmd_clearendofline, &ttyctx); tty_write(tty_cmd_clearendofline, &ttyctx);
} }
/* Clear to start of line from cursor. */ /* Clear to start of line from cursor. */
void void
screen_write_clearstartofline(struct screen_write_ctx *ctx) screen_write_clearstartofline(struct screen_write_ctx *ctx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
u_int sx = screen_size_x(s); u_int sx = screen_size_x(s);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
ttyctx.bg = bg;
if (s->cx > sx - 1) { if (s->cx > sx - 1) {
screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy); screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, 0, s->cy, sx, 1); grid_view_clear(s->grid, 0, s->cy, sx, 1, bg);
} else { } else {
screen_dirty_clear(s, 0, s->cy, s->cx, s->cy); screen_dirty_clear(s, 0, s->cy, s->cx, s->cy);
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1); grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, bg);
} }
tty_write(tty_cmd_clearstartofline, &ttyctx); tty_write(tty_cmd_clearstartofline, &ttyctx);
@ -919,25 +932,28 @@ screen_write_carriagereturn(struct screen_write_ctx *ctx)
/* Clear to end of screen from cursor. */ /* Clear to end of screen from cursor. */
void void
screen_write_clearendofscreen(struct screen_write_ctx *ctx) screen_write_clearendofscreen(struct screen_write_ctx *ctx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
u_int sx = screen_size_x(s), sy = screen_size_y(s); u_int sx = screen_size_x(s), sy = screen_size_y(s);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
ttyctx.bg = bg;
/* Scroll into history if it is enabled and clearing entire screen. */ /* Scroll into history if it is enabled and clearing entire screen. */
if (s->cy == 0 && s->grid->flags & GRID_HISTORY) { if (s->cx == 0 && s->cy == 0 && s->grid->flags & GRID_HISTORY) {
screen_dirty_clear(s, 0, 0, sx - 1, sy - 1); screen_dirty_clear(s, 0, 0, sx - 1, sy - 1);
grid_view_clear_history(s->grid); grid_view_clear_history(s->grid, bg);
} else { } else {
if (s->cx <= sx - 1) { if (s->cx <= sx - 1) {
screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy); screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1); grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1,
bg);
} }
screen_dirty_clear(s, 0, s->cy + 1, sx - 1, sy - 1); screen_dirty_clear(s, 0, s->cy + 1, sx - 1, sy - 1);
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1)); grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1),
bg);
} }
tty_write(tty_cmd_clearendofscreen, &ttyctx); tty_write(tty_cmd_clearendofscreen, &ttyctx);
@ -955,14 +971,14 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
if (s->cy > 0) { if (s->cy > 0) {
screen_dirty_clear(s, 0, 0, sx - 1, s->cy); screen_dirty_clear(s, 0, 0, sx - 1, s->cy);
grid_view_clear(s->grid, 0, 0, sx, s->cy); grid_view_clear(s->grid, 0, 0, sx, s->cy, 8);
} }
if (s->cx > sx - 1) { if (s->cx > sx - 1) {
screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy); screen_dirty_clear(s, 0, s->cy, sx - 1, s->cy);
grid_view_clear(s->grid, 0, s->cy, sx, 1); grid_view_clear(s->grid, 0, s->cy, sx, 1, 8);
} else { } else {
screen_dirty_clear(s, 0, s->cy, s->cx, s->cy); screen_dirty_clear(s, 0, s->cy, s->cx, s->cy);
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1); grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1, 8);
} }
tty_write(tty_cmd_clearstartofscreen, &ttyctx); tty_write(tty_cmd_clearstartofscreen, &ttyctx);
@ -970,21 +986,22 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
/* Clear entire screen. */ /* Clear entire screen. */
void void
screen_write_clearscreen(struct screen_write_ctx *ctx) screen_write_clearscreen(struct screen_write_ctx *ctx, u_int bg)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct tty_ctx ttyctx; struct tty_ctx ttyctx;
u_int sx = screen_size_x(s), sy = screen_size_y(s); u_int sx = screen_size_x(s), sy = screen_size_y(s);
screen_write_initctx(ctx, &ttyctx); screen_write_initctx(ctx, &ttyctx);
ttyctx.bg = bg;
screen_dirty_clear(s, 0, 0, sx - 1, sy - 1); screen_dirty_clear(s, 0, 0, sx - 1, sy - 1);
/* Scroll into history if it is enabled. */ /* Scroll into history if it is enabled. */
if (s->grid->flags & GRID_HISTORY) if (s->grid->flags & GRID_HISTORY)
grid_view_clear_history(s->grid); grid_view_clear_history(s->grid, bg);
else else
grid_view_clear(s->grid, 0, 0, sx, sy); grid_view_clear(s->grid, 0, 0, sx, sy, bg);
tty_write(tty_cmd_clearscreen, &ttyctx); tty_write(tty_cmd_clearscreen, &ttyctx);
} }
@ -996,7 +1013,7 @@ screen_write_clearhistory(struct screen_write_ctx *ctx)
struct screen *s = ctx->s; struct screen *s = ctx->s;
struct grid *gd = s->grid; struct grid *gd = s->grid;
grid_move_lines(gd, 0, gd->hsize, gd->sy); grid_move_lines(gd, 0, gd->hsize, gd->sy, 8);
gd->hscrolled = gd->hsize = 0; gd->hscrolled = gd->hsize = 0;
} }
@ -1049,7 +1066,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
if (s->cx <= sx - width) { if (s->cx <= sx - width) {
screen_write_flush(ctx); screen_write_flush(ctx);
xx = sx - s->cx - width; xx = sx - s->cx - width;
grid_view_insert_cells(s->grid, s->cx, s->cy, xx); grid_view_insert_cells(s->grid, s->cx, s->cy, xx, 8);
} }
insert = 1; insert = 1;
} else } else

View File

@ -60,7 +60,7 @@ screen_reinit(struct screen *s)
screen_reset_tabs(s); screen_reset_tabs(s);
grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy); grid_clear_lines(s->grid, s->grid->hsize, s->grid->sy, 8);
screen_clear_selection(s); screen_clear_selection(s);
} }
@ -193,7 +193,8 @@ screen_resize_y(struct screen *s, u_int sy)
if (available > 0) { if (available > 0) {
if (available > needed) if (available > needed)
available = needed; available = needed;
grid_view_delete_lines(gd, oldy - available, available); grid_view_delete_lines(gd, oldy - available, available,
8);
} }
needed -= available; needed -= available;
@ -209,7 +210,7 @@ screen_resize_y(struct screen *s, u_int sy)
} else if (needed > 0 && available > 0) { } else if (needed > 0 && available > 0) {
if (available > needed) if (available > needed)
available = needed; available = needed;
grid_view_delete_lines(gd, 0, available); grid_view_delete_lines(gd, 0, available, 8);
} }
s->cy -= needed; s->cy -= needed;
} }

8
tmux.1
View File

@ -2183,13 +2183,9 @@ With
the key bindings in the key bindings in
.Ar mode-table .Ar mode-table
are listed; this may be one of: are listed; this may be one of:
.Em vi-edit , .Em vi-choice
.Em emacs-edit ,
.Em vi-choice ,
.Em emacs-choice ,
.Em vi-copy
or or
.Em emacs-copy . .Em emacs-choice .
.It Xo Ic send-keys .It Xo Ic send-keys
.Op Fl lMRX .Op Fl lMRX
.Op Fl N Ar repeat-count .Op Fl N Ar repeat-count

64
tmux.h
View File

@ -604,6 +604,7 @@ struct grid_cell_entry {
/* Grid line. */ /* Grid line. */
struct grid_line { struct grid_line {
u_int cellused;
u_int cellsize; u_int cellsize;
struct grid_cell_entry *celldata; struct grid_cell_entry *celldata;
@ -712,7 +713,7 @@ struct screen {
char *ccolour; /* cursor colour string */ char *ccolour; /* cursor colour string */
u_int rupper; /* scroll region top */ u_int rupper; /* scroll region top */
u_int rlower; /* scroll region bottom */ u_int rlower; /* scroll region bottom */
int mode; int mode;
@ -1146,6 +1147,9 @@ struct tty_ctx {
u_int xoff; u_int xoff;
u_int yoff; u_int yoff;
/* The background colour used for clearing (erasing). */
u_int bg;
/* Saved last cell on line. */ /* Saved last cell on line. */
struct grid_cell last_cell; struct grid_cell last_cell;
}; };
@ -1189,7 +1193,7 @@ struct client {
struct event repeat_timer; struct event repeat_timer;
struct event click_timer; struct event click_timer;
u_int click_button; u_int click_button;
struct event status_timer; struct event status_timer;
struct screen status; struct screen status;
@ -1273,10 +1277,10 @@ struct cmd_find_state {
int flags; int flags;
struct cmd_find_state *current; struct cmd_find_state *current;
struct session *s; struct session *s;
struct winlink *wl; struct winlink *wl;
struct window *w; struct window *w;
struct window_pane *wp; struct window_pane *wp;
int idx; int idx;
}; };
@ -1546,7 +1550,7 @@ void format_defaults_paste_buffer(struct format_tree *,
/* hooks.c */ /* hooks.c */
struct hook; struct hook;
struct hooks *hooks_get(struct session *); struct hooks *hooks_get(struct session *);
struct hooks *hooks_create(struct hooks *); struct hooks *hooks_create(struct hooks *);
void hooks_free(struct hooks *); void hooks_free(struct hooks *);
struct hook *hooks_first(struct hooks *); struct hook *hooks_first(struct hooks *);
@ -1927,17 +1931,17 @@ int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
struct grid *grid_create(u_int, u_int, u_int); struct grid *grid_create(u_int, u_int, u_int);
void grid_destroy(struct grid *); void grid_destroy(struct grid *);
int grid_compare(struct grid *, struct grid *); int grid_compare(struct grid *, struct grid *);
void grid_collect_history(struct grid *); void grid_collect_history(struct grid *, u_int);
void grid_scroll_history(struct grid *); void grid_scroll_history(struct grid *, u_int);
void grid_scroll_history_region(struct grid *, u_int, u_int); void grid_scroll_history_region(struct grid *, u_int, u_int);
void grid_clear_history(struct grid *); void grid_clear_history(struct grid *);
const struct grid_line *grid_peek_line(struct grid *, u_int); const struct grid_line *grid_peek_line(struct grid *, u_int);
void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *); void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
void grid_clear(struct grid *, u_int, u_int, u_int, u_int); void grid_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
void grid_clear_lines(struct grid *, u_int, u_int); void grid_clear_lines(struct grid *, u_int, u_int, u_int);
void grid_move_lines(struct grid *, u_int, u_int, u_int); void grid_move_lines(struct grid *, u_int, u_int, u_int, u_int);
void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int); void grid_move_cells(struct grid *, u_int, u_int, u_int, u_int, u_int);
char *grid_string_cells(struct grid *, u_int, u_int, u_int, char *grid_string_cells(struct grid *, u_int, u_int, u_int,
struct grid_cell **, int, int, int); struct grid_cell **, int, int, int);
void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int, void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
@ -1948,16 +1952,18 @@ u_int grid_reflow(struct grid *, struct grid *, u_int);
void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *); void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_view_set_cell(struct grid *, u_int, u_int, void grid_view_set_cell(struct grid *, u_int, u_int,
const struct grid_cell *); const struct grid_cell *);
void grid_view_clear_history(struct grid *); void grid_view_clear_history(struct grid *, u_int);
void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int); void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int);
void grid_view_scroll_region_up(struct grid *, u_int, u_int); void grid_view_scroll_region_up(struct grid *, u_int, u_int);
void grid_view_scroll_region_down(struct grid *, u_int, u_int); void grid_view_scroll_region_down(struct grid *, u_int, u_int);
void grid_view_insert_lines(struct grid *, u_int, u_int); void grid_view_insert_lines(struct grid *, u_int, u_int, u_int);
void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int); void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int,
void grid_view_delete_lines(struct grid *, u_int, u_int); u_int);
void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int); void grid_view_delete_lines(struct grid *, u_int, u_int, u_int);
void grid_view_insert_cells(struct grid *, u_int, u_int, u_int); void grid_view_delete_lines_region(struct grid *, u_int, u_int, u_int,
void grid_view_delete_cells(struct grid *, u_int, u_int, u_int); u_int);
void grid_view_insert_cells(struct grid *, u_int, u_int, u_int, u_int);
void grid_view_delete_cells(struct grid *, u_int, u_int, u_int, u_int);
char *grid_view_string_cells(struct grid *, u_int, u_int, u_int); char *grid_view_string_cells(struct grid *, u_int, u_int, u_int);
/* screen-write.c */ /* screen-write.c */
@ -1987,22 +1993,22 @@ void screen_write_cursordown(struct screen_write_ctx *, u_int);
void screen_write_cursorright(struct screen_write_ctx *, u_int); void screen_write_cursorright(struct screen_write_ctx *, u_int);
void screen_write_cursorleft(struct screen_write_ctx *, u_int); void screen_write_cursorleft(struct screen_write_ctx *, u_int);
void screen_write_alignmenttest(struct screen_write_ctx *); void screen_write_alignmenttest(struct screen_write_ctx *);
void screen_write_insertcharacter(struct screen_write_ctx *, u_int); void screen_write_insertcharacter(struct screen_write_ctx *, u_int, u_int);
void screen_write_deletecharacter(struct screen_write_ctx *, u_int); void screen_write_deletecharacter(struct screen_write_ctx *, u_int, u_int);
void screen_write_clearcharacter(struct screen_write_ctx *, u_int); void screen_write_clearcharacter(struct screen_write_ctx *, u_int);
void screen_write_insertline(struct screen_write_ctx *, u_int); void screen_write_insertline(struct screen_write_ctx *, u_int, u_int);
void screen_write_deleteline(struct screen_write_ctx *, u_int); void screen_write_deleteline(struct screen_write_ctx *, u_int, u_int);
void screen_write_clearline(struct screen_write_ctx *); void screen_write_clearline(struct screen_write_ctx *, u_int);
void screen_write_clearendofline(struct screen_write_ctx *); void screen_write_clearendofline(struct screen_write_ctx *, u_int);
void screen_write_clearstartofline(struct screen_write_ctx *); void screen_write_clearstartofline(struct screen_write_ctx *, u_int);
void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int); void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int);
void screen_write_reverseindex(struct screen_write_ctx *); void screen_write_reverseindex(struct screen_write_ctx *);
void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int);
void screen_write_linefeed(struct screen_write_ctx *, int); void screen_write_linefeed(struct screen_write_ctx *, int);
void screen_write_carriagereturn(struct screen_write_ctx *); void screen_write_carriagereturn(struct screen_write_ctx *);
void screen_write_clearendofscreen(struct screen_write_ctx *); void screen_write_clearendofscreen(struct screen_write_ctx *, u_int);
void screen_write_clearstartofscreen(struct screen_write_ctx *); void screen_write_clearstartofscreen(struct screen_write_ctx *);
void screen_write_clearscreen(struct screen_write_ctx *); void screen_write_clearscreen(struct screen_write_ctx *, u_int);
void screen_write_clearhistory(struct screen_write_ctx *); void screen_write_clearhistory(struct screen_write_ctx *);
void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *); void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *);
void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int); void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);

95
tty.c
View File

@ -55,7 +55,8 @@ static void tty_colours_bg(struct tty *, const struct grid_cell *);
static void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, static void tty_region_pane(struct tty *, const struct tty_ctx *, u_int,
u_int); u_int);
static int tty_large_region(struct tty *, const struct tty_ctx *); static int tty_large_region(struct tty *, const struct tty_ctx *);
static int tty_fake_bce(const struct tty *, const struct window_pane *); static int tty_fake_bce(const struct tty *, const struct window_pane *,
u_int);
static void tty_redraw_region(struct tty *, const struct tty_ctx *); static void tty_redraw_region(struct tty *, const struct tty_ctx *);
static void tty_emulate_repeat(struct tty *, enum tty_code_code, static void tty_emulate_repeat(struct tty *, enum tty_code_code,
enum tty_code_code, u_int); enum tty_code_code, u_int);
@ -64,6 +65,8 @@ static void tty_cell(struct tty *, const struct grid_cell *,
const struct window_pane *); const struct window_pane *);
static void tty_default_colours(struct grid_cell *, static void tty_default_colours(struct grid_cell *,
const struct window_pane *); const struct window_pane *);
static void tty_default_attributes(struct tty *, const struct window_pane *,
u_int);
#define tty_use_acs(tty) \ #define tty_use_acs(tty) \
(tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8)) (tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8))
@ -604,17 +607,20 @@ tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx)
* emulated. * emulated.
*/ */
static int static int
tty_fake_bce(const struct tty *tty, const struct window_pane *wp) tty_fake_bce(const struct tty *tty, const struct window_pane *wp, u_int bg)
{ {
struct grid_cell gc; struct grid_cell gc;
if (tty_term_flag(tty->term, TTYC_BCE))
return (0);
memcpy(&gc, &grid_default_cell, sizeof gc); memcpy(&gc, &grid_default_cell, sizeof gc);
if (wp != NULL) if (wp != NULL)
tty_default_colours(&gc, wp); tty_default_colours(&gc, wp);
if (gc.bg == 8) if (bg != 8 || gc.bg != 8)
return (0); return (1);
return (!tty_term_flag(tty->term, TTYC_BCE)); return (0);
} }
/* /*
@ -695,13 +701,13 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
} }
if (sx < tty->sx) { if (sx < tty->sx) {
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, 8);
tty_cursor(tty, ox + sx, oy + py); tty_cursor(tty, ox + sx, oy + py);
if (sx != screen_size_x(s) && if (sx != screen_size_x(s) &&
ox + screen_size_x(s) >= tty->sx && ox + screen_size_x(s) >= tty->sx &&
tty_term_has(tty->term, TTYC_EL) && tty_term_has(tty->term, TTYC_EL) &&
!tty_fake_bce(tty, wp)) !tty_fake_bce(tty, wp, 8))
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
else else
tty_repeat_space(tty, screen_size_x(s) - sx); tty_repeat_space(tty, screen_size_x(s) - sx);
@ -759,14 +765,15 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
{ {
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
if (!tty_pane_full_width(tty, ctx) || tty_fake_bce(tty, wp) || if (!tty_pane_full_width(tty, ctx) ||
(!tty_term_has(tty->term, TTYC_DCH) && tty_fake_bce(tty, wp, ctx->bg) ||
!tty_term_has(tty->term, TTYC_DCH1))) { (!tty_term_has(tty->term, TTYC_ICH) &&
!tty_term_has(tty->term, TTYC_ICH1))) {
tty_draw_pane(tty, wp, ctx->ocy, ctx->xoff, ctx->yoff); tty_draw_pane(tty, wp, ctx->ocy, ctx->xoff, ctx->yoff);
return; return;
} }
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, ctx->bg);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
@ -778,14 +785,15 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
{ {
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
if (!tty_pane_full_width(tty, ctx) || tty_fake_bce(tty, wp) || if (!tty_pane_full_width(tty, ctx) ||
tty_fake_bce(tty, wp, ctx->bg) ||
(!tty_term_has(tty->term, TTYC_DCH) && (!tty_term_has(tty->term, TTYC_DCH) &&
!tty_term_has(tty->term, TTYC_DCH1))) { !tty_term_has(tty->term, TTYC_DCH1))) {
tty_draw_pane(tty, wp, ctx->ocy, ctx->xoff, ctx->yoff); tty_draw_pane(tty, wp, ctx->ocy, ctx->xoff, ctx->yoff);
return; return;
} }
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, ctx->bg);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
@ -801,7 +809,8 @@ tty_cmd_clearcharacter(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);
if (tty_term_has(tty->term, TTYC_ECH) && !tty_fake_bce(tty, ctx->wp)) if (tty_term_has(tty->term, TTYC_ECH) &&
!tty_fake_bce(tty, ctx->wp, ctx->bg))
tty_putcode1(tty, TTYC_ECH, ctx->num); tty_putcode1(tty, TTYC_ECH, ctx->num);
else { else {
for (i = 0; i < ctx->num; i++) for (i = 0; i < ctx->num; i++)
@ -812,14 +821,15 @@ tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx)
void void
tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx) tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
{ {
if (!tty_pane_full_width(tty, ctx) || tty_fake_bce(tty, ctx->wp) || if (!tty_pane_full_width(tty, ctx) ||
tty_fake_bce(tty, ctx->wp, ctx->bg) ||
!tty_term_has(tty->term, TTYC_CSR) || !tty_term_has(tty->term, TTYC_CSR) ||
!tty_term_has(tty->term, TTYC_IL1)) { !tty_term_has(tty->term, TTYC_IL1)) {
tty_redraw_region(tty, ctx); tty_redraw_region(tty, ctx);
return; return;
} }
tty_attributes(tty, &grid_default_cell, ctx->wp); tty_default_attributes(tty, ctx->wp, ctx->bg);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
@ -830,14 +840,15 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx)
void void
tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx) tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx)
{ {
if (!tty_pane_full_width(tty, ctx) || tty_fake_bce(tty, ctx->wp) || if (!tty_pane_full_width(tty, ctx) ||
tty_fake_bce(tty, ctx->wp, ctx->bg) ||
!tty_term_has(tty->term, TTYC_CSR) || !tty_term_has(tty->term, TTYC_CSR) ||
!tty_term_has(tty->term, TTYC_DL1)) { !tty_term_has(tty->term, TTYC_DL1)) {
tty_redraw_region(tty, ctx); tty_redraw_region(tty, ctx);
return; return;
} }
tty_attributes(tty, &grid_default_cell, ctx->wp); tty_default_attributes(tty, ctx->wp, ctx->bg);
tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
@ -851,11 +862,12 @@ tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx)
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen; struct screen *s = wp->screen;
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, ctx->bg);
tty_cursor_pane(tty, ctx, 0, ctx->ocy); tty_cursor_pane(tty, ctx, 0, ctx->ocy);
if (tty_pane_full_width(tty, ctx) && !tty_fake_bce(tty, wp) && if (tty_pane_full_width(tty, ctx) &&
!tty_fake_bce(tty, wp, ctx->bg) &&
tty_term_has(tty->term, TTYC_EL)) tty_term_has(tty->term, TTYC_EL))
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
else else
@ -868,12 +880,13 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
struct window_pane *wp = ctx->wp; struct window_pane *wp = ctx->wp;
struct screen *s = wp->screen; struct screen *s = wp->screen;
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, ctx->bg);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
if (tty_pane_full_width(tty, ctx) && if (tty_pane_full_width(tty, ctx) &&
tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp)) tty_term_has(tty->term, TTYC_EL) &&
!tty_fake_bce(tty, wp, ctx->bg))
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
else else
tty_repeat_space(tty, screen_size_x(s) - ctx->ocx); tty_repeat_space(tty, screen_size_x(s) - ctx->ocx);
@ -882,10 +895,13 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
void void
tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
{ {
tty_attributes(tty, &grid_default_cell, ctx->wp); struct window_pane *wp = ctx->wp;
if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1) && tty_default_attributes(tty, wp, ctx->bg);
!tty_fake_bce(tty, ctx->wp)) {
if (ctx->xoff == 0 &&
tty_term_has(tty->term, TTYC_EL1) &&
!tty_fake_bce(tty, ctx->wp, ctx->bg)) {
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
tty_putcode(tty, TTYC_EL1); tty_putcode(tty, TTYC_EL1);
} else { } else {
@ -900,7 +916,8 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
if (ctx->ocy != ctx->orupper) if (ctx->ocy != ctx->orupper)
return; return;
if (!tty_pane_full_width(tty, ctx) || tty_fake_bce(tty, ctx->wp) || if (!tty_pane_full_width(tty, ctx) ||
tty_fake_bce(tty, ctx->wp, ctx->bg) ||
!tty_term_has(tty->term, TTYC_CSR) || !tty_term_has(tty->term, TTYC_CSR) ||
!tty_term_has(tty->term, TTYC_RI)) { !tty_term_has(tty->term, TTYC_RI)) {
tty_redraw_region(tty, ctx); tty_redraw_region(tty, ctx);
@ -923,7 +940,8 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
if (ctx->ocy != ctx->orlower) if (ctx->ocy != ctx->orlower)
return; return;
if (!tty_pane_full_width(tty, ctx) || tty_fake_bce(tty, wp) || if (!tty_pane_full_width(tty, ctx) ||
tty_fake_bce(tty, wp, ctx->bg) ||
!tty_term_has(tty->term, TTYC_CSR)) { !tty_term_has(tty->term, TTYC_CSR)) {
if (tty_large_region(tty, ctx)) if (tty_large_region(tty, ctx))
wp->flags |= PANE_REDRAW; wp->flags |= PANE_REDRAW;
@ -955,13 +973,14 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int i, j; u_int i, j;
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, ctx->bg);
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
if (tty_pane_full_width(tty, ctx) && if (tty_pane_full_width(tty, ctx) &&
tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp)) { tty_term_has(tty->term, TTYC_EL) &&
!tty_fake_bce(tty, wp, ctx->bg)) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
if (ctx->ocy != screen_size_y(s) - 1) { if (ctx->ocy != screen_size_y(s) - 1) {
tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1); tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
@ -995,7 +1014,8 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
tty_cursor_pane(tty, ctx, 0, 0); tty_cursor_pane(tty, ctx, 0, 0);
if (tty_pane_full_width(tty, ctx) && if (tty_pane_full_width(tty, ctx) &&
tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp)) { tty_term_has(tty->term, TTYC_EL) &&
!tty_fake_bce(tty, wp, ctx->bg)) {
for (i = 0; i < ctx->ocy; i++) { for (i = 0; i < ctx->ocy; i++) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1); tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1);
@ -1017,13 +1037,14 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
struct screen *s = wp->screen; struct screen *s = wp->screen;
u_int i, j; u_int i, j;
tty_attributes(tty, &grid_default_cell, wp); tty_default_attributes(tty, wp, ctx->bg);
tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1);
tty_cursor_pane(tty, ctx, 0, 0); tty_cursor_pane(tty, ctx, 0, 0);
if (tty_pane_full_width(tty, ctx) && if (tty_pane_full_width(tty, ctx) &&
tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp)) { tty_term_has(tty->term, TTYC_EL) &&
!tty_fake_bce(tty, wp, ctx->bg)) {
for (i = 0; i < screen_size_y(s); i++) { for (i = 0; i < screen_size_y(s); i++) {
tty_putcode(tty, TTYC_EL); tty_putcode(tty, TTYC_EL);
if (i != screen_size_y(s) - 1) { if (i != screen_size_y(s) - 1) {
@ -1721,3 +1742,13 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
gc->bg = wgc->bg; gc->bg = wgc->bg;
} }
} }
static void
tty_default_attributes(struct tty *tty, const struct window_pane *wp, u_int bg)
{
static struct grid_cell gc;
memcpy(&gc, &grid_default_cell, sizeof gc);
gc.bg = bg;
tty_attributes(tty, &gc, wp);
}

View File

@ -900,7 +900,7 @@ window_choose_scroll_up(struct window_pane *wp)
screen_write_start(&ctx, wp, NULL); screen_write_start(&ctx, wp, NULL);
screen_write_cursormove(&ctx, 0, 0); screen_write_cursormove(&ctx, 0, 0);
screen_write_insertline(&ctx, 1); screen_write_insertline(&ctx, 1, 8);
window_choose_write_line(wp, &ctx, 0); window_choose_write_line(wp, &ctx, 0);
if (screen_size_y(&data->screen) > 1) if (screen_size_y(&data->screen) > 1)
window_choose_write_line(wp, &ctx, 1); window_choose_write_line(wp, &ctx, 1);
@ -920,7 +920,7 @@ window_choose_scroll_down(struct window_pane *wp)
screen_write_start(&ctx, wp, NULL); screen_write_start(&ctx, wp, NULL);
screen_write_cursormove(&ctx, 0, 0); screen_write_cursormove(&ctx, 0, 0);
screen_write_deleteline(&ctx, 1); screen_write_deleteline(&ctx, 1, 8);
window_choose_write_line(wp, &ctx, screen_size_y(s) - 1); window_choose_write_line(wp, &ctx, screen_size_y(s) - 1);
if (screen_size_y(&data->screen) > 1) if (screen_size_y(&data->screen) > 1)
window_choose_write_line(wp, &ctx, screen_size_y(s) - 2); window_choose_write_line(wp, &ctx, screen_size_y(s) - 2);

View File

@ -221,7 +221,7 @@ window_clock_draw_screen(struct window_pane *wp)
} else } else
strftime(tim, sizeof tim, "%H:%M", tm); strftime(tim, sizeof tim, "%H:%M", tm);
screen_write_clearscreen(&ctx); screen_write_clearscreen(&ctx, 8);
if (screen_size_x(s) < 6 * strlen(tim) || screen_size_y(s) < 6) { if (screen_size_x(s) < 6 * strlen(tim) || screen_size_y(s) < 6) {
if (screen_size_x(s) >= strlen(tim) && screen_size_y(s) != 0) { if (screen_size_x(s) >= strlen(tim) && screen_size_y(s) != 0) {

View File

@ -2052,7 +2052,7 @@ window_copy_scroll_up(struct window_pane *wp, u_int ny)
screen_write_start(&ctx, wp, NULL); screen_write_start(&ctx, wp, NULL);
screen_write_cursormove(&ctx, 0, 0); screen_write_cursormove(&ctx, 0, 0);
screen_write_deleteline(&ctx, ny); screen_write_deleteline(&ctx, ny, 8);
window_copy_write_lines(wp, &ctx, screen_size_y(s) - ny, ny); window_copy_write_lines(wp, &ctx, screen_size_y(s) - ny, ny);
window_copy_write_line(wp, &ctx, 0); window_copy_write_line(wp, &ctx, 0);
if (screen_size_y(s) > 1) if (screen_size_y(s) > 1)
@ -2085,7 +2085,7 @@ window_copy_scroll_down(struct window_pane *wp, u_int ny)
screen_write_start(&ctx, wp, NULL); screen_write_start(&ctx, wp, NULL);
screen_write_cursormove(&ctx, 0, 0); screen_write_cursormove(&ctx, 0, 0);
screen_write_insertline(&ctx, ny); screen_write_insertline(&ctx, ny, 8);
window_copy_write_lines(wp, &ctx, 0, ny); window_copy_write_lines(wp, &ctx, 0, ny);
if (s->sel.flag && screen_size_y(s) > ny) if (s->sel.flag && screen_size_y(s) > ny)
window_copy_write_line(wp, &ctx, ny); window_copy_write_line(wp, &ctx, ny);

View File

@ -1038,7 +1038,7 @@ window_pane_alternate_on(struct window_pane *wp, struct grid_cell *gc,
} }
memcpy(&wp->saved_cell, gc, sizeof wp->saved_cell); memcpy(&wp->saved_cell, gc, sizeof wp->saved_cell);
grid_view_clear(s->grid, 0, 0, sx, sy); grid_view_clear(s->grid, 0, 0, sx, sy, 8);
wp->base.grid->flags &= ~GRID_HISTORY; wp->base.grid->flags &= ~GRID_HISTORY;