summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-07-01 06:56:01 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-07-01 06:56:01 +0000
commitfe25aa640715d993e23959ead79edebaee268390 (patch)
tree47f20d3d9da3af502960f3beb47ff497ea694216 /usr.bin/tmux
parenta790f6192f4648094ff1620d534aadb6cff9e90a (diff)
Add a "fill" style attribute to clear the entire format drawing area in
a colour, GitHub issue 1815.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/format-draw.c17
-rw-r--r--usr.bin/tmux/style.c14
-rw-r--r--usr.bin/tmux/tmux.17
-rw-r--r--usr.bin/tmux/tmux.h3
4 files changed, 35 insertions, 6 deletions
diff --git a/usr.bin/tmux/format-draw.c b/usr.bin/tmux/format-draw.c
index da361b41029..c74f2841a99 100644
--- a/usr.bin/tmux/format-draw.c
+++ b/usr.bin/tmux/format-draw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format-draw.c,v 1.10 2019/06/14 15:35:58 nicm Exp $ */
+/* $OpenBSD: format-draw.c,v 1.11 2019/07/01 06:56:00 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -511,8 +511,9 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
u_int ocx = os->cx, ocy = os->cy, i, width[TOTAL];
u_int map[] = { LEFT, LEFT, CENTRE, RIGHT };
int focus_start = -1, focus_end = -1;
- int list_state = -1;
+ int list_state = -1, fill = -1;
enum style_align list_align = STYLE_ALIGN_DEFAULT;
+ struct grid_cell gc;
struct style sy;
struct utf8_data *ud = &sy.gc.data;
const char *cp, *end;
@@ -590,6 +591,10 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
style_tostring(&sy));
free(tmp);
+ /* If this style has a fill colour, store it for later. */
+ if (sy.fill != 8)
+ fill = sy.fill;
+
/* Check the list state. */
switch (sy.list) {
case STYLE_LIST_ON:
@@ -711,6 +716,14 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
fr->argument, names[fr->index], fr->start, fr->end);
}
+ /* Clear the available area. */
+ if (fill != -1) {
+ memcpy(&gc, &grid_default_cell, sizeof gc);
+ gc.bg = fill;
+ for (i = 0; i < available; i++)
+ screen_write_putc(octx, &gc, ' ');
+ }
+
/*
* Draw the screens. How they are arranged depends on where the list
* appearsq.
diff --git a/usr.bin/tmux/style.c b/usr.bin/tmux/style.c
index 3d76db467a5..887036ef280 100644
--- a/usr.bin/tmux/style.c
+++ b/usr.bin/tmux/style.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: style.c,v 1.21 2019/06/27 15:17:41 nicm Exp $ */
+/* $OpenBSD: style.c,v 1.22 2019/07/01 06:56:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -32,6 +32,7 @@
static struct style style_default = {
{ 0, 0, 8, 8, 0, { { ' ' }, 0, 1, 1 } },
+ 8,
STYLE_ALIGN_DEFAULT,
STYLE_LIST_OFF,
@@ -127,6 +128,10 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
sy->align = STYLE_ALIGN_RIGHT;
else
goto error;
+ } else if (end > 5 && strncasecmp(tmp, "fill=", 5) == 0) {
+ if ((value = colour_fromstring(tmp + 5)) == -1)
+ goto error;
+ sy->fill = value;
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) {
if ((value = colour_fromstring(tmp + 3)) == -1)
goto error;
@@ -213,6 +218,11 @@ style_tostring(struct style *sy)
tmp);
comma = ",";
}
+ if (sy->fill != 8) {
+ off += xsnprintf(s + off, sizeof s - off, "%sfill=%s", comma,
+ colour_tostring(sy->fill));
+ comma = ",";
+ }
if (gc->fg != 8) {
off += xsnprintf(s + off, sizeof s - off, "%sfg=%s", comma,
colour_tostring(gc->fg));
@@ -290,6 +300,8 @@ style_equal(struct style *sy1, struct style *sy2)
return (0);
if ((gc1->attr & STYLE_ATTR_MASK) != (gc2->attr & STYLE_ATTR_MASK))
return (0);
+ if (sy1->fill != sy2->fill)
+ return (0);
if (sy1->align != sy2->align)
return (0);
return (1);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 89dad13c4ff..b07c75db48e 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.673 2019/06/27 17:29:16 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.674 2019/07/01 06:56:00 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 27 2019 $
+.Dd $Mdocdate: July 1 2019 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -4337,6 +4337,9 @@ to unset.
.Ic align=right
.Xc
Align text to the left, centre or right of the available space if appropriate.
+.It Xo Ic fill=colour
+.Xc
+Fill the available space with a background colour if appropriate.
.It Xo Ic list=on ,
.Ic list=focus ,
.Ic list=left-marker ,
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 85af1e2027d..74b1c28d051 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.917 2019/06/30 19:21:53 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.918 2019/07/01 06:56:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -682,6 +682,7 @@ TAILQ_HEAD(style_ranges, style_range);
struct style {
struct grid_cell gc;
+ int fill;
enum style_align align;
enum style_list list;