version 1.107, 2014/04/24 09:14:43 |
version 1.108, 2014/05/13 07:34:35 |
|
|
void window_copy_start_selection(struct window_pane *); |
void window_copy_start_selection(struct window_pane *); |
int window_copy_update_selection(struct window_pane *, int); |
int window_copy_update_selection(struct window_pane *, int); |
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 *, const char *, void *, |
void window_copy_copy_pipe( |
size_t); |
struct window_pane *, struct session *, int, const char *); |
void window_copy_copy_pipe(struct window_pane *, struct session *, |
void window_copy_copy_selection(struct window_pane *, int); |
const char *, const char *); |
void window_copy_append_selection(struct window_pane *, int); |
void window_copy_copy_selection(struct window_pane *, const char *); |
|
void window_copy_append_selection(struct window_pane *, const char *); |
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( |
struct window_pane *, char **, size_t *, u_int, u_int, u_int); |
struct window_pane *, char **, size_t *, u_int, u_int, u_int); |
|
|
switch (cmd) { |
switch (cmd) { |
case MODEKEYCOPY_APPENDSELECTION: |
case MODEKEYCOPY_APPENDSELECTION: |
if (sess != NULL) { |
if (sess != NULL) { |
window_copy_append_selection(wp, data->numprefix); |
window_copy_append_selection(wp, NULL); |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
return; |
return; |
} |
} |
|
|
if (sess != NULL && |
if (sess != NULL && |
(cmd == MODEKEYCOPY_COPYLINE || |
(cmd == MODEKEYCOPY_COPYLINE || |
cmd == MODEKEYCOPY_COPYENDOFLINE)) { |
cmd == MODEKEYCOPY_COPYENDOFLINE)) { |
window_copy_copy_selection(wp, -1); |
window_copy_copy_selection(wp, NULL); |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
return; |
return; |
} |
} |
|
|
break; |
break; |
case MODEKEYCOPY_COPYPIPE: |
case MODEKEYCOPY_COPYPIPE: |
if (sess != NULL) { |
if (sess != NULL) { |
window_copy_copy_pipe(wp, sess, data->numprefix, arg); |
window_copy_copy_pipe(wp, sess, NULL, arg); |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
return; |
return; |
} |
} |
break; |
break; |
case MODEKEYCOPY_COPYSELECTION: |
case MODEKEYCOPY_COPYSELECTION: |
if (sess != NULL) { |
if (sess != NULL) { |
window_copy_copy_selection(wp, data->numprefix); |
window_copy_copy_selection(wp, NULL); |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
return; |
return; |
} |
} |
|
|
s->mode &= ~MODE_MOUSE_BUTTON; |
s->mode &= ~MODE_MOUSE_BUTTON; |
s->mode |= MODE_MOUSE_STANDARD; |
s->mode |= MODE_MOUSE_STANDARD; |
if (sess != NULL) { |
if (sess != NULL) { |
window_copy_copy_selection(wp, -1); |
window_copy_copy_selection(wp, NULL); |
window_pane_reset_mode(wp); |
window_pane_reset_mode(wp); |
} |
} |
} |
} |
|
|
} |
} |
|
|
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, const char *bufname, void *buf, |
|
size_t len) |
{ |
{ |
u_int limit; |
|
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
if (options_get_number(&global_options, "set-clipboard")) { |
if (options_get_number(&global_options, "set-clipboard")) { |
|
|
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
if (idx == -1) { |
if (paste_set(buf, len, bufname, NULL) != 0) |
limit = options_get_number(&global_options, "buffer-limit"); |
|
paste_add(buf, len, limit); |
|
} else if (paste_replace(idx, buf, len) != 0) |
|
free(buf); |
free(buf); |
} |
} |
|
|
void |
void |
window_copy_copy_pipe( |
window_copy_copy_pipe(struct window_pane *wp, struct session *sess, |
struct window_pane *wp, struct session *sess, int idx, const char *arg) |
const char *bufname, const char *arg) |
{ |
{ |
void *buf; |
void *buf; |
size_t len; |
size_t len; |
|
|
job = job_run(arg, sess, NULL, NULL, NULL); |
job = job_run(arg, sess, NULL, NULL, NULL); |
bufferevent_write(job->event, buf, len); |
bufferevent_write(job->event, buf, len); |
|
|
window_copy_copy_buffer(wp, idx, buf, len); |
window_copy_copy_buffer(wp, bufname, buf, len); |
} |
} |
|
|
void |
void |
window_copy_copy_selection(struct window_pane *wp, int idx) |
window_copy_copy_selection(struct window_pane *wp, const char *bufname) |
{ |
{ |
void* buf; |
void* buf; |
size_t len; |
size_t len; |
|
|
if (buf == NULL) |
if (buf == NULL) |
return; |
return; |
|
|
window_copy_copy_buffer(wp, idx, buf, len); |
window_copy_copy_buffer(wp, bufname, buf, len); |
} |
} |
|
|
void |
void |
window_copy_append_selection(struct window_pane *wp, int idx) |
window_copy_append_selection(struct window_pane *wp, const char *bufname) |
{ |
{ |
char *buf; |
char *buf; |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
size_t len; |
size_t len; |
u_int limit; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
|
buf = window_copy_get_selection(wp, &len); |
buf = window_copy_get_selection(wp, &len); |
if (buf == NULL) |
if (buf == NULL) |
|
|
screen_write_stop(&ctx); |
screen_write_stop(&ctx); |
} |
} |
|
|
if (idx == -1) |
if (bufname == NULL || *bufname == '\0') { |
idx = 0; |
pb = paste_get_top(); |
|
if (pb != NULL) |
if (idx == 0 && paste_get_top() == NULL) { |
bufname = pb->name; |
limit = options_get_number(&global_options, "buffer-limit"); |
} else |
paste_add(buf, len, limit); |
pb = paste_get_name(bufname); |
return; |
|
} |
|
|
|
pb = paste_get_index(idx); |
|
if (pb != NULL) { |
if (pb != NULL) { |
buf = xrealloc(buf, 1, len + pb->size); |
buf = xrealloc(buf, 1, len + pb->size); |
memmove(buf + pb->size, buf, len); |
memmove(buf + pb->size, buf, len); |
memcpy(buf, pb->data, pb->size); |
memcpy(buf, pb->data, pb->size); |
len += pb->size; |
len += pb->size; |
} |
} |
|
if (paste_set(buf, len, bufname, NULL) != 0) |
if (paste_replace(idx, buf, len) != 0) |
|
free(buf); |
free(buf); |
} |
} |
|
|