mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Add setb -a to append and a copy mode append command, from J Raynor with
minor changes.
This commit is contained in:
@ -58,6 +58,7 @@ 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);
|
||||
@ -414,6 +415,13 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
|
||||
|
||||
cmd = mode_key_lookup(&data->mdata, key, &arg);
|
||||
switch (cmd) {
|
||||
case MODEKEYCOPY_APPENDSELECTION:
|
||||
if (sess != NULL) {
|
||||
window_copy_append_selection(wp, data->numprefix);
|
||||
window_pane_reset_mode(wp);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case MODEKEYCOPY_CANCEL:
|
||||
window_pane_reset_mode(wp);
|
||||
return;
|
||||
@ -1491,6 +1499,46 @@ window_copy_copy_selection(struct window_pane *wp, int idx)
|
||||
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)
|
||||
return;
|
||||
|
||||
if (options_get_number(&global_options, "set-clipboard")) {
|
||||
screen_write_start(&ctx, wp, NULL);
|
||||
screen_write_setselection(&ctx, buf, len);
|
||||
screen_write_stop(&ctx);
|
||||
}
|
||||
|
||||
if (idx == -1)
|
||||
idx = 0;
|
||||
|
||||
if (idx == 0 && paste_get_top(&global_buffers) == NULL) {
|
||||
limit = options_get_number(&global_options, "buffer-limit");
|
||||
paste_add(&global_buffers, buf, len, limit);
|
||||
return;
|
||||
}
|
||||
|
||||
pb = paste_get_index(&global_buffers, 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(&global_buffers, idx, buf, len) != 0)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
window_copy_copy_line(struct window_pane *wp,
|
||||
char **buf, size_t *off, u_int sy, u_int sx, u_int ex)
|
||||
|
Reference in New Issue
Block a user