From c7243b73cb3baaf6993d8a9dfb16c054c3978040 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 2 Jun 2008 18:08:17 +0000 Subject: Move -s and -c down a level so handling them is the responsibility of the command (with some helper functions), rather than the top-level. This changes the action command syntax so that -s and -c must be after the command rather than before. --- cmd-paste-buffer.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'cmd-paste-buffer.c') diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c index 349feb48..30146ad4 100644 --- a/cmd-paste-buffer.c +++ b/cmd-paste-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-paste-buffer.c,v 1.2 2007-12-06 09:46:22 nicm Exp $ */ +/* $Id: cmd-paste-buffer.c,v 1.3 2008-06-02 18:08:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -31,25 +31,29 @@ void cmd_paste_buffer_exec(void *, struct cmd_ctx *); const struct cmd_entry cmd_paste_buffer_entry = { - "paste-buffer", NULL, "paste", - CMD_NOCLIENT, - NULL, + "paste-buffer", "paste", + CMD_SESSIONONLY_USAGE, + 0, + cmd_sessiononly_parse, cmd_paste_buffer_exec, - NULL, - NULL, - NULL + cmd_sessiononly_send, + cmd_sessiononly_recv, + cmd_sessiononly_free }; void cmd_paste_buffer_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct window *w = ctx->session->curw->window; + struct session *s; + struct window *w; - if (ctx->flags & CMD_KEY) { - if (paste_buffer != NULL && *paste_buffer != '\0') { - buffer_write( - w->out, paste_buffer, strlen(paste_buffer)); - } + if ((s = cmd_sessiononly_get(ptr, ctx)) == NULL) + return; + w = s->curw->window; + + if (ctx->flags & CMD_KEY && + paste_buffer != NULL && *paste_buffer != '\0') { + buffer_write(w->out, paste_buffer, strlen(paste_buffer)); } if (ctx->cmdclient != NULL) -- cgit