summaryrefslogtreecommitdiffstats
path: root/grid.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-09-15 15:14:09 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-09-15 15:14:09 +0000
commit427819910184a7174391c2e688da6b89634045ec (patch)
tree6a08b4939c09e170574c4a7065da3007ea37ac5b /grid.c
parentf39865e8e4aa1a8918c64cfc40fb0acc644861a4 (diff)
Stick line length to what is actually used (removing an optimization that
allowed it to be bigger), and use clear line/EOL sequences rather than spaces in copy/scroll mode. This fixes xterm copy/paste from tmux which treats trailing spaces differently from clearing a line with the escape sequences. Reported by martynas@.
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/grid.c b/grid.c
index b79e8843..6e01aa7c 100644
--- a/grid.c
+++ b/grid.c
@@ -189,22 +189,15 @@ grid_scroll_line(struct grid *gd)
/* Expand line to fit to cell. */
void
-grid_expand_line(struct grid *gd, u_int py, u_int wantx)
+grid_expand_line(struct grid *gd, u_int py, u_int sx)
{
struct grid_line *gl;
- u_int xx, sx;
+ u_int xx;
gl = &gd->linedata[py];
- if (wantx <= gl->cellsize)
+ if (sx <= gl->cellsize)
return;
- if (gl->cellsize > gd->sx / 2)
- sx = gd->sx;
- else {
- sx = gl->cellsize + 1;
- while (sx < wantx)
- sx *= 2;
- }
gl->celldata = xrealloc(gl->celldata, sx, sizeof *gl->celldata);
for (xx = gl->cellsize; xx < sx; xx++)
grid_put_cell(gd, xx, py, &grid_default_cell);
@@ -307,10 +300,7 @@ grid_set_utf8(
grid_put_utf8(gd, px, py, gc);
}
-/*
- * Clear area. Note this is different from a fill as it just omits unallocated
- * cells.
- */
+/* Clear area. */
void
grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)
{
@@ -336,6 +326,12 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)
return;
for (yy = py; yy < py + ny; yy++) {
+ if (px >= gd->linedata[yy].cellsize)
+ continue;
+ if (px + nx >= gd->linedata[yy].cellsize) {
+ gd->linedata[yy].cellsize = px;
+ continue;
+ }
for (xx = px; xx < px + nx; xx++) {
if (xx >= gd->linedata[yy].cellsize)
break;