=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window-copy.c,v retrieving revision 1.99 retrieving revision 1.100 diff -c -r1.99 -r1.100 *** src/usr.bin/tmux/window-copy.c 2014/01/22 13:57:49 1.99 --- src/usr.bin/tmux/window-copy.c 2014/01/22 22:32:15 1.100 *************** *** 1,4 **** ! /* $OpenBSD: window-copy.c,v 1.99 2014/01/22 13:57:49 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: window-copy.c,v 1.100 2014/01/22 22:32:15 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 750,757 **** { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; ! size_t inputlen; int np; switch (mode_key_lookup(&data->mdata, key, NULL)) { case MODEKEYEDIT_CANCEL: --- 750,759 ---- { struct window_copy_mode_data *data = wp->modedata; struct screen *s = &data->screen; ! size_t inputlen, n; int np; + struct paste_buffer *pb; + u_char ch; switch (mode_key_lookup(&data->mdata, key, NULL)) { case MODEKEYEDIT_CANCEL: *************** *** 765,770 **** --- 767,786 ---- case MODEKEYEDIT_DELETELINE: *data->inputstr = '\0'; break; + case MODEKEYEDIT_PASTE: + if ((pb = paste_get_top(&global_buffers)) == NULL) + break; + for (n = 0; n < pb->size; n++) { + ch = (u_char) pb->data[n]; + if (ch < 32 || ch == 127) + break; + } + inputlen = strlen(data->inputstr); + + data->inputstr = xrealloc(data->inputstr, 1, inputlen + n + 1); + memcpy(data->inputstr + inputlen, pb->data, n); + data->inputstr[inputlen + n] = '\0'; + break; case MODEKEYEDIT_ENTER: np = data->numprefix; if (np <= 0) *************** *** 1154,1161 **** struct screen *s = &data->screen; struct options *oo = &wp->window->options; struct grid_cell gc; ! char hdr[32]; ! size_t last, xoff = 0, size = 0; window_mode_attrs(&gc, oo); --- 1170,1177 ---- struct screen *s = &data->screen; struct options *oo = &wp->window->options; struct grid_cell gc; ! char hdr[512]; ! size_t last, xoff = 0, size = 0, limit; window_mode_attrs(&gc, oo); *************** *** 1168,1178 **** screen_write_cursormove(ctx, screen_size_x(s) - size, 0); screen_write_puts(ctx, &gc, "%s", hdr); } else if (py == last && data->inputtype != WINDOW_COPY_OFF) { if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) { ! xoff = size = xsnprintf(hdr, sizeof hdr, "Repeat: %u", data->numprefix); } else { ! xoff = size = xsnprintf(hdr, sizeof hdr, "%s: %s", data->inputprompt, data->inputstr); } screen_write_cursormove(ctx, 0, last); --- 1184,1197 ---- screen_write_cursormove(ctx, screen_size_x(s) - size, 0); screen_write_puts(ctx, &gc, "%s", hdr); } else if (py == last && data->inputtype != WINDOW_COPY_OFF) { + limit = sizeof hdr; + if (limit > screen_size_x(s)) + limit = screen_size_x(s); if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) { ! xoff = size = xsnprintf(hdr, limit, "Repeat: %u", data->numprefix); } else { ! xoff = size = xsnprintf(hdr, limit, "%s: %s", data->inputprompt, data->inputstr); } screen_write_cursormove(ctx, 0, last);