ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.148 by root, Mon Dec 13 01:29:03 2004 UTC vs.
Revision 1.150 by root, Mon Dec 13 19:16:36 2004 UTC

2656/* ------------------------------------------------------------------------- */ 2656/* ------------------------------------------------------------------------- */
2657/* 2657/*
2658 * Paste a selection direct to the command fd 2658 * Paste a selection direct to the command fd
2659 */ 2659 */
2660void 2660void
2661rxvt_term::paste (const unsigned char *data, unsigned int len) 2661rxvt_term::paste (unsigned char *data, unsigned int len)
2662{ 2662{
2663 unsigned int i, j, n;
2664 unsigned char *ds = (unsigned char *)rxvt_malloc (PASTE_SIZE);
2665
2666 /* convert normal newline chars into common keyboard Return key sequence */ 2663 /* convert normal newline chars into common keyboard Return key sequence */
2667 for (i = 0; i < len; i += PASTE_SIZE) 2664 for (unsigned int i = 0; i < len; i++)
2668 {
2669 n = min (len - i, PASTE_SIZE);
2670 memcpy (ds, data + i, n);
2671
2672 for (j = 0; j < n; j++)
2673 if (ds[j] == C0_LF) 2665 if (data[i] == C0_LF)
2674 ds[j] = C0_CR; 2666 data[i] = C0_CR;
2675 2667
2676 tt_write (ds, (int)n); 2668 tt_write (data, len);
2677 }
2678
2679 free (ds);
2680} 2669}
2681 2670
2682/* ------------------------------------------------------------------------- */ 2671/* ------------------------------------------------------------------------- */
2683/* 2672/*
2684 * Respond to a notification that a primary selection has been sent 2673 * Respond to a notification that a primary selection has been sent
2714 2703
2715 unsigned long bytes_after; 2704 unsigned long bytes_after;
2716 XTextProperty ct; 2705 XTextProperty ct;
2717 2706
2718 if (XGetWindowProperty (display->display, win, prop, 2707 if (XGetWindowProperty (display->display, win, prop,
2719 0, (long)(PROP_SIZE / 4), 2708 0, PROP_SIZE / 4,
2720 delete_prop, AnyPropertyType, 2709 delete_prop, AnyPropertyType,
2721 &ct.encoding, &ct.format, 2710 &ct.encoding, &ct.format,
2722 &ct.nitems, &bytes_after, 2711 &ct.nitems, &bytes_after,
2723 &ct.value) != Success) 2712 &ct.value) != Success)
2724 { 2713 {
2731 2720
2732 if (bytes_after) 2721 if (bytes_after)
2733 { 2722 {
2734 // fetch and append remaining data 2723 // fetch and append remaining data
2735 XTextProperty ct2; 2724 XTextProperty ct2;
2736 unsigned long bytes_after2;
2737 2725
2738 if (XGetWindowProperty (display->display, win, prop, 2726 if (XGetWindowProperty (display->display, win, prop,
2739 ct.nitems / 4, (long) (bytes_after + 3) / 4, 2727 ct.nitems / 4, (bytes_after + 3) / 4,
2740 delete_prop, AnyPropertyType, 2728 delete_prop, AnyPropertyType,
2741 &ct2.encoding, &ct2.format, 2729 &ct2.encoding, &ct2.format,
2742 &ct2.nitems, &bytes_after2, 2730 &ct2.nitems, &bytes_after,
2743 &ct2.value) != Success) 2731 &ct2.value) != Success)
2744 goto bailout; 2732 goto bailout;
2745 2733
2746 // realloc should be compatible to XFree, here, and elsewhere, too 2734 // realloc should be compatible to XFree, here, and elsewhere, too
2747 ct.value = (unsigned char *)realloc (ct.value, ct.nitems + bytes_after); 2735 ct.value = (unsigned char *)realloc (ct.value, ct.nitems + ct2.nitems + 1);
2748 memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems); 2736 memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems + 1);
2749 ct.nitems += ct2.nitems; 2737 ct.nitems += ct2.nitems;
2750 2738
2751 XFree (ct2.value); 2739 XFree (ct2.value);
2752 } 2740 }
2753 else if (delete_prop)
2754 XDeleteProperty (display->display, win, prop);
2755 2741
2756 if (ct.value == 0) 2742 if (ct.value == 0)
2757 goto bailout; 2743 goto bailout;
2758 2744
2759 if (ct.encoding == xa[XA_INCR]) 2745 if (ct.encoding == xa[XA_INCR])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines