mirror of
https://github.com/tmux/tmux.git
synced 2025-03-25 15:28:49 +00:00
Create a new context when copying instead of using the input
context. The input context may not exist yet. Fixes crash when copying from config file errors.
This commit is contained in:
parent
d28a39d01d
commit
599dd2a560
@ -54,7 +54,8 @@ void window_copy_start_selection(struct window_pane *);
|
|||||||
int window_copy_update_selection(struct window_pane *);
|
int window_copy_update_selection(struct window_pane *);
|
||||||
void *window_copy_get_selection(struct window_pane *, size_t *);
|
void *window_copy_get_selection(struct window_pane *, size_t *);
|
||||||
void window_copy_copy_buffer(struct window_pane *, int, void *, size_t);
|
void window_copy_copy_buffer(struct window_pane *, int, void *, size_t);
|
||||||
void window_copy_copy_pipe(struct window_pane *, int, const char *);
|
void window_copy_copy_pipe(
|
||||||
|
struct window_pane *, struct session *, int, const char *);
|
||||||
void window_copy_copy_selection(struct window_pane *, int);
|
void window_copy_copy_selection(struct window_pane *, int);
|
||||||
void window_copy_clear_selection(struct window_pane *);
|
void window_copy_clear_selection(struct window_pane *);
|
||||||
void window_copy_copy_line(
|
void window_copy_copy_line(
|
||||||
@ -539,7 +540,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
|
|||||||
break;
|
break;
|
||||||
case MODEKEYCOPY_COPYPIPE:
|
case MODEKEYCOPY_COPYPIPE:
|
||||||
if (sess != NULL) {
|
if (sess != NULL) {
|
||||||
window_copy_copy_pipe(wp, data->numprefix, arg);
|
window_copy_copy_pipe(wp, sess, data->numprefix, arg);
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1384,10 +1385,14 @@ window_copy_get_selection(struct window_pane *wp, size_t *len)
|
|||||||
void
|
void
|
||||||
window_copy_copy_buffer(struct window_pane *wp, int idx, void *buf, size_t len)
|
window_copy_copy_buffer(struct window_pane *wp, int idx, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
u_int limit;
|
u_int limit;
|
||||||
|
struct screen_write_ctx ctx;
|
||||||
|
|
||||||
if (options_get_number(&global_options, "set-clipboard"))
|
if (options_get_number(&global_options, "set-clipboard")) {
|
||||||
screen_write_setselection(&wp->ictx.ctx, buf, len);
|
screen_write_start(&ctx, wp, NULL);
|
||||||
|
screen_write_setselection(&ctx, buf, len);
|
||||||
|
screen_write_stop(&ctx);
|
||||||
|
}
|
||||||
|
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
limit = options_get_number(&global_options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
@ -1397,21 +1402,20 @@ window_copy_copy_buffer(struct window_pane *wp, int idx, void *buf, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_copy_copy_pipe(struct window_pane *wp, int idx, const char *arg)
|
window_copy_copy_pipe(
|
||||||
|
struct window_pane *wp, struct session *sess, int idx, const char *arg)
|
||||||
{
|
{
|
||||||
void* buf;
|
void *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
FILE* f;
|
struct job *job;
|
||||||
|
|
||||||
|
|
||||||
buf = window_copy_get_selection(wp, &len);
|
buf = window_copy_get_selection(wp, &len);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
f = popen(arg, "w");
|
job = job_run(arg, sess, NULL, NULL, NULL);
|
||||||
if (f != NULL) {
|
bufferevent_write(job->event, buf, len);
|
||||||
fwrite(buf, 1, len, f);
|
|
||||||
pclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
window_copy_copy_buffer(wp, idx, buf, len);
|
window_copy_copy_buffer(wp, idx, buf, len);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user