1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include <sys/types.h>
- #include <stdlib.h>
- #include <string.h>
- #include "tmux.h"
- #define LIST_BUFFERS_TEMPLATE \
- "#{buffer_name}: #{buffer_size} bytes: \"#{buffer_sample}\""
- enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_q *);
- const struct cmd_entry cmd_list_buffers_entry = {
- .name = "list-buffers",
- .alias = "lsb",
- .args = { "F:", 0, 0 },
- .usage = "[-F format]",
- .flags = 0,
- .exec = cmd_list_buffers_exec
- };
- enum cmd_retval
- cmd_list_buffers_exec(struct cmd *self, struct cmd_q *cmdq)
- {
- struct args *args = self->args;
- struct paste_buffer *pb;
- struct format_tree *ft;
- char *line;
- const char *template;
- if ((template = args_get(args, 'F')) == NULL)
- template = LIST_BUFFERS_TEMPLATE;
- pb = NULL;
- while ((pb = paste_walk(pb)) != NULL) {
- ft = format_create(cmdq, 0);
- format_defaults_paste_buffer(ft, pb);
- line = format_expand(ft, template);
- cmdq_print(cmdq, "%s", line);
- free(line);
- format_free(ft);
- }
- return (CMD_RETURN_NORMAL);
- }
|