summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-08-16 10:00:53 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-08-16 10:00:53 +0000
commit7d91d2a9a173d0f842a9be82c870cd5431f233c5 (patch)
treee83ed52aa808fe23bc47019fe663b707a49f7346 /usr.bin/tmux
parent012465707b15b23744f8fe4a3db4b0ed5fef0309 (diff)
Add a -r flag to switch-client to toggle the client read-only flag. From
Johan Commelin.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-choose-client.c8
-rw-r--r--usr.bin/tmux/cmd-list-clients.c9
-rw-r--r--usr.bin/tmux/cmd-switch-client.c18
-rw-r--r--usr.bin/tmux/tmux.114
4 files changed, 34 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-choose-client.c b/usr.bin/tmux/cmd-choose-client.c
index 70bab74cf04..87ee1302aee 100644
--- a/usr.bin/tmux/cmd-choose-client.c
+++ b/usr.bin/tmux/cmd-choose-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-choose-client.c,v 1.5 2011/01/04 00:42:46 nicm Exp $ */
+/* $OpenBSD: cmd-choose-client.c,v 1.6 2011/08/16 10:00:52 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -76,9 +76,11 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
idx++;
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->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);
diff --git a/usr.bin/tmux/cmd-list-clients.c b/usr.bin/tmux/cmd-list-clients.c
index 5822ce424a3..7b7b436b826 100644
--- a/usr.bin/tmux/cmd-list-clients.c
+++ b/usr.bin/tmux/cmd-list-clients.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-clients.c,v 1.7 2011/04/17 19:28:09 nicm Exp $ */
+/* $OpenBSD: cmd-list-clients.c,v 1.8 2011/08/16 10:00:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_list_clients_entry = {
"list-clients", "lsc",
"t:", 0, 0,
CMD_TARGET_SESSION_USAGE,
- 0,
+ CMD_READONLY,
NULL,
NULL,
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)
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->tty.termname, s_utf8);
+ c->tty.termname, s_utf8,
+ c->flags & CLIENT_READONLY ? " (ro)" : "");
}
return (0);
diff --git a/usr.bin/tmux/cmd-switch-client.c b/usr.bin/tmux/cmd-switch-client.c
index 1a0de247492..1ff9e643fb1 100644
--- a/usr.bin/tmux/cmd-switch-client.c
+++ b/usr.bin/tmux/cmd-switch-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-switch-client.c,v 1.12 2011/04/05 19:37:01 nicm Exp $ */
+/* $OpenBSD: cmd-switch-client.c,v 1.13 2011/08/16 10:00:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,9 +32,9 @@ int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_switch_client_entry = {
"switch-client", "switchc",
- "lc:npt:", 0, 0,
- "[-lnp] [-c target-client] [-t target-session]",
- 0,
+ "lc:npt:r", 0, 0,
+ "[-lnpr] [-c target-client] [-t target-session]",
+ CMD_READONLY,
cmd_switch_client_key_binding,
NULL,
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)
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;
if (args_has(args, 'n')) {
if ((s = session_next_session(c->session)) == NULL) {
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 9c63f7ebc20..008eebd56e8 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.241 2011/07/30 18:27:57 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.242 2011/08/16 10:00:52 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -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: July 30 2011 $
+.Dd $Mdocdate: August 16 2011 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -558,7 +558,9 @@ is specified, any other clients attached to the session are detached.
.Fl r
signifies the client is read-only (only keys bound to the
.Ic detach-client
-command have any effect)
+or
+.Ic switch-client
+commands have any effect)
.Pp
If no server is started,
.Ic attach-session
@@ -714,7 +716,7 @@ Suspend a client by sending
.Dv SIGTSTP
(tty stop).
.It Xo Ic switch-client
-.Op Fl lnp
+.Op Fl lnpr
.Op Fl c Ar target-client
.Op Fl t Ar target-session
.Xc
@@ -730,6 +732,10 @@ or
.Fl p
is used, the client is moved to the last, next or previous session
respectively.
+.Fl r
+toggles whether a client is read-only (see the
+.Ic attach-session
+command).
.El
.Sh WINDOWS AND PANES
A