mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Make synchronize-panes a pane option and add -U flag to set-option to
unset an option on all panes. GitHub issue 2491 from Rostislav Nesin.
This commit is contained in:
@ -33,8 +33,8 @@ const struct cmd_entry cmd_set_option_entry = {
|
|||||||
.name = "set-option",
|
.name = "set-option",
|
||||||
.alias = "set",
|
.alias = "set",
|
||||||
|
|
||||||
.args = { "aFgopqst:uw", 1, 2 },
|
.args = { "aFgopqst:uUw", 1, 2 },
|
||||||
.usage = "[-aFgopqsuw] " CMD_TARGET_PANE_USAGE " option [value]",
|
.usage = "[-aFgopqsuUw] " CMD_TARGET_PANE_USAGE " option [value]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_PANE, CMD_FIND_CANFAIL },
|
.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);
|
struct args *args = cmd_get_args(self);
|
||||||
int append = args_has(args, 'a');
|
int append = args_has(args, 'a');
|
||||||
struct cmd_find_state *target = cmdq_get_target(item);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
|
struct window_pane *loop;
|
||||||
struct options *oo;
|
struct options *oo;
|
||||||
struct options_entry *parent, *o;
|
struct options_entry *parent, *o, *po;
|
||||||
char *name, *argument, *value = NULL, *cause;
|
char *name, *argument, *value = NULL, *cause;
|
||||||
int window, idx, already, error, ambiguous;
|
int window, idx, already, error, ambiguous;
|
||||||
int scope;
|
int scope;
|
||||||
@ -148,7 +149,19 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Change the option. */
|
/* 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)
|
if (o == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
if (options_remove_or_default(o, idx, &cause) != 0) {
|
if (options_remove_or_default(o, idx, &cause) != 0) {
|
||||||
|
2
format.c
2
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_cb(ft, "pane_in_mode", format_cb_pane_in_mode);
|
||||||
|
|
||||||
format_add(ft, "pane_synchronized", "%d",
|
format_add(ft, "pane_synchronized", "%d",
|
||||||
!!options_get_number(w->options, "synchronize-panes"));
|
!!options_get_number(wp->options, "synchronize-panes"));
|
||||||
if (wp->searchstr != NULL)
|
if (wp->searchstr != NULL)
|
||||||
format_add(ft, "pane_search_string", "%s", wp->searchstr);
|
format_add(ft, "pane_search_string", "%s", wp->searchstr);
|
||||||
|
|
||||||
|
@ -958,7 +958,7 @@ const struct options_table_entry options_table[] = {
|
|||||||
|
|
||||||
{ .name = "synchronize-panes",
|
{ .name = "synchronize-panes",
|
||||||
.type = OPTIONS_TABLE_FLAG,
|
.type = OPTIONS_TABLE_FLAG,
|
||||||
.scope = OPTIONS_TABLE_WINDOW,
|
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
|
||||||
.default_num = 0,
|
.default_num = 0,
|
||||||
.text = "Whether typing should be sent to all panes simultaneously."
|
.text = "Whether typing should be sent to all panes simultaneously."
|
||||||
},
|
},
|
||||||
|
19
tmux.1
19
tmux.1
@ -3136,7 +3136,7 @@ abc123
|
|||||||
Commands which set options are as follows:
|
Commands which set options are as follows:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo Ic set-option
|
.It Xo Ic set-option
|
||||||
.Op Fl aFgopqsuw
|
.Op Fl aFgopqsuUw
|
||||||
.Op Fl t Ar target-pane
|
.Op Fl t Ar target-pane
|
||||||
.Ar option Ar value
|
.Ar option Ar value
|
||||||
.Xc
|
.Xc
|
||||||
@ -3169,6 +3169,11 @@ flag unsets an option, so a session inherits the option from the global
|
|||||||
options (or with
|
options (or with
|
||||||
.Fl g ,
|
.Fl g ,
|
||||||
restores a global option to the default).
|
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
|
.Ar value
|
||||||
depends on the option and may be a number, a string, or a flag (on, off, or
|
depends on the option and may be a number, a string, or a flag (on, off, or
|
||||||
omitted to toggle).
|
omitted to toggle).
|
||||||
@ -4062,12 +4067,6 @@ see the
|
|||||||
section.
|
section.
|
||||||
Attributes are ignored.
|
Attributes are ignored.
|
||||||
.Pp
|
.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
|
.It Ic window-status-activity-style Ar style
|
||||||
Set status line style for windows with an activity alert.
|
Set status line style for windows with an activity alert.
|
||||||
For how to specify
|
For how to specify
|
||||||
@ -4190,6 +4189,12 @@ The pane may be reactivated with the
|
|||||||
.Ic respawn-pane
|
.Ic respawn-pane
|
||||||
command.
|
command.
|
||||||
.Pp
|
.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
|
.It Ic window-active-style Ar style
|
||||||
Set the pane style when it is the active pane.
|
Set the pane style when it is the active pane.
|
||||||
For how to specify
|
For how to specify
|
||||||
|
29
window.c
29
window.c
@ -1145,12 +1145,27 @@ window_pane_reset_mode_all(struct window_pane *wp)
|
|||||||
window_pane_reset_mode(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
|
int
|
||||||
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
||||||
struct winlink *wl, key_code key, struct mouse_event *m)
|
struct winlink *wl, key_code key, struct mouse_event *m)
|
||||||
{
|
{
|
||||||
struct window_mode_entry *wme;
|
struct window_mode_entry *wme;
|
||||||
struct window_pane *wp2;
|
|
||||||
|
|
||||||
if (KEYC_IS_MOUSE(key) && m == NULL)
|
if (KEYC_IS_MOUSE(key) && m == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -1172,16 +1187,8 @@ window_pane_key(struct window_pane *wp, struct client *c, struct session *s,
|
|||||||
|
|
||||||
if (KEYC_IS_MOUSE(key))
|
if (KEYC_IS_MOUSE(key))
|
||||||
return (0);
|
return (0);
|
||||||
if (options_get_number(wp->window->options, "synchronize-panes")) {
|
if (options_get_number(wp->options, "synchronize-panes"))
|
||||||
TAILQ_FOREACH(wp2, &wp->window->panes, entry) {
|
window_pane_copy_key(wp, key);
|
||||||
if (wp2 != wp &&
|
|
||||||
TAILQ_EMPTY(&wp2->modes) &&
|
|
||||||
wp2->fd != -1 &&
|
|
||||||
(~wp2->flags & PANE_INPUTOFF) &&
|
|
||||||
window_pane_visible(wp2))
|
|
||||||
input_key_pane(wp2, key, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user