The branch, master has been updated
       via  1d591ada76c049343feab503863cc57308bb1280 (commit)
      from  2bdc59fac8aef9df6ef53a13e59221153619770d (commit)

- Log -----------------------------------------------------------------
commit 1d591ada76c049343feab503863cc57308bb1280
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Support capture-pane -p to send to stdout.
---
 cmd-capture-pane.c |   57 +++++++++++++++++++++++++++++++--------------------
 tmux.1             |   12 +++++++++-
 2 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index adb827b..0fd05f9 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -24,15 +24,16 @@
 #include "tmux.h"
 
 /*
- * Write the entire contents of a pane to a buffer.
+ * Write the entire contents of a pane to a buffer or stdout.
  */
 
 enum cmd_retval         cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
 
 const struct cmd_entry cmd_capture_pane_entry = {
        "capture-pane", "capturep",
-       "b:E:S:t:", 0, 0,
-       "[-b buffer-index] [-E end-line] [-S start-line] "
+       "b:c:E:pS:t:", 0, 0,
+       "[-p] [-c target-client] [-b buffer-index] [-E end-line] "
+       "[-S start-line] "
        CMD_TARGET_PANE_USAGE,
        0,
        NULL,
@@ -44,6 +45,7 @@ enum cmd_retval
 cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 {
        struct args             *args = self->args;
+       struct client           *c;
        struct window_pane      *wp;
        char                    *buf, *line, *cause;
        struct screen           *s;
@@ -52,6 +54,9 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
        u_int                    i, limit, top, bottom, tmp;
        size_t                   len, linelen;
 
+       if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
+               return (CMD_RETURN_ERROR);
+
        if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
                return (CMD_RETURN_ERROR);
        s = &wp->base;
@@ -100,25 +105,33 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx 
*ctx)
               free(line);
        }
 
-       limit = options_get_number(&global_options, "buffer-limit");
-
-       if (!args_has(args, 'b')) {
-               paste_add(&global_buffers, buf, len, limit);
-               return (CMD_RETURN_NORMAL);
-       }
-
-       buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
-       if (cause != NULL) {
-               ctx->error(ctx, "buffer %s", cause);
-               free(buf);
-               free(cause);
-               return (CMD_RETURN_ERROR);
-       }
-
-       if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
-               ctx->error(ctx, "no buffer %d", buffer);
-               free(buf);
-               return (CMD_RETURN_ERROR);
+       if (args_has(args, 'p')) {
+               if (c == NULL) {
+                       ctx->error(ctx, "can't write to stdout");
+                       return (CMD_RETURN_ERROR);
+               }
+               evbuffer_add(c->stdout_data, buf, len);
+               server_push_stdout(c);
+       } else {
+               limit = options_get_number(&global_options, "buffer-limit");
+               if (!args_has(args, 'b')) {
+                       paste_add(&global_buffers, buf, len, limit);
+                       return (CMD_RETURN_NORMAL);
+               }
+
+               buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
+               if (cause != NULL) {
+                       ctx->error(ctx, "buffer %s", cause);
+                       free(buf);
+                       free(cause);
+                       return (CMD_RETURN_ERROR);
+               }
+
+               if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
+                       ctx->error(ctx, "no buffer %d", buffer);
+                       free(buf);
+                       return (CMD_RETURN_ERROR);
+               }
        }
 
        return (CMD_RETURN_NORMAL);
diff --git a/tmux.1 b/tmux.1
index efb4437..15f93dd 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1040,14 +1040,22 @@ By default, it uses the format
 but a different format may be specified with
 .Fl F .
 .It Xo Ic capture-pane
+.Op Fl p
 .Op Fl b Ar buffer-index
+.Op Fl c Ar target-client
 .Op Fl E Ar end-line
 .Op Fl S Ar start-line
 .Op Fl t Ar target-pane
 .Xc
 .D1 (alias: Ic capturep )
-Capture the contents of a pane to the specified buffer, or a new buffer if none
-is specified.
+Capture the contents of a pane.
+If
+.Fl p
+is given, the output goes to
+.Ar target-client
+stdout, otherwise to the buffer specified with
+.Fl b
+or a new buffer if omitted.
 .Pp
 .Fl S
 and


-----------------------------------------------------------------------

Summary of changes:
 cmd-capture-pane.c |   57 +++++++++++++++++++++++++++++++--------------------
 tmux.1             |   12 +++++++++-
 2 files changed, 45 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to