summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-06-02 20:51:47 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-06-02 20:51:47 +0000
commit3f157bc466d021893f9144e42360e354926875ba (patch)
tree1a8a73992c6289aeb552e2e186c7e8fb1c237b33 /usr.bin
parent501f8883d2d4fc63891cacf57efb2b92e9d523fe (diff)
Move the code to set up a padding cell into grid.c.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/grid-view.c9
-rw-r--r--usr.bin/tmux/grid.c23
-rw-r--r--usr.bin/tmux/screen-write.c8
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/tty.c11
5 files changed, 38 insertions, 17 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c
index b14c2480312..23beae8c61b 100644
--- a/usr.bin/tmux/grid-view.c
+++ b/usr.bin/tmux/grid-view.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid-view.c,v 1.33 2019/08/16 08:52:25 nicm Exp $ */
+/* $OpenBSD: grid-view.c,v 1.34 2020/06/02 20:51:46 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index a16b004502a..c095463dc96 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.115 2020/06/02 20:10:23 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.116 2020/06/02 20:51:46 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 5a7e84d0527..81a1a74f72d 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.183 2020/06/02 20:10:23 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.184 2020/06/02 20:51:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index c6c4408b39e..223df889053 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1061 2020/06/02 20:10:23 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1062 2020/06/02 20:51:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index f3e0de7ac74..1dd4e009d45 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.380 2020/05/24 09:13:06 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.381 2020/06/02 20:51:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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;