diff options
author | nicm <nicm> | 2017-02-08 15:41:41 +0000 |
---|---|---|
committer | nicm <nicm> | 2017-02-08 15:41:41 +0000 |
commit | ac1f294bb930a0c05f96197b6a53b883ebc483f2 (patch) | |
tree | e3ae525926d363396e6f0c41f9b6d8c6b8ed893f /grid.c | |
parent | 96b66f8fc32867899653dd898f53285741ab8c83 (diff) |
Add a helper to store a cell, and some tidying.
Diffstat (limited to 'grid.c')
-rw-r--r-- | grid.c | 38 |
1 files changed, 23 insertions, 15 deletions
@@ -59,6 +59,25 @@ static size_t grid_string_cells_bg(const struct grid_cell *, int *); static void grid_string_cells_code(const struct grid_cell *, const struct grid_cell *, char *, size_t, int); +/* Store cell in entry. */ +static void +grid_store_cell(struct grid_cell_entry *gce, const struct grid_cell *gc, + u_char c) +{ + gce->flags = gc->flags; + + gce->data.fg = gc->fg & 0xff; + if (gc->fg & COLOUR_FLAG_256) + gce->flags |= GRID_FLAG_FG256; + + gce->data.bg = gc->bg & 0xff; + if (gc->bg & COLOUR_FLAG_256) + gce->flags |= GRID_FLAG_BG256; + + gce->data.attr = gc->attr; + gce->data.data = c; +} + /* Set cell as extended. */ static struct grid_cell * grid_extended_cell(struct grid_line *gl, struct grid_cell_entry *gce, @@ -371,11 +390,10 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) grid_expand_line(gd, py, px + 1, 8); gl = &gd->linedata[py]; - gce = &gl->celldata[px]; - if (px + 1 > gl->cellused) gl->cellused = px + 1; + gce = &gl->celldata[px]; extended = (gce->flags & GRID_FLAG_EXTENDED); if (!extended && (gc->data.size != 1 || gc->data.width != 1)) extended = 1; @@ -383,20 +401,10 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) extended = 1; if (!extended && (gc->bg & COLOUR_FLAG_RGB)) extended = 1; - if (extended) { + if (extended) grid_extended_cell(gl, gce, gc); - return; - } - - gce->flags = gc->flags; - gce->data.attr = gc->attr; - gce->data.fg = gc->fg & 0xff; - if (gc->fg & COLOUR_FLAG_256) - gce->flags |= GRID_FLAG_FG256; - gce->data.bg = gc->bg & 0xff; - if (gc->bg & COLOUR_FLAG_256) - gce->flags |= GRID_FLAG_BG256; - gce->data.data = gc->data.data[0]; + else + grid_store_cell(gce, gc, gc->data.data[0]); } /* Clear area. */ |