summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/grid.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-02-08 15:41:42 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-02-08 15:41:42 +0000
commit73398c7a75663b62be63630bcdc112ff563ca29b (patch)
tree0258671812fa1d451be696fafda20bd16fec4eb6 /usr.bin/tmux/grid.c
parent0cb4121c9ba9d94a6bb34df14f6805fa6f948936 (diff)
Add a helper to store a cell, and some tidying.
Diffstat (limited to 'usr.bin/tmux/grid.c')
-rw-r--r--usr.bin/tmux/grid.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index ff1ac8dba93..829205e44ad 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.62 2017/02/08 08:26:35 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.63 2017/02/08 15:41:41 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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. */