summaryrefslogtreecommitdiffstats
path: root/key-bindings.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-02-06 22:55:31 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-02-06 22:55:31 +0000
commitbb53c20c1882cbc909d4fe2ae3c6ad665da6abf6 (patch)
tree345afb7897f7639b2c8981674e064d976f68ab57 /key-bindings.c
parent0a86d3579edb44ee559cfe6498f43d6637a08bd9 (diff)
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.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/key-bindings.c b/key-bindings.c
index d536af11..c08ac942 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -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);
}