Skip to content

Instantly share code, notes, and snippets.

@qbit
Created October 1, 2018 00:33
Show Gist options
  • Save qbit/ba0458d31be8c7cd777f025e3232acc9 to your computer and use it in GitHub Desktop.
Save qbit/ba0458d31be8c7cd777f025e3232acc9 to your computer and use it in GitHub Desktop.
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index f3622017830..97b21f01e58 100644
--- a/usr.bin/tmux/cmd-set-option.c
+++ b/usr.bin/tmux/cmd-set-option.c
@@ -254,6 +254,7 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
if (strcmp(name, "monitor-silence") == 0)
alerts_reset_all();
if (strcmp(name, "window-style") == 0 ||
+ strcmp(name, "window-inactive-style") == 0 ||
strcmp(name, "window-active-style") == 0) {
RB_FOREACH(w, windows, &windows)
w->flags |= WINDOW_STYLECHANGED;
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index b8ca7f1c8b6..a8171d3de8b 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -771,6 +771,12 @@ const struct options_table_entry options_table[] = {
.default_str = "default"
},
+ { .name = "window-inactive-style",
+ .type = OPTIONS_TABLE_STYLE,
+ .scope = OPTIONS_TABLE_WINDOW,
+ .default_str = "default"
+ },
+
{ .name = "window-style",
.type = OPTIONS_TABLE_STYLE,
.scope = OPTIONS_TABLE_WINDOW,
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index eca8e2afeec..12487d8d637 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -2026,9 +2026,10 @@ and
.Ic swap-window .
.Pp
Each pane has a style: by default the
-.Ic window-style
-and
+.Ic window-style ,
.Ic window-active-style
+and
+.Ic window-inactive-style
options are used,
.Ic select-pane
.Fl P
@@ -3251,6 +3252,14 @@ see the
.Ic message-command-style
option.
.Pp
+.It Ic window-inactive-style Ar style
+Set the style for the window's inactive panes.
+For how to specify
+.Ar style ,
+see the
+.Ic message-command-style
+option.
+.Pp
.It Ic window-status-activity-style Ar style
Set status line style for windows with an activity alert.
For how to specify
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 3c348b1fb29..75e2cae6c5a 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -808,6 +808,7 @@ struct window {
struct grid_cell style;
struct grid_cell active_style;
+ struct grid_cell inactive_style;
u_int references;
TAILQ_HEAD(, winlink) winlinks;
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 754614b27de..80bb9f6307c 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -2146,17 +2146,20 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
{
struct window *w = wp->window;
struct options *oo = w->options;
- const struct grid_cell *agc, *pgc, *wgc;
+ const struct grid_cell *agc, *igc, *pgc, *wgc;
int c;
if (w->flags & WINDOW_STYLECHANGED) {
w->flags &= ~WINDOW_STYLECHANGED;
agc = options_get_style(oo, "window-active-style");
memcpy(&w->active_style, agc, sizeof w->active_style);
+ igc = options_get_style(oo, "window-inactive-style");
+ memcpy(&w->inactive_style, igc, sizeof w->inactive_style);
wgc = options_get_style(oo, "window-style");
memcpy(&w->style, wgc, sizeof w->style);
} else {
agc = &w->active_style;
+ igc = &w->inactive_style;
wgc = &w->style;
}
pgc = &wp->colgc;
@@ -2166,6 +2169,8 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
gc->fg = pgc->fg;
else if (wp == w->active && agc->fg != 8)
gc->fg = agc->fg;
+ else if (wp != w->active && igc->fg != 8)
+ gc->fg = igc->fg;
else
gc->fg = wgc->fg;
@@ -2179,6 +2184,8 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
gc->bg = pgc->bg;
else if (wp == w->active && agc->bg != 8)
gc->bg = agc->bg;
+ else if (wp != w->active && igc->bg != 8)
+ gc->bg = igc->bg;
else
gc->bg = wgc->bg;
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index f94724fdbf1..f0ec870a5fa 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -476,17 +476,19 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
void
window_redraw_active_switch(struct window *w, struct window_pane *wp)
{
- const struct grid_cell *gc;
+ const struct grid_cell *gc, *igc;
if (wp == w->active)
return;
/*
- * If window-style and window-active-style are the same, we don't need
- * to redraw panes when switching active panes.
+ * If window-style and window-{in}active-style are the same, we don't
+ * need to redraw panes when switching active panes.
*/
gc = options_get_style(w->options, "window-active-style");
- if (style_equal(gc, options_get_style(w->options, "window-style")))
+ igc = options_get_style(w->options, "window-inactive-style");
+ if (style_equal(gc, options_get_style(w->options, "window-style")) &&
+ style_equal(igc, gc))
return;
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment