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.330 by root, Tue Dec 29 04:18:10 2009 UTC vs.
Revision 1.335 by root, Tue Mar 30 23:00:35 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
544 want_refresh = 1; 546 want_refresh = 1;
545 view_start = 0; 547 view_start = 0;
546 548
547 selection_check (2); /* check for boundary cross */ 549 selection_check (2); /* check for boundary cross */
548 550
549 int i = current_screen; current_screen = scrn; scrn = i; 551 current_screen = scrn;
550 552
551#if NSCREENS 553#if NSCREENS
552 if (option (Opt_secondaryScreen)) 554 if (option (Opt_secondaryScreen))
553 { 555 {
554 num_scr = 0; 556 num_scr = 0;
1832 for (i = PART_BEG; i < RC_COUNT; i++) 1834 for (i = PART_BEG; i < RC_COUNT; i++)
1833 { 1835 {
1834 min_it (rc[i].col, ncol - 1); 1836 min_it (rc[i].col, ncol - 1);
1835 min_it (rc[i].row, nrow - 1); 1837 min_it (rc[i].row, nrow - 1);
1836 } 1838 }
1837// TODO: this line somehow causes segfault if scr_expose() is called just after resize 1839
1838 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1840 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1839 fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); 1841 fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1840 1842
1841 num_scr_allow = 0; 1843 num_scr_allow = 0;
1842 1844
1933 1935
1934 bell_ev.start (VISUAL_BELL_DURATION); 1936 bell_ev.start (VISUAL_BELL_DURATION);
1935 } 1937 }
1936 else 1938 else
1937 XBell (dpy, 0); 1939 XBell (dpy, 0);
1940 HOOK_INVOKE ((this, HOOK_BELL, DT_END));
1938#endif 1941#endif
1939} 1942}
1940 1943
1941/* ------------------------------------------------------------------------- */ 1944/* ------------------------------------------------------------------------- */
1942/* ARGSUSED */ 1945/* ARGSUSED */
2374 } 2377 }
2375 2378
2376 /* 2379 /*
2377 * Actually do the drawing of the string here 2380 * Actually do the drawing of the string here
2378 */ 2381 */
2379 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; 2382 rxvt_font *font = fontset [GET_STYLE (rend)]->get (*text, GET_FONT (rend));
2380 2383
2381 if (expect_true (have_bg && back == Color_bg)) 2384 if (expect_true (have_bg && back == Color_bg))
2382 { 2385 {
2383 // this is very ugly, maybe push it into ->draw? 2386 // this is very ugly, maybe push it into ->draw?
2384 2387
2943/* 2946/*
2944 * Clear all selected text 2947 * Clear all selected text
2945 * EXT: SelectionClear 2948 * EXT: SelectionClear
2946 */ 2949 */
2947void 2950void
2948rxvt_term::selection_clear () NOTHROW 2951rxvt_term::selection_clear (bool clipboard) NOTHROW
2949{ 2952{
2953 if (!clipboard)
2954 {
2950 want_refresh = 1; 2955 want_refresh = 1;
2951 free (selection.text); 2956 free (selection.text);
2952 selection.text = NULL; 2957 selection.text = NULL;
2953 selection.len = 0; 2958 selection.len = 0;
2954 CLEAR_SELECTION (); 2959 CLEAR_SELECTION ();
2955 2960
2956 if (display->selection_owner == this) 2961 if (display->selection_owner == this)
2957 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 }
2958} 2987}
2959 2988
2960/* ------------------------------------------------------------------------- */ 2989/* ------------------------------------------------------------------------- */
2961/* 2990/*
2962 * Copy a selection into the cut buffer 2991 * Copy a selection into the cut buffer
3088 3117
3089 selection_grab (tm); 3118 selection_grab (tm);
3090} 3119}
3091 3120
3092bool 3121bool
3093rxvt_term::selection_grab (Time tm) NOTHROW 3122rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW
3094{ 3123{
3124 Atom sel;
3125
3126 if (!clipboard)
3127 {
3095 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 }
3096 3136
3097 XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); 3137 XSetSelectionOwner (dpy, sel, vt, tm);
3098 if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) 3138 if (XGetSelectionOwner (dpy, sel) == vt)
3099 { 3139 {
3100 display->set_selection_owner (this); 3140 display->set_selection_owner (this, clipboard);
3101 return true; 3141 return true;
3102 } 3142 }
3103 else 3143 else
3104 { 3144 {
3105 selection_clear (); 3145 selection_clear (clipboard);
3106 return false; 3146 return false;
3107 } 3147 }
3108 3148
3109#if 0 3149#if 0
3110 XTextProperty ct; 3150 XTextProperty ct;
3605 else if (rq.target == xa[XA_MULTIPLE]) 3645 else if (rq.target == xa[XA_MULTIPLE])
3606 { 3646 {
3607 /* TODO: Handle MULTIPLE */ 3647 /* TODO: Handle MULTIPLE */
3608 } 3648 }
3609#endif 3649#endif
3610 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3650 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == XA_PRIMARY && selection.text)
3611 { 3651 {
3612 XChangeProperty (dpy, rq.requestor, rq.property, rq.target, 3652 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3613 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);
3614 ev.property = rq.property; 3660 ev.property = rq.property;
3615 } 3661 }
3616 else if (rq.target == XA_STRING 3662 else if (rq.target == XA_STRING
3617 || rq.target == xa[XA_TEXT] 3663 || rq.target == xa[XA_TEXT]
3618 || rq.target == xa[XA_COMPOUND_TEXT] 3664 || rq.target == xa[XA_COMPOUND_TEXT]
3651 { 3697 {
3652 target = xa[XA_COMPOUND_TEXT]; 3698 target = xa[XA_COMPOUND_TEXT];
3653 style = enc_compound_text; 3699 style = enc_compound_text;
3654 } 3700 }
3655 3701
3656 if (selection.text) 3702 if (rq.selection == XA_PRIMARY && selection.text)
3657 { 3703 {
3658 cl = selection.text; 3704 cl = selection.text;
3659 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;
3660 } 3711 }
3661 else 3712 else
3662 { 3713 {
3663 cl = L""; 3714 cl = L"";
3664 selectlen = 0; 3715 selectlen = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines