diff options
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -407,6 +407,36 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) grid_store_cell(gce, gc, gc->data.data[0]); } +/* Set cells at relative position. */ +void +grid_set_cells(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc, + const char *s, size_t slen) +{ + struct grid_line *gl; + struct grid_cell_entry *gce; + struct grid_cell *gcp; + u_int i; + + if (grid_check_y(gd, py) != 0) + return; + + grid_expand_line(gd, py, px + slen, 8); + + gl = &gd->linedata[py]; + if (px + slen > gl->cellused) + gl->cellused = px + slen; + + for (i = 0; i < slen; i++) { + gce = &gl->celldata[px + i]; + if (gce->flags & GRID_FLAG_EXTENDED) { + gcp = &gl->extddata[gce->offset]; + memcpy(gcp, gc, sizeof *gcp); + utf8_set(&gcp->data, s[i]); + } else + grid_store_cell(gce, gc, s[i]); + } +} + /* Clear area. */ void grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg) |