summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-10-25 15:13:39 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-10-25 15:13:39 +0000
commit5650c2b39286b57f4f4c47f76527367cf5066e27 (patch)
tree8d857f06e204b9edfe43f54109f0450216315ee4 /usr.bin/tmux
parentb6e37a7900023f8d0e428855a7979ad75542dc89 (diff)
Add a "terminal" colour which can be used instead of "default" in style
options for the terminal default colour, bypassing any inheritance from other options. Prompted by a discussion with abieber@.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/colour.c11
-rw-r--r--usr.bin/tmux/grid.c18
-rw-r--r--usr.bin/tmux/options-table.c4
-rw-r--r--usr.bin/tmux/screen-write.c6
-rw-r--r--usr.bin/tmux/tmux.115
-rw-r--r--usr.bin/tmux/tmux.h5
-rw-r--r--usr.bin/tmux/tty.c40
7 files changed, 59 insertions, 40 deletions
diff --git a/usr.bin/tmux/colour.c b/usr.bin/tmux/colour.c
index 3097c3c218c..63dfaa22846 100644
--- a/usr.bin/tmux/colour.c
+++ b/usr.bin/tmux/colour.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: colour.c,v 1.15 2017/03/24 07:14:27 nicm Exp $ */
+/* $OpenBSD: colour.c,v 1.16 2018/10/25 15:13:38 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -141,6 +141,8 @@ colour_tostring(int c)
return ("white");
case 8:
return ("default");
+ case 9:
+ return ("terminal");
case 90:
return ("brightblack");
case 91:
@@ -188,6 +190,11 @@ colour_fromstring(const char *s)
return (n | COLOUR_FLAG_256);
}
+ if (strcasecmp(s, "default") == 0)
+ return (8);
+ if (strcasecmp(s, "terminal") == 0)
+ return (9);
+
if (strcasecmp(s, "black") == 0 || strcmp(s, "0") == 0)
return (0);
if (strcasecmp(s, "red") == 0 || strcmp(s, "1") == 0)
@@ -204,8 +211,6 @@ colour_fromstring(const char *s)
return (6);
if (strcasecmp(s, "white") == 0 || strcmp(s, "7") == 0)
return (7);
- if (strcasecmp(s, "default") == 0 || strcmp(s, "8") == 0)
- return (8);
if (strcasecmp(s, "brightblack") == 0 || strcmp(s, "90") == 0)
return (90);
if (strcasecmp(s, "brightred") == 0 || strcmp(s, "91") == 0)
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index 36237865048..ef8d25550f6 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.87 2018/10/18 07:57:57 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.88 2018/10/25 15:13:38 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -418,7 +418,7 @@ static void
grid_empty_line(struct grid *gd, u_int py, u_int bg)
{
memset(&gd->linedata[py], 0, sizeof gd->linedata[py]);
- if (bg != 8)
+ if (!COLOUR_DEFAULT(bg))
grid_expand_line(gd, py, gd->sx, bg);
}
@@ -524,7 +524,8 @@ grid_set_cells(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc,
void
grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg)
{
- u_int xx, yy;
+ struct grid_line *gl;
+ u_int xx, yy;
if (nx == 0 || ny == 0)
return;
@@ -540,12 +541,13 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg)
return;
for (yy = py; yy < py + ny; yy++) {
- if (px + nx >= gd->sx && px < gd->linedata[yy].cellused)
- gd->linedata[yy].cellused = px;
- if (px > gd->linedata[yy].cellsize && bg == 8)
+ gl = &gd->linedata[yy];
+ if (px + nx >= gd->sx && px < gl->cellused)
+ gl->cellused = px;
+ if (px > gl->cellsize && COLOUR_DEFAULT(bg))
continue;
- if (px + nx >= gd->linedata[yy].cellsize && bg == 8) {
- gd->linedata[yy].cellsize = px;
+ if (px + nx >= gl->cellsize && COLOUR_DEFAULT(bg)) {
+ gl->cellsize = px;
continue;
}
grid_expand_line(gd, yy, px + nx, 8); /* default bg first */
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index af73e14cb04..d8d81514cf9 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-table.c,v 1.97 2018/10/18 08:38:01 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.98 2018/10/25 15:13:38 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -771,7 +771,7 @@ const struct options_table_entry options_table[] = {
.type = OPTIONS_TABLE_CHOICE,
.scope = OPTIONS_TABLE_WINDOW,
.choices = options_table_window_size_list,
- .default_num = WINDOW_SIZE_LARGEST
+ .default_num = WINDOW_SIZE_SMALLEST
},
{ .name = "window-style",
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index ae9424de63f..20036732656 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.139 2018/10/18 08:38:01 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.140 2018/10/25 15:13:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -965,7 +965,7 @@ screen_write_clearline(struct screen_write_ctx *ctx, u_int bg)
u_int sx = screen_size_x(s);
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
- if (gl->cellsize == 0 && bg == 8)
+ if (gl->cellsize == 0 && COLOUR_DEFAULT(bg))
return;
screen_write_initctx(ctx, &ttyctx);
@@ -988,7 +988,7 @@ screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
u_int sx = screen_size_x(s);
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
- if (s->cx > sx - 1 || (s->cx >= gl->cellsize && bg == 8))
+ if (s->cx > sx - 1 || (s->cx >= gl->cellsize && COLOUR_DEFAULT(bg)))
return;
screen_write_initctx(ctx, &ttyctx);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 4afbb64da53..9f84cc8ebbf 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.613 2018/10/18 13:03:45 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.614 2018/10/25 15:13:38 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: October 18 2018 $
+.Dd $Mdocdate: October 25 2018 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -2750,7 +2750,7 @@ Set status line message command style, where
.Ar style
is a comma-separated list of characteristics to be specified.
.Pp
-These may be
+The style format is shared by many options and may be:
.Ql bg=colour
to set the background colour,
.Ql fg=colour
@@ -2773,8 +2773,13 @@ and so on),
to
.Ic colour255
from the 256-colour set,
-.Ic default ,
-or a hexadecimal RGB string such as
+.Ic default
+for the default colour (inherited from another option in the case of some options, for example
+.Ic window-status-style
+inherits from
+.Ic status-style ) ,
+.Ic terminal
+for the terminal default colour, or a hexadecimal RGB string such as
.Ql #ffffff .
.Pp
The attributes is either
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 85eb4b4ccf8..49a0258b67e 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.849 2018/10/18 08:38:01 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.850 2018/10/25 15:13:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -543,6 +543,9 @@ enum utf8_state {
#define COLOUR_FLAG_256 0x01000000
#define COLOUR_FLAG_RGB 0x02000000
+/* Special colours. */
+#define COLOUR_DEFAULT(c) ((c) == 8 || (c) == 9)
+
/* Grid attributes. Anything above 0xff is stored in an extended cell. */
#define GRID_ATTR_BRIGHT 0x1
#define GRID_ATTR_DIM 0x2
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 3248e99bc41..e5298c6f368 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.309 2018/10/18 08:38:01 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.310 2018/10/25 15:13:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -851,7 +851,7 @@ tty_fake_bce(const struct tty *tty, const struct window_pane *wp, u_int bg)
if (wp != NULL)
tty_default_colours(&gc, wp);
- if (bg != 8 || gc.bg != 8)
+ if (!COLOUR_DEFAULT(bg) || !COLOUR_DEFAULT(gc.bg))
return (1);
return (0);
}
@@ -1098,7 +1098,7 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py,
* background colour isn't default (because it doesn't work
* after SGR 0).
*/
- if (tty->term_type == TTY_VT420 && bg != 8) {
+ if (tty->term_type == TTY_VT420 && COLOUR_DEFAULT(bg)) {
xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x",
py + 1, px + 1, py + ny, px + nx);
tty_puts(tty, tmp);
@@ -2134,10 +2134,10 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc,
*/
if (!tty_term_has(tty->term, TTYC_SETAB)) {
if (gc2.attr & GRID_ATTR_REVERSE) {
- if (gc2.fg != 7 && gc2.fg != 8)
+ if (gc2.fg != 7 && !COLOUR_DEFAULT(gc2.fg))
gc2.attr &= ~GRID_ATTR_REVERSE;
} else {
- if (gc2.bg != 0 && gc2.bg != 8)
+ if (gc2.bg != 0 && !COLOUR_DEFAULT(gc2.bg))
gc2.attr |= GRID_ATTR_REVERSE;
}
}
@@ -2212,7 +2212,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc)
* case if only one is default need to fall onward to set the other
* colour.
*/
- if (gc->fg == 8 || gc->bg == 8) {
+ if (COLOUR_DEFAULT(gc->fg) || COLOUR_DEFAULT(gc->bg)) {
/*
* If don't have AX but do have op, send sgr0 (op can't
* actually be used because it is sometimes the same as sgr0
@@ -2224,32 +2224,32 @@ tty_colours(struct tty *tty, const struct grid_cell *gc)
if (!have_ax && tty_term_has(tty->term, TTYC_OP))
tty_reset(tty);
else {
- if (gc->fg == 8 && tc->fg != 8) {
+ if (COLOUR_DEFAULT(gc->fg) && !COLOUR_DEFAULT(tc->fg)) {
if (have_ax)
tty_puts(tty, "\033[39m");
else if (tc->fg != 7)
tty_putcode1(tty, TTYC_SETAF, 7);
- tc->fg = 8;
+ tc->fg = gc->fg;
}
- if (gc->bg == 8 && tc->bg != 8) {
+ if (COLOUR_DEFAULT(gc->bg) && !COLOUR_DEFAULT(tc->bg)) {
if (have_ax)
tty_puts(tty, "\033[49m");
else if (tc->bg != 0)
tty_putcode1(tty, TTYC_SETAB, 0);
- tc->bg = 8;
+ tc->bg = gc->fg;
}
}
}
/* Set the foreground colour. */
- if (gc->fg != 8 && gc->fg != tc->fg)
+ if (!COLOUR_DEFAULT(gc->fg) && gc->fg != tc->fg)
tty_colours_fg(tty, gc);
/*
* Set the background colour. This must come after the foreground as
* tty_colour_fg() can call tty_reset().
*/
- if (gc->bg != 8 && gc->bg != tc->bg)
+ if (!COLOUR_DEFAULT(gc->bg) && gc->bg != tc->bg)
tty_colours_bg(tty, gc);
}
@@ -2515,9 +2515,11 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
else
gc->fg = wgc->fg;
- if (gc->fg != 8 &&
- (c = window_pane_get_palette(wp, gc->fg)) != -1)
- gc->fg = c;
+ if (gc->fg != 8) {
+ c = window_pane_get_palette(wp, gc->fg);
+ if (c != -1)
+ gc->fg = c;
+ }
}
if (gc->bg == 8) {
@@ -2528,9 +2530,11 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
else
gc->bg = wgc->bg;
- if (gc->bg != 8 &&
- (c = window_pane_get_palette(wp, gc->bg)) != -1)
- gc->bg = c;
+ if (gc->bg != 8) {
+ c = window_pane_get_palette(wp, gc->bg);
+ if (c != -1)
+ gc->bg = c;
+ }
}
}