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.332 by sf-exg, Mon Jan 18 10:05:55 2010 UTC vs.
Revision 1.333 by sf-exg, Sun Jan 24 21:53:13 2010 UTC

231 selection.text = NULL; 231 selection.text = NULL;
232 selection.len = 0; 232 selection.len = 0;
233 selection.op = SELECTION_CLEAR; 233 selection.op = SELECTION_CLEAR;
234 selection.screen = PRIMARY; 234 selection.screen = PRIMARY;
235 selection.clicks = 0; 235 selection.clicks = 0;
236 selection.clip_text = NULL;
237 selection.clip_len = 0;
236 } 238 }
237 else 239 else
238 { 240 {
239 /* 241 /*
240 * add or delete rows as appropriate 242 * add or delete rows as appropriate
2944/* 2946/*
2945 * Clear all selected text 2947 * Clear all selected text
2946 * EXT: SelectionClear 2948 * EXT: SelectionClear
2947 */ 2949 */
2948void 2950void
2949rxvt_term::selection_clear () NOTHROW 2951rxvt_term::selection_clear (bool clipboard) NOTHROW
2950{ 2952{
2953 if (!clipboard)
2954 {
2951 want_refresh = 1; 2955 want_refresh = 1;
2952 free (selection.text); 2956 free (selection.text);
2953 selection.text = NULL; 2957 selection.text = NULL;
2954 selection.len = 0; 2958 selection.len = 0;
2955 CLEAR_SELECTION (); 2959 CLEAR_SELECTION ();
2956 2960
2957 if (display->selection_owner == this) 2961 if (display->selection_owner == this)
2958 display->selection_owner = 0; 2962 display->selection_owner = 0;
2963 }
2964 else
2965 {
2966 free (selection.clip_text);
2967 selection.clip_text = NULL;
2968 selection.clip_len = 0;
2969
2970 if (display->clipboard_owner == this)
2971 display->clipboard_owner = 0;
2972 }
2973}
2974
2975void
2976rxvt_term::clipboard_copy (Time tm)
2977{
2978 if (selection.len > 0)
2979 {
2980 free (selection.clip_text);
2981 selection.clip_len = selection.len;
2982 selection.clip_text = (wchar_t *) malloc (sizeof (wchar_t) * selection.clip_len);
2983 memcpy (selection.clip_text, selection.text,
2984 sizeof (wchar_t) * selection.clip_len);
2985 selection_grab (tm, true);
2986 }
2959} 2987}
2960 2988
2961/* ------------------------------------------------------------------------- */ 2989/* ------------------------------------------------------------------------- */
2962/* 2990/*
2963 * Copy a selection into the cut buffer 2991 * Copy a selection into the cut buffer
3089 3117
3090 selection_grab (tm); 3118 selection_grab (tm);
3091} 3119}
3092 3120
3093bool 3121bool
3094rxvt_term::selection_grab (Time tm) NOTHROW 3122rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW
3095{ 3123{
3124 Atom sel;
3125
3126 if (!clipboard)
3127 {
3096 selection_time = tm; 3128 selection_time = tm;
3129 sel = XA_PRIMARY;
3130 }
3131 else
3132 {
3133 clipboard_time = tm;
3134 sel = xa[XA_CLIPBOARD];
3135 }
3097 3136
3098 XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); 3137 XSetSelectionOwner (dpy, sel, vt, tm);
3099 if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) 3138 if (XGetSelectionOwner (dpy, sel) == vt)
3100 { 3139 {
3101 display->set_selection_owner (this); 3140 display->set_selection_owner (this, clipboard);
3102 return true; 3141 return true;
3103 } 3142 }
3104 else 3143 else
3105 { 3144 {
3106 selection_clear (); 3145 selection_clear (clipboard);
3107 return false; 3146 return false;
3108 } 3147 }
3109 3148
3110#if 0 3149#if 0
3111 XTextProperty ct; 3150 XTextProperty ct;
3606 else if (rq.target == xa[XA_MULTIPLE]) 3645 else if (rq.target == xa[XA_MULTIPLE])
3607 { 3646 {
3608 /* TODO: Handle MULTIPLE */ 3647 /* TODO: Handle MULTIPLE */
3609 } 3648 }
3610#endif 3649#endif
3611 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3650 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == XA_PRIMARY && selection.text)
3612 { 3651 {
3613 XChangeProperty (dpy, rq.requestor, rq.property, rq.target, 3652 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3614 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3653 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3654 ev.property = rq.property;
3655 }
3656 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
3657 {
3658 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3659 32, PropModeReplace, (unsigned char *)&clipboard_time, 1);
3615 ev.property = rq.property; 3660 ev.property = rq.property;
3616 } 3661 }
3617 else if (rq.target == XA_STRING 3662 else if (rq.target == XA_STRING
3618 || rq.target == xa[XA_TEXT] 3663 || rq.target == xa[XA_TEXT]
3619 || rq.target == xa[XA_COMPOUND_TEXT] 3664 || rq.target == xa[XA_COMPOUND_TEXT]
3652 { 3697 {
3653 target = xa[XA_COMPOUND_TEXT]; 3698 target = xa[XA_COMPOUND_TEXT];
3654 style = enc_compound_text; 3699 style = enc_compound_text;
3655 } 3700 }
3656 3701
3657 if (selection.text) 3702 if (rq.selection == XA_PRIMARY && selection.text)
3658 { 3703 {
3659 cl = selection.text; 3704 cl = selection.text;
3660 selectlen = selection.len; 3705 selectlen = selection.len;
3706 }
3707 else if (rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
3708 {
3709 cl = selection.clip_text;
3710 selectlen = selection.clip_len;
3661 } 3711 }
3662 else 3712 else
3663 { 3713 {
3664 cl = L""; 3714 cl = L"";
3665 selectlen = 0; 3715 selectlen = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines