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

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.35 by root, Sat Jan 7 04:19:43 2006 UTC vs.
Revision 1.36 by root, Sat Jan 7 19:29:17 2006 UTC

101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); 101 croak ("perl code used %s object, but C++ object is already destroyed, caught", klass);
102 102
103 return (long)mg->mg_ptr; 103 return (long)mg->mg_ptr;
104} 104}
105 105
106#define newSVterm(term) SvREFCNT_inc ((SV *)term->self) 106#define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self)
107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") 107#define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term")
108 108
109///////////////////////////////////////////////////////////////////////////// 109/////////////////////////////////////////////////////////////////////////////
110 110
111struct perl_watcher 111struct perl_watcher
290void 290void
291overlay::show () 291overlay::show ()
292{ 292{
293 char key[33]; sprintf (key, "%32lx", (long)this); 293 char key[33]; sprintf (key, "%32lx", (long)this);
294 294
295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); 295 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0));
296 hv_store (hv, key, 32, newSViv ((long)this), 0); 296 hv_store (hv, key, 32, newSViv ((long)this), 0);
297} 297}
298 298
299void 299void
300overlay::hide () 300overlay::hide ()
301{ 301{
302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); 302 SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0);
303 303
304 if (ovs) 304 if (ovs)
305 { 305 {
306 char key[33]; sprintf (key, "%32lx", (long)this); 306 char key[33]; sprintf (key, "%32lx", (long)this);
307 307
415 if (!perl) 415 if (!perl)
416 return false; 416 return false;
417 417
418 if (htype == HOOK_INIT) // first hook ever called 418 if (htype == HOOK_INIT) // first hook ever called
419 { 419 {
420 term->self = (void *)newSVptr ((void *)term, "urxvt::term"); 420 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
421 hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); 421 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0);
422 } 422 }
423 else if (!term->self) 423 else if (!term->perl.self)
424 return false; // perl not initialized for this instance 424 return false; // perl not initialized for this instance
425 else if (htype == HOOK_DESTROY) 425 else if (htype == HOOK_DESTROY)
426 { 426 {
427 // handled later 427 // handled later
428 } 428 }
429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 429 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
430 { 430 {
431 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); 431 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
432 432
433 if (HvKEYS (hv)) 433 if (HvKEYS (hv))
434 { 434 {
435 hv_iterinit (hv); 435 hv_iterinit (hv);
436 436
562 if (SvTRUE (ERRSV)) 562 if (SvTRUE (ERRSV))
563 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); 563 rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV));
564 564
565 if (htype == HOOK_DESTROY) 565 if (htype == HOOK_DESTROY)
566 { 566 {
567 clearSVptr ((SV *)term->self); 567 clearSVptr ((SV *)term->perl.self);
568 SvREFCNT_dec ((SV *)term->self); 568 SvREFCNT_dec ((SV *)term->perl.self);
569 } 569 }
570 570
571 return count; 571 return count;
572 } 572 }
573 573
596 export_const (RS_Bold); 596 export_const (RS_Bold);
597 export_const (RS_Italic); 597 export_const (RS_Italic);
598 export_const (RS_Blink); 598 export_const (RS_Blink);
599 export_const (RS_RVid); 599 export_const (RS_RVid);
600 export_const (RS_Uline); 600 export_const (RS_Uline);
601 export_const (CurrentTime);
601 602
602 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 603 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR);
603} 604}
604 605
605SV * 606SV *
625 { 626 {
626 term->destroy (); 627 term->destroy ();
627 croak ("exception caught while initializing new terminal instance"); 628 croak ("exception caught while initializing new terminal instance");
628 } 629 }
629 630
630 RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; 631 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
631} 632}
632 OUTPUT: 633 OUTPUT:
633 RETVAL 634 RETVAL
634 635
635void 636void
706 707
707void 708void
708rxvt_term::destroy () 709rxvt_term::destroy ()
709 710
710void 711void
711rxvt_term::grab (int eventtime) 712rxvt_term::grab_button (int button, U32 modifiers)
712 CODE: 713 CODE:
713{ 714 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
714return;
715 XGrabPointer (THIS->display->display, THIS->vt, 0,
716 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 715 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
717 GrabModeAsync, GrabModeAsync, None, None, eventtime); 716 GrabModeSync, GrabModeSync, None, None);
717
718bool
719rxvt_term::grab (U32 eventtime, int sync = 0)
720 CODE:
721{
722 int mode = sync ? GrabModeSync : GrabModeAsync;
723
724 THIS->perl.grabtime = 0;
725
726 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
727 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
728 mode, mode, None, None, eventtime))
718 XGrabKeyboard (THIS->display->display, THIS->vt, 0, GrabModeAsync, GrabModeAsync, eventtime); 729 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
730 THIS->perl.grabtime = eventtime;
731 else
732 XUngrabPointer (THIS->display->display, eventtime);
733
734 RETVAL = !!THIS->perl.grabtime;
719} 735}
736 OUTPUT:
737 RETVAL
738
739void
740rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime)
741 CODE:
742 XAllowEvents (THIS->display->display, AsyncBoth, eventtime);
743
744void
745rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime)
746 CODE:
747 XAllowEvents (THIS->display->display, SyncBoth, eventtime);
748
749void
750rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime)
751 CODE:
752 XAllowEvents (THIS->display->display, ReplayPointer, eventtime);
753 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime);
754
755void
756rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime)
757 CODE:
758 THIS->perl.grabtime = 0;
759 XUngrabKeyboard (THIS->display->display, eventtime);
760 XUngrabPointer (THIS->display->display, eventtime);
720 761
721int 762int
722rxvt_term::strwidth (SV *str) 763rxvt_term::strwidth (SV *str)
723 CODE: 764 CODE:
724{ 765{
1109 THIS->want_refresh = 1; 1150 THIS->want_refresh = 1;
1110 } 1151 }
1111} 1152}
1112 1153
1113int 1154int
1114rxvt_term::selection_grab (int eventtime = CurrentTime) 1155rxvt_term::selection_grab (U32 eventtime)
1115 1156
1116void 1157void
1117rxvt_term::selection (SV *newtext = 0) 1158rxvt_term::selection (SV *newtext = 0)
1118 PPCODE: 1159 PPCODE:
1119{ 1160{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines