version 1.50, 2020/04/13 20:51:57 |
version 1.51, 2020/07/21 05:24:33 |
|
|
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item) |
cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item) |
{ |
{ |
struct args *args = cmd_get_args(self); |
struct args *args = cmd_get_args(self); |
|
struct client *c = cmdq_get_client(item); |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
int flags; |
int flags; |
const char *bufname = args_get(args, 'b'), *bufdata; |
const char *bufname = args_get(args, 'b'), *bufdata; |
size_t bufsize; |
size_t bufsize; |
char *path; |
char *path, *tmp; |
|
|
if (bufname == NULL) { |
if (bufname == NULL) { |
if ((pb = paste_get_top(NULL)) == NULL) { |
if ((pb = paste_get_top(NULL)) == NULL) { |
|
|
} |
} |
bufdata = paste_buffer_data(pb, &bufsize); |
bufdata = paste_buffer_data(pb, &bufsize); |
|
|
if (cmd_get_entry(self) == &cmd_show_buffer_entry) |
if (cmd_get_entry(self) == &cmd_show_buffer_entry) { |
|
if (c->session != NULL || (c->flags & CLIENT_CONTROL)) { |
|
utf8_stravisx(&tmp, bufdata, bufsize, |
|
VIS_OCTAL|VIS_CSTYLE|VIS_TAB); |
|
cmdq_print(item, "%s", tmp); |
|
free(tmp); |
|
return (CMD_RETURN_NORMAL); |
|
} |
path = xstrdup("-"); |
path = xstrdup("-"); |
else |
} else |
path = format_single_from_target(item, args->argv[0]); |
path = format_single_from_target(item, args->argv[0]); |
if (args_has(args, 'a')) |
if (args_has(args, 'a')) |
flags = O_APPEND; |
flags = O_APPEND; |