--- rxvt-unicode/src/rxvtperl.xs 2011/04/07 12:19:41 1.140 +++ rxvt-unicode/src/rxvtperl.xs 2011/07/01 19:07:08 1.142 @@ -343,7 +343,7 @@ "" "use urxvt;" }; - int argc = ARRAY_LENGTH(args); + int argc = ecb_array_length (args); char **argv = args; PERL_SYS_INIT3 (&argc, &argv, &environ); @@ -369,6 +369,7 @@ // runs outside of perls ENV term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); + hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); } } @@ -399,6 +400,16 @@ for (int i = 0; i <= AvFILL (av); i++) ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); } + else if (htype == HOOK_DESTROY) + { + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); + + for (int i = AvFILL (av); i >= 0; i--) + { + rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); + delete req; + } + } bool event_consumed; @@ -790,7 +801,7 @@ # endif }; - for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) + for (civ = const_iv + ecb_array_length (const_iv); civ-- > const_iv; ) newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); } @@ -878,6 +889,8 @@ CODE: rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); req->cb_sv = newSVsv (cb); + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); + av_push (av, newSViv ((IV)req)); RETVAL = (IV)req; OUTPUT: RETVAL @@ -886,6 +899,18 @@ _delete_selection_request (IV req_) CODE: rxvt_selection *req = (rxvt_selection *)req_; + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); + int i; + + for (i = AvFILL (av); i >= 0; i--) + if (SvIV (*av_fetch (av, i, 1)) == req_) + break; + + for (; i < AvFILL (av); i++) + av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); + + av_pop (av); + delete req; MODULE = urxvt PACKAGE = urxvt::term @@ -1483,7 +1508,7 @@ # undef reserve }; - rs = rslist + ARRAY_LENGTH(rslist); + rs = rslist + ecb_array_length (rslist); if (*name) {