version 1.3, 2009/07/26 12:58:44 |
version 1.4, 2009/09/07 18:50:45 |
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
|
|
#include <sys/types.h> |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
|
#include <string.h> |
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
|
|
{ |
{ |
struct cmd_copy_buffer_data *data = self->data; |
struct cmd_copy_buffer_data *data = self->data; |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
|
struct paste_stack *dst_ps, *src_ps; |
|
u_char *pdata; |
struct session *dst_session, *src_session; |
struct session *dst_session, *src_session; |
u_int limit; |
u_int limit; |
|
|
if ((dst_session = cmd_find_session(ctx, data->dst_session)) == NULL || |
if ((dst_session = cmd_find_session(ctx, data->dst_session)) == NULL || |
(src_session = cmd_find_session(ctx, data->src_session)) == NULL) |
(src_session = cmd_find_session(ctx, data->src_session)) == NULL) |
return (-1); |
return (-1); |
|
dst_ps = &dst_session->buffers; |
|
src_ps = &src_session->buffers; |
|
|
if (data->src_idx == -1) { |
if (data->src_idx == -1) { |
if ((pb = paste_get_top(&src_session->buffers)) == NULL) { |
if ((pb = paste_get_top(src_ps)) == NULL) { |
ctx->error(ctx, "no buffers"); |
ctx->error(ctx, "no buffers"); |
return (-1); |
return (-1); |
} |
} |
} else { |
} else { |
if ((pb = paste_get_index(&src_session->buffers, |
if ((pb = paste_get_index(src_ps, data->src_idx)) == NULL) { |
data->src_idx)) == NULL) { |
|
ctx->error(ctx, "no buffer %d", data->src_idx); |
ctx->error(ctx, "no buffer %d", data->src_idx); |
return (-1); |
return (-1); |
} |
} |
} |
} |
|
|
limit = options_get_number(&dst_session->options, "buffer-limit"); |
limit = options_get_number(&dst_session->options, "buffer-limit"); |
if (data->dst_idx == -1) { |
|
paste_add(&dst_session->buffers, xstrdup(pb->data), limit); |
pdata = xmalloc(pb->size); |
return (0); |
memcpy(pdata, pb->data, pb->size); |
} |
|
if (paste_replace(&dst_session->buffers, data->dst_idx, |
if (data->dst_idx == -1) |
xstrdup(pb->data)) != 0) { |
paste_add(dst_ps, pdata, pb->size, limit); |
|
else if (paste_replace(dst_ps, data->dst_idx, pdata, pb->size) != 0) { |
ctx->error(ctx, "no buffer %d", data->dst_idx); |
ctx->error(ctx, "no buffer %d", data->dst_idx); |
|
xfree(pdata); |
return (-1); |
return (-1); |
} |
} |
|
|