aboutsummaryrefslogtreecommitdiff
path: root/key-bindings.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-02-08 18:27:34 +0000
committerTiago Cunha <tcunha@gmx.com>2010-02-08 18:27:34 +0000
commitc6ba78137977bd7a447fd5f97b205544c2b41505 (patch)
treeec4d93053a821886b0a651d9d88d277d1e92966b /key-bindings.c
parent9b57743cca71a7b2313a8d4f41558e8ec0404d9b (diff)
downloadrtmux-c6ba78137977bd7a447fd5f97b205544c2b41505.tar.gz
rtmux-c6ba78137977bd7a447fd5f97b205544c2b41505.tar.bz2
rtmux-c6ba78137977bd7a447fd5f97b205544c2b41505.zip
Sync OpenBSD patchset 639:
Support attaching a client read-only with a new -r flag to the attach-session command.
Diffstat (limited to 'key-bindings.c')
-rw-r--r--key-bindings.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/key-bindings.c b/key-bindings.c
index 3af974f8..1c6d9112 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -1,4 +1,4 @@
-/* $Id: key-bindings.c,v 1.87 2009-12-10 16:59:02 tcunha Exp $ */
+/* $Id: key-bindings.c,v 1.88 2010-02-08 18:27:34 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -239,7 +239,9 @@ key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
void
key_bindings_dispatch(struct key_binding *bd, struct client *c)
{
- struct cmd_ctx ctx;
+ struct cmd_ctx ctx;
+ struct cmd *cmd;
+ int readonly;
ctx.msgdata = NULL;
ctx.curclient = c;
@@ -250,5 +252,15 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c)
ctx.cmdclient = NULL;
+ readonly = 1;
+ TAILQ_FOREACH(cmd, bd->cmdlist, qentry) {
+ if (!(cmd->entry->flags & CMD_READONLY))
+ readonly = 0;
+ }
+ if (!readonly && c->flags & CLIENT_READONLY) {
+ key_bindings_info(&ctx, "Client is read-only");
+ return;
+ }
+
cmd_list_exec(bd->cmdlist, &ctx);
}