mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
paste_send_pane can be merged into cmd-paste-buffer.c now.
This commit is contained in:
parent
b569585000
commit
373ef850e0
@ -48,7 +48,9 @@ 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, *bufname;
|
||||
const char *sepstr, *bufname, *bufdata, *bufend, *line;
|
||||
size_t seplen, bufsize;
|
||||
int bracket = args_has(args, 'p');
|
||||
|
||||
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
|
||||
return (CMD_RETURN_ERROR);
|
||||
@ -67,7 +69,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
}
|
||||
}
|
||||
|
||||
if (pb != NULL) {
|
||||
if (pb != NULL && ~wp->flags & PANE_INPUTOFF) {
|
||||
sepstr = args_get(args, 's');
|
||||
if (sepstr == NULL) {
|
||||
if (args_has(args, 'r'))
|
||||
@ -75,10 +77,31 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
else
|
||||
sepstr = "\r";
|
||||
}
|
||||
paste_send_pane(pb, wp, sepstr, args_has(args, 'p'));
|
||||
seplen = strlen(sepstr);
|
||||
|
||||
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
|
||||
bufferevent_write(wp->event, "\033[200~", 6);
|
||||
|
||||
bufdata = paste_buffer_data(pb, &bufsize);
|
||||
bufend = bufdata + bufsize;
|
||||
|
||||
for (;;) {
|
||||
line = memchr(bufdata, '\n', bufend - bufdata);
|
||||
if (line == NULL)
|
||||
break;
|
||||
|
||||
bufferevent_write(wp->event, bufdata, line - bufdata);
|
||||
bufferevent_write(wp->event, sepstr, seplen);
|
||||
|
||||
bufdata = line + 1;
|
||||
}
|
||||
if (bufdata != bufend)
|
||||
bufferevent_write(wp->event, bufdata, bufend - bufdata);
|
||||
|
||||
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
|
||||
bufferevent_write(wp->event, "\033[201~", 6);
|
||||
}
|
||||
|
||||
/* Delete the buffer if -d. */
|
||||
if (args_has(args, 'd')) {
|
||||
if (bufname == NULL)
|
||||
paste_free_top();
|
||||
|
@ -57,8 +57,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
|
||||
struct client *c = cmdq->client;
|
||||
struct session *s;
|
||||
struct paste_buffer *pb;
|
||||
const char *path, *bufname, *bufdata;
|
||||
char *start, *end, *msg;
|
||||
const char *path, *bufname, *bufdata, *start, *end;
|
||||
char *msg;
|
||||
size_t size, used, msglen, bufsize;
|
||||
int cwd, fd;
|
||||
FILE *f;
|
||||
|
29
paste.c
29
paste.c
@ -319,32 +319,3 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag)
|
||||
strlcpy(buf + width, "...", 4);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
/* Paste into a window pane, filtering '\n' according to separator. */
|
||||
void
|
||||
paste_send_pane(struct paste_buffer *pb, struct window_pane *wp,
|
||||
const char *sep, int bracket)
|
||||
{
|
||||
const char *data = pb->data, *end = data + pb->size, *lf;
|
||||
size_t seplen;
|
||||
|
||||
if (wp->flags & PANE_INPUTOFF)
|
||||
return;
|
||||
|
||||
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
|
||||
bufferevent_write(wp->event, "\033[200~", 6);
|
||||
|
||||
seplen = strlen(sep);
|
||||
while ((lf = memchr(data, '\n', end - data)) != NULL) {
|
||||
if (lf != data)
|
||||
bufferevent_write(wp->event, data, lf - data);
|
||||
bufferevent_write(wp->event, sep, seplen);
|
||||
data = lf + 1;
|
||||
}
|
||||
|
||||
if (end != data)
|
||||
bufferevent_write(wp->event, data, end - data);
|
||||
|
||||
if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
|
||||
bufferevent_write(wp->event, "\033[201~", 6);
|
||||
}
|
||||
|
2
tmux.h
2
tmux.h
@ -1452,8 +1452,6 @@ void paste_add(char *, size_t);
|
||||
int paste_rename(const char *, const char *, char **);
|
||||
int paste_set(char *, size_t, const char *, char **);
|
||||
char *paste_make_sample(struct paste_buffer *, int);
|
||||
void paste_send_pane(struct paste_buffer *, struct window_pane *,
|
||||
const char *, int);
|
||||
|
||||
/* format.c */
|
||||
struct format_tree;
|
||||
|
Loading…
Reference in New Issue
Block a user