summaryrefslogtreecommitdiffstats
path: root/grid-view.c
diff options
context:
space:
mode:
authornicm <nicm>2016-10-13 20:27:27 +0000
committernicm <nicm>2016-10-13 20:27:27 +0000
commit4179b4242411f41a22d9743b4eff3b19ef69b3e8 (patch)
treec50ccb7dac6c4ddc71a666aeaaba5c489e703946 /grid-view.c
parent1bd08f903b8f70b0dd9aad577f830d944b969516 (diff)
Add support for BCE (background colour erase). This makes various escape
sequences (notable EL and ED but also IL, DL, ICH, DCH) create blank cells using the current background colour rather than the default colour. On modern systems BCE doesn't really have many benefits, but most other terminals now support it, some (lazy) applications rely on it, and it is not hard to include now that we have pane background colours anyway. Mostly written by Sean Haugh.
Diffstat (limited to 'grid-view.c')
-rw-r--r--grid-view.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/grid-view.c b/grid-view.c
index 8160679d..da0433bf 100644
--- a/grid-view.c
+++ b/grid-view.c
@@ -47,7 +47,7 @@ grid_view_set_cell(struct grid *gd, u_int px, u_int py,
/* Clear into history. */
void
-grid_view_clear_history(struct grid *gd)
+grid_view_clear_history(struct grid *gd, u_int bg)
{
struct grid_line *gl;
u_int yy, last;
@@ -56,28 +56,33 @@ grid_view_clear_history(struct grid *gd)
last = 0;
for (yy = 0; yy < gd->sy; yy++) {
gl = &gd->linedata[grid_view_y(gd, yy)];
- if (gl->cellsize != 0)
+ if (gl->cellused != 0)
last = yy + 1;
}
- if (last == 0)
+ if (last == 0) {
+ grid_view_clear(gd, 0, 0, gd->sx, gd->sy, bg);
return;
+ }
/* Scroll the lines into the history. */
for (yy = 0; yy < last; yy++) {
- grid_collect_history(gd);
- grid_scroll_history(gd);
+ grid_collect_history(gd, bg);
+ grid_scroll_history(gd, bg);
}
+ if (last < gd->sy)
+ grid_view_clear(gd, 0, 0, gd->sx, gd->sy - last, bg);
gd->hscrolled = 0;
}
/* Clear area. */
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);
py = grid_view_y(gd, py);
- grid_clear(gd, px, py, nx, ny);
+ grid_clear(gd, px, py, nx, ny, bg);
}
/* Scroll region up. */
@@ -85,9 +90,9 @@ void
grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower)
{
if (gd->flags & GRID_HISTORY) {
- grid_collect_history(gd);
+ grid_collect_history(gd, 8);
if (rupper == 0 && rlower == gd->sy - 1)
- grid_scroll_history(gd);
+ grid_scroll_history(gd, 8);
else {
rupper = grid_view_y(gd, rupper);
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 {
rupper = grid_view_y(gd, rupper);
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);
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. */
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;
@@ -120,13 +125,13 @@ grid_view_insert_lines(struct grid *gd, u_int py, u_int ny)
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. */
void
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;
@@ -135,13 +140,13 @@ grid_view_insert_lines_region(struct grid *gd, u_int rlower, u_int py,
py = grid_view_y(gd, py);
ny2 = rlower + 1 - py - ny;
- grid_move_lines(gd, rlower + 1 - ny2, py, ny2);
- grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2);
+ grid_move_lines(gd, rlower + 1 - ny2, py, ny2, bg);
+ grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2, bg);
}
/* Delete lines. */
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;
@@ -149,14 +154,14 @@ grid_view_delete_lines(struct grid *gd, u_int py, u_int ny)
sy = grid_view_y(gd, gd->sy);
- grid_move_lines(gd, py, py + ny, sy - py - ny);
- grid_clear(gd, 0, sy - ny, gd->sx, py + ny - (sy - ny));
+ grid_move_lines(gd, py, py + ny, sy - py - ny, bg);
+ grid_clear(gd, 0, sy - ny, gd->sx, py + ny - (sy - ny), bg);
}
/* Delete lines inside scroll region. */
void
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;
@@ -165,13 +170,13 @@ grid_view_delete_lines_region(struct grid *gd, u_int rlower, u_int py,
py = grid_view_y(gd, py);
ny2 = rlower + 1 - py - ny;
- grid_move_lines(gd, py, py + ny, ny2);
- grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2);
+ grid_move_lines(gd, py, py + ny, ny2, bg);
+ grid_clear(gd, 0, py + ny2, gd->sx, ny - ny2, bg);
}
/* Insert characters. */
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;
@@ -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);
if (px == sx - 1)
- grid_clear(gd, px, py, 1, 1);
+ grid_clear(gd, px, py, 1, 1, bg);
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. */
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;
@@ -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);
- grid_move_cells(gd, px, px + nx, py, sx - px - nx);
- grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1);
+ grid_move_cells(gd, px, px + nx, py, sx - px - nx, bg);
+ grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1, bg);
}
/* Convert cells into a string. */