summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-11-02 21:29:18 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-11-02 21:29:18 +0000
commitf568348413f21ed85b72756035d630767e7d81ab (patch)
treed08cc07f3534f5441cab7d171ca2d488239c16e1 /usr.bin/tmux
parent45ececc62b3e881ea76a09e9a305a470b5e8dedd (diff)
Add a "fast" version of screen_write_copy for tree mode that doesn't do
all the checks and selection and marking stuff needed for copy mode.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/mode-tree.c4
-rw-r--r--usr.bin/tmux/screen-write.c57
-rw-r--r--usr.bin/tmux/status.c5
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window-client.c6
5 files changed, 54 insertions, 22 deletions
diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c
index f9983a56376..fb1ae800f64 100644
--- a/usr.bin/tmux/mode-tree.c
+++ b/usr.bin/tmux/mode-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mode-tree.c,v 1.15 2017/10/25 12:13:20 nicm Exp $ */
+/* $OpenBSD: mode-tree.c,v 1.16 2017/11/02 21:29:17 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -595,7 +595,7 @@ mode_tree_draw(struct mode_tree_data *mtd)
box = mtd->drawcb(mtd->modedata, mti->itemdata, box_x, box_y);
if (box != NULL) {
screen_write_cursormove(&ctx, 2, h + 1);
- screen_write_copy(&ctx, box, 0, 0, box_x, box_y, NULL, NULL);
+ screen_write_fast_copy(&ctx, box, 0, 0, box_x, box_y);
screen_free(box);
}
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 93489c9b9e3..a566ac40388 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.131 2017/10/05 08:12:24 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.132 2017/11/02 21:29:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -351,11 +351,10 @@ screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
free(msg);
}
-/* Copy from another screen. */
+/* Copy from another screen. Assumes target region is big enough. */
void
screen_write_copy(struct screen_write_ctx *ctx, struct screen *src, u_int px,
- u_int py, u_int nx, u_int ny, bitstr_t *markbs,
- const struct grid_cell *markgc)
+ u_int py, u_int nx, u_int ny, bitstr_t *mbs, const struct grid_cell *mgc)
{
struct screen *s = ctx->s;
struct grid *gd = src->grid;
@@ -371,22 +370,52 @@ screen_write_copy(struct screen_write_ctx *ctx, struct screen *src, u_int px,
for (yy = py; yy < py + ny; yy++) {
for (xx = px; xx < px + nx; xx++) {
grid_get_cell(gd, xx, yy, &gc);
- if (markbs != NULL) {
+ if (mbs != NULL) {
b = (yy * screen_size_x(src)) + xx;
- if (bit_test(markbs, b)) {
- gc.attr = markgc->attr;
- gc.fg = markgc->fg;
- gc.bg = markgc->bg;
+ if (bit_test(mbs, b)) {
+ gc.attr = mgc->attr;
+ gc.fg = mgc->fg;
+ gc.bg = mgc->bg;
}
}
screen_write_cell(ctx, &gc);
}
-
cy++;
screen_write_cursormove(ctx, cx, cy);
}
}
+/*
+ * Copy from another screen but without the selection stuff. Also assumes the
+ * target region is already big enough and already cleared.
+ */
+void
+screen_write_fast_copy(struct screen_write_ctx *ctx, struct screen *src,
+ u_int px, u_int py, u_int nx, u_int ny)
+{
+ struct screen *s = ctx->s;
+ struct grid *gd = src->grid;
+ struct grid_cell gc;
+ u_int xx, yy, cx, cy;
+
+ if (nx == 0 || ny == 0)
+ return;
+
+ cy = s->cy;
+ for (yy = py; yy < py + ny; yy++) {
+ cx = s->cx;
+ for (xx = px; xx < px + nx; xx++) {
+ if (xx >= gd->linedata[yy].cellsize)
+ break;
+ grid_get_cell(gd, xx, yy, &gc);
+ if (!grid_cells_equal(&gc, &grid_default_cell))
+ grid_view_set_cell(ctx->s->grid, cx, cy, &gc);
+ cx++;
+ }
+ cy++;
+ }
+}
+
/* Draw a horizontal line on screen. */
void
screen_write_hline(struct screen_write_ctx *ctx, u_int nx, int left, int right)
@@ -471,7 +500,10 @@ screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny)
screen_write_cursormove(ctx, cx, cy);
}
-/* Write a preview version of a window. */
+/*
+ * Write a preview version of a window. Assumes target area is big enough and
+ * already cleared.
+ */
void
screen_write_preview(struct screen_write_ctx *ctx, struct screen *src, u_int nx,
u_int ny)
@@ -515,8 +547,7 @@ screen_write_preview(struct screen_write_ctx *ctx, struct screen *src, u_int nx,
py = 0;
}
- screen_write_copy(ctx, src, px, src->grid->hsize + py, nx, ny, NULL,
- NULL);
+ screen_write_fast_copy(ctx, src, px, src->grid->hsize + py, nx, ny);
if (src->mode & MODE_CURSOR) {
grid_view_get_cell(src->grid, src->cx, src->cy, &gc);
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index b21f53df3a6..a49087e5486 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.170 2017/10/20 13:10:54 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.171 2017/11/02 21:29:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -508,8 +508,7 @@ draw:
/* Copy the window list. */
c->wlmouse = -wloffset + wlstart;
screen_write_cursormove(&ctx, wloffset, 0);
- screen_write_copy(&ctx, &window_list, wlstart, 0, wlwidth, 1, NULL,
- NULL);
+ screen_write_fast_copy(&ctx, &window_list, wlstart, 0, wlwidth, 1);
screen_free(&window_list);
screen_write_stop(&ctx);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 55d1dca386e..05928bfc80f 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.809 2017/11/02 18:27:35 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.810 2017/11/02 21:29:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2037,6 +2037,8 @@ void screen_write_putc(struct screen_write_ctx *, const struct grid_cell *,
u_char);
void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int,
u_int, u_int, u_int, bitstr_t *, const struct grid_cell *);
+void screen_write_fast_copy(struct screen_write_ctx *, struct screen *,
+ u_int, u_int, u_int, u_int);
void screen_write_hline(struct screen_write_ctx *, u_int, int, int);
void screen_write_vline(struct screen_write_ctx *, u_int, int, int);
void screen_write_box(struct screen_write_ctx *, u_int, u_int);
diff --git a/usr.bin/tmux/window-client.c b/usr.bin/tmux/window-client.c
index 222065a9a30..85f118d9504 100644
--- a/usr.bin/tmux/window-client.c
+++ b/usr.bin/tmux/window-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-client.c,v 1.9 2017/10/25 11:26:11 nicm Exp $ */
+/* $OpenBSD: window-client.c,v 1.10 2017/11/02 21:29:17 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -235,9 +235,9 @@ window_client_draw(__unused void *modedata, void *itemdata, u_int sx, u_int sy)
screen_write_cursormove(&ctx, 0, sy - 1);
if (c->old_status != NULL)
- screen_write_copy(&ctx, c->old_status, 0, 0, sx, 1, NULL, NULL);
+ screen_write_fast_copy(&ctx, c->old_status, 0, 0, sx, 1);
else
- screen_write_copy(&ctx, &c->status, 0, 0, sx, 1, NULL, NULL);
+ screen_write_fast_copy(&ctx, &c->status, 0, 0, sx, 1);
screen_write_stop(&ctx);
return (&s);