aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2020-06-02 20:51:46 +0000
committernicm <nicm>2020-06-02 20:51:46 +0000
commit4694e9a2b62c8df0862d80237e42978d65fc824e (patch)
treeb7c9710117c99894e62fc2b672600475cd9ed260
parent2a4d4bda2b94602e9f999ff0b59efa92613f75a9 (diff)
downloadrtmux-4694e9a2b62c8df0862d80237e42978d65fc824e.tar.gz
rtmux-4694e9a2b62c8df0862d80237e42978d65fc824e.tar.bz2
rtmux-4694e9a2b62c8df0862d80237e42978d65fc824e.zip
Move the code to set up a padding cell into grid.c.
-rw-r--r--grid-view.c7
-rw-r--r--grid.c21
-rw-r--r--screen-write.c6
-rw-r--r--tmux.h2
-rw-r--r--tty.c9
5 files changed, 33 insertions, 12 deletions
diff --git a/grid-view.c b/grid-view.c
index a4bd5ba2..f230d3c8 100644
--- a/grid-view.c
+++ b/grid-view.c
@@ -45,6 +45,13 @@ grid_view_set_cell(struct grid *gd, u_int px, u_int py,
grid_set_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py), gc);
}
+/* Set padding. */
+void
+grid_view_set_padding(struct grid *gd, u_int px, u_int py)
+{
+ grid_set_padding(gd, grid_view_x(gd, px), grid_view_y(gd, py));
+}
+
/* Set cells. */
void
grid_view_set_cells(struct grid *gd, u_int px, u_int py,
diff --git a/grid.c b/grid.c
index 7943d3be..2e3f50b9 100644
--- a/grid.c
+++ b/grid.c
@@ -40,8 +40,16 @@ const struct grid_cell grid_default_cell = {
{ { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0
};
+/*
+ * Padding grid cell data. Padding cells are the only zero width cell that
+ * appears in the grid - because of this, they are always extended cells.
+ */
+static const struct grid_cell grid_padding_cell = {
+ { { '!' }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 0
+};
+
/* Cleared grid cell data. */
-const struct grid_cell grid_cleared_cell = {
+static const struct grid_cell grid_cleared_cell = {
{ { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0
};
static const struct grid_cell_entry grid_cleared_entry = {
@@ -524,7 +532,7 @@ grid_get_cell(struct grid *gd, u_int px, u_int py, struct grid_cell *gc)
grid_get_cell1(&gd->linedata[py], px, gc);
}
-/* Set cell at relative position. */
+/* Set cell at position. */
void
grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
{
@@ -547,7 +555,14 @@ 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. */
+/* Set padding at position. */
+void
+grid_set_padding(struct grid *gd, u_int px, u_int py)
+{
+ grid_set_cell(gd, px, py, &grid_padding_cell);
+}
+
+/* Set cells at 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)
diff --git a/screen-write.c b/screen-write.c
index 68c3aa76..46ac967e 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -38,10 +38,6 @@ static int screen_write_overwrite(struct screen_write_ctx *,
static const struct grid_cell *screen_write_combine(struct screen_write_ctx *,
const struct utf8_data *, u_int *);
-static const struct grid_cell screen_write_pad_cell = {
- { { 0 }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 0
-};
-
struct screen_write_collect_item {
u_int x;
int wrapped;
@@ -1774,7 +1770,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
*/
for (xx = s->cx + 1; xx < s->cx + width; xx++) {
log_debug("%s: new padding at %u,%u", __func__, xx, s->cy);
- grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell);
+ grid_view_set_padding(gd, xx, s->cy);
skip = 0;
}
diff --git a/tmux.h b/tmux.h
index b02525fa..4523fce4 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2499,6 +2499,7 @@ void grid_clear_history(struct grid *);
const struct grid_line *grid_peek_line(struct grid *, u_int);
void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
+void grid_set_padding(struct grid *, u_int, u_int);
void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *,
const char *, size_t);
struct grid_line *grid_get_line(struct grid *, u_int);
@@ -2520,6 +2521,7 @@ u_int grid_line_length(struct grid *, u_int);
void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_view_set_cell(struct grid *, u_int, u_int,
const struct grid_cell *);
+void grid_view_set_padding(struct grid *, u_int, u_int);
void grid_view_set_cells(struct grid *, u_int, u_int,
const struct grid_cell *, const char *, size_t);
void grid_view_clear_history(struct grid *, u_int);
diff --git a/tty.c b/tty.c
index ba06d0bb..77eb90be 100644
--- a/tty.c
+++ b/tty.c
@@ -1380,9 +1380,10 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
screen_select_cell(s, &last, gcp);
else
memcpy(&last, gcp, sizeof last);
- if (!tty_check_overlay(tty, atx + ux, aty))
- ux += gcp->data.width;
- else if (ux + gcp->data.width > nx) {
+ if (!tty_check_overlay(tty, atx + ux, aty)) {
+ if (~gcp->flags & GRID_FLAG_PADDING)
+ ux += gcp->data.width;
+ } else if (ux + gcp->data.width > nx) {
tty_attributes(tty, &last, defaults, palette);
tty_cursor(tty, atx + ux, aty);
for (j = 0; j < gcp->data.width; j++) {
@@ -1397,7 +1398,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
for (j = 0; j < gcp->data.size; j++)
tty_putc(tty, gcp->data.data[j]);
ux += gcp->data.width;
- } else {
+ } else if (~gcp->flags & GRID_FLAG_PADDING) {
memcpy(buf + len, gcp->data.data, gcp->data.size);
len += gcp->data.size;
width += gcp->data.width;