Sync OpenBSD patchset 946:

Add a -r flag to switch-client to toggle the client read-only flag. From
Johan Commelin.
This commit is contained in:
Tiago Cunha 2011-08-21 12:38:55 +00:00
parent 5775074f73
commit 87a2a13f68
4 changed files with 30 additions and 11 deletions

View File

@ -76,9 +76,11 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
idx++; idx++;
window_choose_add(wl->window->active, i, window_choose_add(wl->window->active, i,
"%s: %s [%ux%u %s]%s", c->tty.path, "%s: %s [%ux%u %s]%s%s", c->tty.path,
c->session->name, c->tty.sx, c->tty.sy, c->session->name, c->tty.sx, c->tty.sy,
c->tty.termname, c->tty.flags & TTY_UTF8 ? " (utf8)" : ""); c->tty.termname,
c->tty.flags & TTY_UTF8 ? " (utf8)" : "",
c->flags & CLIENT_READONLY ? " (ro)" : "");
} }
cdata = xmalloc(sizeof *cdata); cdata = xmalloc(sizeof *cdata);

View File

@ -33,7 +33,7 @@ const struct cmd_entry cmd_list_clients_entry = {
"list-clients", "lsc", "list-clients", "lsc",
"t:", 0, 0, "t:", 0, 0,
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, CMD_READONLY,
NULL, NULL,
NULL, NULL,
cmd_list_clients_exec cmd_list_clients_exec
@ -68,9 +68,10 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
if (s != NULL && s != c->session) if (s != NULL && s != c->session)
continue; continue;
ctx->print(ctx, "%s: %s [%ux%u %s]%s", c->tty.path, ctx->print(ctx, "%s: %s [%ux%u %s]%s%s", c->tty.path,
c->session->name, c->tty.sx, c->tty.sy, c->session->name, c->tty.sx, c->tty.sy,
c->tty.termname, s_utf8); c->tty.termname, s_utf8,
c->flags & CLIENT_READONLY ? " (ro)" : "");
} }
return (0); return (0);

View File

@ -32,9 +32,9 @@ int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_switch_client_entry = { const struct cmd_entry cmd_switch_client_entry = {
"switch-client", "switchc", "switch-client", "switchc",
"lc:npt:", 0, 0, "lc:npt:r", 0, 0,
"[-lnp] [-c target-client] [-t target-session]", "[-lnpr] [-c target-client] [-t target-session]",
0, CMD_READONLY,
cmd_switch_client_key_binding, cmd_switch_client_key_binding,
NULL, NULL,
cmd_switch_client_exec cmd_switch_client_exec
@ -67,6 +67,16 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL) if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
return (-1); return (-1);
if (args_has(args, 'r')) {
if (c->flags & CLIENT_READONLY) {
c->flags &= ~CLIENT_READONLY;
ctx->info(ctx, "made client writable");
} else {
c->flags |= CLIENT_READONLY;
ctx->info(ctx, "made client read-only");
}
}
s = NULL; s = NULL;
if (args_has(args, 'n')) { if (args_has(args, 'n')) {
if ((s = session_next_session(c->session)) == NULL) { if ((s = session_next_session(c->session)) == NULL) {

12
tmux.1
View File

@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: July 30 2011 $ .Dd $Mdocdate: August 16 2011 $
.Dt TMUX 1 .Dt TMUX 1
.Os .Os
.Sh NAME .Sh NAME
@ -562,7 +562,9 @@ is specified, any other clients attached to the session are detached.
.Fl r .Fl r
signifies the client is read-only (only keys bound to the signifies the client is read-only (only keys bound to the
.Ic detach-client .Ic detach-client
command have any effect) or
.Ic switch-client
commands have any effect)
.Pp .Pp
If no server is started, If no server is started,
.Ic attach-session .Ic attach-session
@ -718,7 +720,7 @@ Suspend a client by sending
.Dv SIGTSTP .Dv SIGTSTP
(tty stop). (tty stop).
.It Xo Ic switch-client .It Xo Ic switch-client
.Op Fl lnp .Op Fl lnpr
.Op Fl c Ar target-client .Op Fl c Ar target-client
.Op Fl t Ar target-session .Op Fl t Ar target-session
.Xc .Xc
@ -734,6 +736,10 @@ or
.Fl p .Fl p
is used, the client is moved to the last, next or previous session is used, the client is moved to the last, next or previous session
respectively. respectively.
.Fl r
toggles whether a client is read-only (see the
.Ic attach-session
command).
.El .El
.Sh WINDOWS AND PANES .Sh WINDOWS AND PANES
A A