diff options
author | nicm <nicm> | 2015-08-29 09:25:00 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-08-29 09:25:00 +0000 |
commit | b56958500036970023c7a53264331cd10a5bbed2 (patch) | |
tree | 4e919788d8f30a08c048d573449a79e03fc06cc1 /window-copy.c | |
parent | b9f0571780e7058a70a8cc3b6805b6f1a73061e0 (diff) |
Move struct paste_buffer out of tmux.h.
Diffstat (limited to 'window-copy.c')
-rw-r--r-- | window-copy.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/window-copy.c b/window-copy.c index 850b437a..460dd10b 100644 --- a/window-copy.c +++ b/window-copy.c @@ -782,7 +782,8 @@ window_copy_key_input(struct window_pane *wp, int key) { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; - size_t inputlen, n; + const char *bufdata; + size_t inputlen, n, bufsize; int np; struct paste_buffer *pb; u_char ch; @@ -800,17 +801,18 @@ window_copy_key_input(struct window_pane *wp, int key) *data->inputstr = '\0'; break; case MODEKEYEDIT_PASTE: - if ((pb = paste_get_top()) == NULL) + if ((pb = paste_get_top(NULL)) == NULL) break; - for (n = 0; n < pb->size; n++) { - ch = (u_char) pb->data[n]; + bufdata = paste_buffer_data(pb, &bufsize); + for (n = 0; n < bufsize; n++) { + ch = (u_char)bufdata[n]; if (ch < 32 || ch == 127) break; } inputlen = strlen(data->inputstr); data->inputstr = xrealloc(data->inputstr, inputlen + n + 1); - memcpy(data->inputstr + inputlen, pb->data, n); + memcpy(data->inputstr + inputlen, bufdata, n); data->inputstr[inputlen + n] = '\0'; break; case MODEKEYEDIT_ENTER: @@ -1491,7 +1493,8 @@ window_copy_append_selection(struct window_pane *wp, const char *bufname) { char *buf; struct paste_buffer *pb; - size_t len; + const char *bufdata; + size_t len, bufsize; struct screen_write_ctx ctx; buf = window_copy_get_selection(wp, &len); @@ -1504,17 +1507,16 @@ window_copy_append_selection(struct window_pane *wp, const char *bufname) screen_write_stop(&ctx); } - if (bufname == NULL || *bufname == '\0') { - pb = paste_get_top(); - if (pb != NULL) - bufname = pb->name; - } else + if (bufname == NULL || *bufname == '\0') + pb = paste_get_top(&bufname); + else pb = paste_get_name(bufname); if (pb != NULL) { - buf = xrealloc(buf, len + pb->size); - memmove(buf + pb->size, buf, len); - memcpy(buf, pb->data, pb->size); - len += pb->size; + bufdata = paste_buffer_data(pb, &bufsize); + buf = xrealloc(buf, len + bufsize); + memmove(buf + bufsize, buf, len); + memcpy(buf, bufdata, bufsize); + len += bufsize; } if (paste_set(buf, len, bufname, NULL) != 0) free(buf); |