diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-05-13 07:34:36 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-05-13 07:34:36 +0000 |
commit | eea58c09685cd8439bb19a2e328aa366de27f75a (patch) | |
tree | 9cb6bc45f5903458267efca5355da3c61d0c7e99 /usr.bin/tmux/cmd-paste-buffer.c | |
parent | ad8189fb5b6fc3356176d1de4ace98c13dcf4f97 (diff) |
Add support for named buffers. If you don't name a buffer, things work
much as before - buffers are automatically named "buffer0000",
"buffer0001" and so on and ordered as a stack. Buffers can be named
explicitly when creating ("loadb -b foo" etc) or renamed ("setb -b
buffer0000 -n foo"). If buffers are named explicitly, they are not
deleted when buffer-limit is reached. Diff from J Raynor.
Diffstat (limited to 'usr.bin/tmux/cmd-paste-buffer.c')
-rw-r--r-- | usr.bin/tmux/cmd-paste-buffer.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/usr.bin/tmux/cmd-paste-buffer.c b/usr.bin/tmux/cmd-paste-buffer.c index fbb0790f8f8..088c9498441 100644 --- a/usr.bin/tmux/cmd-paste-buffer.c +++ b/usr.bin/tmux/cmd-paste-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-paste-buffer.c,v 1.24 2014/04/24 09:14:43 nicm Exp $ */ +/* $OpenBSD: cmd-paste-buffer.c,v 1.25 2014/05/13 07:34:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,7 +36,7 @@ void cmd_paste_buffer_filter(struct window_pane *, const struct cmd_entry cmd_paste_buffer_entry = { "paste-buffer", "pasteb", "db:prs:t:", 0, 0, - "[-dpr] [-s separator] [-b buffer-index] " CMD_TARGET_PANE_USAGE, + "[-dpr] [-s separator] " CMD_BUFFER_USAGE " " CMD_TARGET_PANE_USAGE, 0, NULL, cmd_paste_buffer_exec @@ -49,31 +49,22 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq) struct window_pane *wp; struct session *s; struct paste_buffer *pb; - const char *sepstr; - char *cause; - int buffer; + const char *sepstr, *bufname; int pflag; if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL) return (CMD_RETURN_ERROR); - if (!args_has(args, 'b')) - buffer = -1; - else { - buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause); - if (cause != NULL) { - cmdq_error(cmdq, "buffer %s", cause); - free(cause); - return (CMD_RETURN_ERROR); - } - } + bufname = NULL; + if (args_has(args, 'b')) + bufname = args_get(args, 'b'); - if (buffer == -1) + if (bufname == NULL) pb = paste_get_top(); else { - pb = paste_get_index(buffer); + pb = paste_get_name(bufname); if (pb == NULL) { - cmdq_error(cmdq, "no buffer %d", buffer); + cmdq_error(cmdq, "no buffer %s", bufname); return (CMD_RETURN_ERROR); } } @@ -92,10 +83,10 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq) /* Delete the buffer if -d. */ if (args_has(args, 'd')) { - if (buffer == -1) + if (bufname == NULL) paste_free_top(); else - paste_free_index(buffer); + paste_free_name(bufname); } return (CMD_RETURN_NORMAL); |