aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-set-option.c21
-rw-r--r--format.c2
-rw-r--r--options-table.c2
-rw-r--r--tmux.119
-rw-r--r--window.c29
5 files changed, 49 insertions, 24 deletions
diff --git a/cmd-set-option.c b/cmd-set-option.c
index 0df12aa0..70e3c54d 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -33,8 +33,8 @@ const struct cmd_entry cmd_set_option_entry = {
.name = "set-option",
.alias = "set",
- .args = { "aFgopqst:uw", 1, 2 },
- .usage = "[-aFgopqsuw] " CMD_TARGET_PANE_USAGE " option [value]",
+ .args = { "aFgopqst:uUw", 1, 2 },
+ .usage = "[-aFgopqsuUw] " CMD_TARGET_PANE_USAGE " option [value]",
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
@@ -74,8 +74,9 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self);
int append = args_has(args, 'a');
struct cmd_find_state *target = cmdq_get_target(item);
+ struct window_pane *loop;
struct options *oo;
- struct options_entry *parent, *o;
+ struct options_entry *parent, *o, *po;
char *name, *argument, *value = NULL, *cause;
int window, idx, already, error, ambiguous;
int scope;
@@ -148,7 +149,19 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
}
/* Change the option. */
- if (args_has(args, 'u')) {
+ if (args_has(args, 'U') && scope == OPTIONS_TABLE_WINDOW) {
+ TAILQ_FOREACH(loop, &target->w->panes, entry) {
+ po = options_get_only(loop->options, name);
+ if (po == NULL)
+ continue;
+ if (options_remove_or_default(po, idx, &cause) != 0) {
+ cmdq_error(item, "%s", cause);
+ free(cause);
+ goto fail;
+ }
+ }
+ }
+ if (args_has(args, 'u') || args_has(args, 'U')) {
if (o == NULL)
goto out;
if (options_remove_or_default(o, idx, &cause) != 0) {
diff --git a/format.c b/format.c
index 98dc4cb7..3611efe9 100644
--- a/format.c
+++ b/format.c
@@ -3085,7 +3085,7 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
format_add_cb(ft, "pane_in_mode", format_cb_pane_in_mode);
format_add(ft, "pane_synchronized", "%d",
- !!options_get_number(w->options, "synchronize-panes"));
+ !!options_get_number(wp->options, "synchronize-panes"));
if (wp->searchstr != NULL)
format_add(ft, "pane_search_string", "%s", wp->searchstr);
diff --git a/options-table.c b/options-table.c
index 56e1c895..34a4c57b 100644
--- a/options-table.c
+++ b/options-table.c
@@ -958,7 +958,7 @@ const struct options_table_entry options_table[] = {
{ .name = "synchronize-panes",
.type = OPTIONS_TABLE_FLAG,
- .scope = OPTIONS_TABLE_WINDOW,
+ .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
.default_num = 0,
.text = "Whether typing should be sent to all panes simultaneously."
},
diff --git a/tmux.1 b/tmux.1
index f9a9cdf3..344f3b72 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3136,7 +3136,7 @@ abc123
Commands which set options are as follows:
.Bl -tag -width Ds
.It Xo Ic set-option
-.Op Fl aFgopqsuw
+.Op Fl aFgopqsuUw
.Op Fl t Ar target-pane
.Ar option Ar value
.Xc
@@ -3169,6 +3169,11 @@ flag unsets an option, so a session inherits the option from the global
options (or with
.Fl g ,
restores a global option to the default).
+.Fl U
+unsets an option (like
+.Fl u )
+but if the option is a pane option also unsets the option on any panes in the
+window.
.Ar value
depends on the option and may be a number, a string, or a flag (on, off, or
omitted to toggle).
@@ -4062,12 +4067,6 @@ see the
section.
Attributes are ignored.
.Pp
-.It Xo Ic synchronize-panes
-.Op Ic on | off
-.Xc
-Duplicate input to any pane to all other panes in the same window (only
-for panes that are not in any special mode).
-.Pp
.It Ic window-status-activity-style Ar style
Set status line style for windows with an activity alert.
For how to specify
@@ -4190,6 +4189,12 @@ The pane may be reactivated with the
.Ic respawn-pane
command.
.Pp
+.It Xo Ic synchronize-panes
+.Op Ic on | off
+.Xc
+Duplicate input to all other panes in the same window where this option is also
+on (only for panes that are not in any mode).
+.Pp
.It Ic window-active-style Ar style
Set the pane style when it is the active pane.
For how to specify
diff --git a/window.c b/window.c
index 66298495..22986a04 100644
--- a/window.c
+++ b/window.c
@@ -1145,12 +1145,27 @@ window_pane_reset_mode_all(struct window_pane *wp)
window_pane_reset_mode(wp);
}
+static void
+window_pane_copy_key(struct window_pane *wp, key_code key)
+{
+ struct window_pane *loop;
+
+ TAILQ_FOREACH(loop, &wp->window->panes, entry) {
+ if (loop != wp &&
+ TAILQ_EMPTY(&loop->modes) &&
+ loop->fd != -1 &&
+ (~loop->flags & PANE_INPUTOFF) &&
+ window_pane_visible(loop) &&
+ options_get_number(loop->options, "synchronize-panes"))
+ input_key_pane(loop, key, NULL);
+ }
+}
+
int
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
struct winlink *wl, key_code key, struct mouse_event *m)
{
struct window_mode_entry *wme;
- struct window_pane *wp2;
if (KEYC_IS_MOUSE(key) && m == NULL)
return (-1);
@@ -1172,16 +1187,8 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
if (KEYC_IS_MOUSE(key))
return (0);
- if (options_get_number(wp->window->options, "synchronize-panes")) {
- TAILQ_FOREACH(wp2, &wp->window->panes, entry) {
- if (wp2 != wp &&
- TAILQ_EMPTY(&wp2->modes) &&
- wp2->fd != -1 &&
- (~wp2->flags & PANE_INPUTOFF) &&
- window_pane_visible(wp2))
- input_key_pane(wp2, key, NULL);
- }
- }
+ if (options_get_number(wp->options, "synchronize-panes"))
+ window_pane_copy_key(wp, key);
return (0);
}