version 1.18, 2013/03/22 15:56:11 |
version 1.19, 2013/03/24 09:54:10 |
|
|
* Write the entire contents of a pane to a buffer or stdout. |
* Write the entire contents of a pane to a buffer or stdout. |
*/ |
*/ |
|
|
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *); |
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *); |
|
|
const struct cmd_entry cmd_capture_pane_entry = { |
const struct cmd_entry cmd_capture_pane_entry = { |
"capture-pane", "capturep", |
"capture-pane", "capturep", |
|
|
}; |
}; |
|
|
enum cmd_retval |
enum cmd_retval |
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct client *c; |
struct client *c; |
|
|
struct grid_cell *gc; |
struct grid_cell *gc; |
const struct grid_line *gl; |
const struct grid_line *gl; |
|
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL) |
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL) |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
s = &wp->base; |
s = &wp->base; |
gd = s->grid; |
gd = s->grid; |
|
|
} |
} |
|
|
if (args_has(args, 'p')) { |
if (args_has(args, 'p')) { |
c = ctx->curclient; |
c = cmdq->client; |
if (c == NULL || !(c->flags & CLIENT_CONTROL)) |
if (c == NULL || |
c = ctx->cmdclient; |
(c->session != NULL && !(c->flags & CLIENT_CONTROL))) { |
if (c == NULL) { |
cmdq_error(cmdq, "can't write to stdout"); |
ctx->error(ctx, "can't write to stdout"); |
|
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
evbuffer_add(c->stdout_data, buf, len); |
evbuffer_add(c->stdout_data, buf, len); |
|
|
|
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); |
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); |
if (cause != NULL) { |
if (cause != NULL) { |
ctx->error(ctx, "buffer %s", cause); |
cmdq_error(cmdq, "buffer %s", cause); |
free(buf); |
free(buf); |
free(cause); |
free(cause); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |
|
|
if (paste_replace(&global_buffers, buffer, buf, len) != 0) { |
if (paste_replace(&global_buffers, buffer, buf, len) != 0) { |
ctx->error(ctx, "no buffer %d", buffer); |
cmdq_error(cmdq, "no buffer %d", buffer); |
free(buf); |
free(buf); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |