aboutsummaryrefslogtreecommitdiff
path: root/grid.c
diff options
context:
space:
mode:
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/grid.c b/grid.c
index b2031045..0cef412b 100644
--- a/grid.c
+++ b/grid.c
@@ -48,8 +48,6 @@ static const struct grid_cell_entry grid_cleared_entry = {
GRID_FLAG_CLEARED, { .data = { 0, 8, 8, ' ' } }
};
-static void grid_empty_line(struct grid *, u_int, u_int);
-
/* Store cell in entry. */
static void
grid_store_cell(struct grid_cell_entry *gce, const struct grid_cell *gc,
@@ -258,7 +256,10 @@ grid_create(u_int sx, u_int sy, u_int hlimit)
gd->sx = sx;
gd->sy = sy;
- gd->flags = GRID_HISTORY;
+ if (hlimit != 0)
+ gd->flags = GRID_HISTORY;
+ else
+ gd->flags = 0;
gd->hscrolled = 0;
gd->hsize = 0;
@@ -348,6 +349,19 @@ grid_collect_history(struct grid *gd)
gd->hscrolled = gd->hsize;
}
+/* Remove lines from the bottom of the history. */
+void
+grid_remove_history(struct grid *gd, u_int ny)
+{
+ u_int yy;
+
+ if (ny > gd->hsize)
+ return;
+ for (yy = 0; yy < ny; yy++)
+ grid_free_line(gd, gd->hsize + gd->sy - 1 - yy);
+ gd->hsize -= ny;
+}
+
/*
* Scroll the entire visible screen, moving one line into the history. Just
* allocate a new line at the bottom and move the history size indicator.
@@ -438,7 +452,7 @@ grid_expand_line(struct grid *gd, u_int py, u_int sx, u_int bg)
}
/* Empty a line and set background colour if needed. */
-static void
+void
grid_empty_line(struct grid *gd, u_int py, u_int bg)
{
memset(&gd->linedata[py], 0, sizeof gd->linedata[py]);
@@ -755,15 +769,15 @@ grid_string_cells_bg(const struct grid_cell *gc, int *values)
case 8:
values[n++] = 49;
break;
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- values[n++] = gc->bg - 10;
+ case 90:
+ case 91:
+ case 92:
+ case 93:
+ case 94:
+ case 95:
+ case 96:
+ case 97:
+ values[n++] = gc->bg + 10;
break;
}
}
@@ -1327,17 +1341,13 @@ grid_wrap_position(struct grid *gd, u_int px, u_int py, u_int *wx, u_int *wy)
void
grid_unwrap_position(struct grid *gd, u_int *px, u_int *py, u_int wx, u_int wy)
{
- u_int yy, ax = 0, ay = 0;
+ u_int yy, ay = 0;
for (yy = 0; yy < gd->hsize + gd->sy - 1; yy++) {
if (ay == wy)
break;
- if (gd->linedata[yy].flags & GRID_LINE_WRAPPED)
- ax += gd->linedata[yy].cellused;
- else {
- ax = 0;
+ if (~gd->linedata[yy].flags & GRID_LINE_WRAPPED)
ay++;
- }
}
/*