author | Raghavendra D Prabhu <[email protected]> | 2011-01-23 11:59:16 (GMT) |
---|---|---|
committer | Raghavendra D Prabhu <[email protected]> | 2011-01-23 11:59:16 (GMT) |
commit | 0426ab2b383afd38af7274759c3a8d017bc88f00 (patch) (side-by-side diff) | |
tree | 2cc4bf1da4062c9ef91f2e94a9625f2423f57102 /cmd-show-buffer.c | |
parent | 4e4aed43dc2b40b36f1b31cd3af9f874b78fa454 (diff) | |
parent | b67bfd382d3401de572bb3487b1af3382a9cbeda (diff) | |
download | tmux-old-master.zip tmux-old-master.tar.gz tmux-old-master.tar.bz2 |
merged new changesmaster
-rw-r--r-- | cmd-show-buffer.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/cmd-show-buffer.c b/cmd-show-buffer.c index 0d9d9b5..4222697 100644 --- a/cmd-show-buffer.c +++ b/cmd-show-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-show-buffer.c,v 1.12 2009/12/04 22:14:47 tcunha Exp $ */ +/* $Id: cmd-show-buffer.c,v 1.14 2011/01/07 14:45:34 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <[email protected]> @@ -28,39 +28,47 @@ int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_show_buffer_entry = { "show-buffer", "showb", - CMD_BUFFER_SESSION_USAGE, - 0, "", - cmd_buffer_init, - cmd_buffer_parse, - cmd_show_buffer_exec, - cmd_buffer_free, - cmd_buffer_print + "b:", 0, 0, + CMD_BUFFER_USAGE, + 0, + NULL, + NULL, + cmd_show_buffer_exec }; int cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_buffer_data *data = self->data; + struct args *args = self->args; struct session *s; struct paste_buffer *pb; - char *in, *buf, *ptr; + int buffer; + char *in, *buf, *ptr, *cause; size_t size, len; u_int width; - if ((s = cmd_find_session(ctx, data->target)) == NULL) + if ((s = cmd_find_session(ctx, NULL)) == NULL) return (-1); - if (data->buffer == -1) { - if ((pb = paste_get_top(&s->buffers)) == NULL) { + if (!args_has(args, 'b')) { + if ((pb = paste_get_top(&global_buffers)) == NULL) { ctx->error(ctx, "no buffers"); return (-1); } - } else if ((pb = paste_get_index(&s->buffers, data->buffer)) == NULL) { - ctx->error(ctx, "no buffer %d", data->buffer); - return (-1); + } else { + buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); + if (cause != NULL) { + ctx->error(ctx, "buffer %s", cause); + xfree(cause); + return (-1); + } + + pb = paste_get_index(&global_buffers, buffer); + if (pb == NULL) { + ctx->error(ctx, "no buffer %d", buffer); + return (-1); + } } - if (pb == NULL) - return (0); size = pb->size; if (size > SIZE_MAX / 4 - 1) |