=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window-copy.c,v retrieving revision 1.107 retrieving revision 1.108 diff -c -r1.107 -r1.108 *** src/usr.bin/tmux/window-copy.c 2014/04/24 09:14:43 1.107 --- src/usr.bin/tmux/window-copy.c 2014/05/13 07:34:35 1.108 *************** *** 1,4 **** ! /* $OpenBSD: window-copy.c,v 1.107 2014/04/24 09:14:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: window-copy.c,v 1.108 2014/05/13 07:34:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 54,64 **** void window_copy_start_selection(struct window_pane *); int window_copy_update_selection(struct window_pane *, int); 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_pipe( ! struct window_pane *, struct session *, int, const char *); ! void window_copy_copy_selection(struct window_pane *, int); ! void window_copy_append_selection(struct window_pane *, int); void window_copy_clear_selection(struct window_pane *); void window_copy_copy_line( struct window_pane *, char **, size_t *, u_int, u_int, u_int); --- 54,65 ---- void window_copy_start_selection(struct window_pane *); int window_copy_update_selection(struct window_pane *, int); void *window_copy_get_selection(struct window_pane *, size_t *); ! void window_copy_copy_buffer(struct window_pane *, const char *, void *, ! size_t); ! void window_copy_copy_pipe(struct window_pane *, struct session *, ! const char *, const char *); ! 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_copy_line( struct window_pane *, char **, size_t *, u_int, u_int, u_int); *************** *** 417,423 **** switch (cmd) { case MODEKEYCOPY_APPENDSELECTION: if (sess != NULL) { ! window_copy_append_selection(wp, data->numprefix); window_pane_reset_mode(wp); return; } --- 418,424 ---- switch (cmd) { case MODEKEYCOPY_APPENDSELECTION: if (sess != NULL) { ! window_copy_append_selection(wp, NULL); window_pane_reset_mode(wp); return; } *************** *** 543,549 **** if (sess != NULL && (cmd == MODEKEYCOPY_COPYLINE || cmd == MODEKEYCOPY_COPYENDOFLINE)) { ! window_copy_copy_selection(wp, -1); window_pane_reset_mode(wp); return; } --- 544,550 ---- if (sess != NULL && (cmd == MODEKEYCOPY_COPYLINE || cmd == MODEKEYCOPY_COPYENDOFLINE)) { ! window_copy_copy_selection(wp, NULL); window_pane_reset_mode(wp); return; } *************** *** 554,567 **** break; case MODEKEYCOPY_COPYPIPE: if (sess != NULL) { ! window_copy_copy_pipe(wp, sess, data->numprefix, arg); window_pane_reset_mode(wp); return; } break; case MODEKEYCOPY_COPYSELECTION: if (sess != NULL) { ! window_copy_copy_selection(wp, data->numprefix); window_pane_reset_mode(wp); return; } --- 555,568 ---- break; case MODEKEYCOPY_COPYPIPE: if (sess != NULL) { ! window_copy_copy_pipe(wp, sess, NULL, arg); window_pane_reset_mode(wp); return; } break; case MODEKEYCOPY_COPYSELECTION: if (sess != NULL) { ! window_copy_copy_selection(wp, NULL); window_pane_reset_mode(wp); return; } *************** *** 918,924 **** s->mode &= ~MODE_MOUSE_BUTTON; s->mode |= MODE_MOUSE_STANDARD; if (sess != NULL) { ! window_copy_copy_selection(wp, -1); window_pane_reset_mode(wp); } } --- 919,925 ---- s->mode &= ~MODE_MOUSE_BUTTON; s->mode |= MODE_MOUSE_STANDARD; if (sess != NULL) { ! window_copy_copy_selection(wp, NULL); window_pane_reset_mode(wp); } } *************** *** 1452,1460 **** } void ! window_copy_copy_buffer(struct window_pane *wp, int idx, void *buf, size_t len) { - u_int limit; struct screen_write_ctx ctx; if (options_get_number(&global_options, "set-clipboard")) { --- 1453,1461 ---- } void ! window_copy_copy_buffer(struct window_pane *wp, const char *bufname, void *buf, ! size_t len) { struct screen_write_ctx ctx; if (options_get_number(&global_options, "set-clipboard")) { *************** *** 1463,1478 **** screen_write_stop(&ctx); } ! if (idx == -1) { ! limit = options_get_number(&global_options, "buffer-limit"); ! paste_add(buf, len, limit); ! } else if (paste_replace(idx, buf, len) != 0) free(buf); } void ! window_copy_copy_pipe( ! struct window_pane *wp, struct session *sess, int idx, const char *arg) { void *buf; size_t len; --- 1464,1476 ---- screen_write_stop(&ctx); } ! if (paste_set(buf, len, bufname, NULL) != 0) free(buf); } void ! window_copy_copy_pipe(struct window_pane *wp, struct session *sess, ! const char *bufname, const char *arg) { void *buf; size_t len; *************** *** 1486,1496 **** job = job_run(arg, sess, NULL, NULL, NULL); bufferevent_write(job->event, buf, len); ! window_copy_copy_buffer(wp, idx, buf, len); } void ! window_copy_copy_selection(struct window_pane *wp, int idx) { void* buf; size_t len; --- 1484,1494 ---- job = job_run(arg, sess, NULL, NULL, NULL); bufferevent_write(job->event, buf, len); ! window_copy_copy_buffer(wp, bufname, buf, len); } void ! window_copy_copy_selection(struct window_pane *wp, const char *bufname) { void* buf; size_t len; *************** *** 1499,1515 **** if (buf == NULL) return; ! window_copy_copy_buffer(wp, idx, buf, len); } void ! window_copy_append_selection(struct window_pane *wp, int idx) { ! char *buf; ! struct paste_buffer *pb; ! size_t len; ! u_int limit; ! struct screen_write_ctx ctx; buf = window_copy_get_selection(wp, &len); if (buf == NULL) --- 1497,1512 ---- if (buf == NULL) return; ! window_copy_copy_buffer(wp, bufname, buf, len); } void ! window_copy_append_selection(struct window_pane *wp, const char *bufname) { ! char *buf; ! struct paste_buffer *pb; ! size_t len; ! struct screen_write_ctx ctx; buf = window_copy_get_selection(wp, &len); if (buf == NULL) *************** *** 1521,1544 **** screen_write_stop(&ctx); } ! if (idx == -1) ! idx = 0; ! ! if (idx == 0 && paste_get_top() == NULL) { ! limit = options_get_number(&global_options, "buffer-limit"); ! paste_add(buf, len, limit); ! return; ! } ! ! pb = paste_get_index(idx); if (pb != NULL) { buf = xrealloc(buf, 1, len + pb->size); memmove(buf + pb->size, buf, len); memcpy(buf, pb->data, pb->size); len += pb->size; } ! ! if (paste_replace(idx, buf, len) != 0) free(buf); } --- 1518,1536 ---- screen_write_stop(&ctx); } ! if (bufname == NULL || *bufname == '\0') { ! pb = paste_get_top(); ! if (pb != NULL) ! bufname = pb->name; ! } else ! pb = paste_get_name(bufname); if (pb != NULL) { buf = xrealloc(buf, 1, len + pb->size); memmove(buf + pb->size, buf, len); memcpy(buf, pb->data, pb->size); len += pb->size; } ! if (paste_set(buf, len, bufname, NULL) != 0) free(buf); }