From 3dbacbb62b033c04185fb87da5b0622f0aafee86 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 13 May 2014 07:34:35 +0000 Subject: 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. --- cmd-choose-buffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cmd-choose-buffer.c') diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c index c6c70a0d..42caa7cd 100644 --- a/cmd-choose-buffer.c +++ b/cmd-choose-buffer.c @@ -75,19 +75,20 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq) action = xstrdup("paste-buffer -b '%%'"); idx = 0; - while ((pb = paste_walk_stack(&idx)) != NULL) { + pb = NULL; + while ((pb = paste_walk(pb)) != NULL) { cdata = window_choose_data_create(TREE_OTHER, c, c->session); - cdata->idx = idx - 1; + cdata->idx = idx; cdata->ft_template = xstrdup(template); - format_add(cdata->ft, "line", "%u", idx - 1); format_paste_buffer(cdata->ft, pb, utf8flag); - xasprintf(&action_data, "%u", idx - 1); + xasprintf(&action_data, "%s", pb->name); cdata->command = cmd_template_replace(action, action_data, 1); free(action_data); window_choose_add(wl->window->active, cdata); + idx++; } free(action); -- cgit