… | |
… | |
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 | |
111 | struct perl_watcher |
111 | struct perl_watcher |
… | |
… | |
290 | void |
290 | void |
291 | overlay::show () |
291 | overlay::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 | |
299 | void |
299 | void |
300 | overlay::hide () |
300 | overlay::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 | |
605 | SV * |
606 | SV * |
… | |
… | |
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 | |
635 | void |
636 | void |
… | |
… | |
704 | |
705 | |
705 | MODULE = urxvt PACKAGE = urxvt::term |
706 | MODULE = urxvt PACKAGE = urxvt::term |
706 | |
707 | |
707 | void |
708 | void |
708 | rxvt_term::destroy () |
709 | rxvt_term::destroy () |
|
|
710 | |
|
|
711 | void |
|
|
712 | rxvt_term::grab_button (int button, U32 modifiers) |
|
|
713 | CODE: |
|
|
714 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
|
|
715 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
716 | GrabModeSync, GrabModeSync, None, None); |
|
|
717 | |
|
|
718 | bool |
|
|
719 | rxvt_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)) |
|
|
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; |
|
|
735 | } |
|
|
736 | OUTPUT: |
|
|
737 | RETVAL |
|
|
738 | |
|
|
739 | void |
|
|
740 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
|
|
741 | CODE: |
|
|
742 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
|
|
743 | |
|
|
744 | void |
|
|
745 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
|
|
746 | CODE: |
|
|
747 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
|
|
748 | |
|
|
749 | void |
|
|
750 | rxvt_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 | |
|
|
755 | void |
|
|
756 | rxvt_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); |
709 | |
761 | |
710 | int |
762 | int |
711 | rxvt_term::strwidth (SV *str) |
763 | rxvt_term::strwidth (SV *str) |
712 | CODE: |
764 | CODE: |
713 | { |
765 | { |
… | |
… | |
1098 | THIS->want_refresh = 1; |
1150 | THIS->want_refresh = 1; |
1099 | } |
1151 | } |
1100 | } |
1152 | } |
1101 | |
1153 | |
1102 | int |
1154 | int |
1103 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
1155 | rxvt_term::selection_grab (U32 eventtime) |
1104 | |
1156 | |
1105 | void |
1157 | void |
1106 | rxvt_term::selection (SV *newtext = 0) |
1158 | rxvt_term::selection (SV *newtext = 0) |
1107 | PPCODE: |
1159 | PPCODE: |
1108 | { |
1160 | { |
… | |
… | |
1146 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1198 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1147 | |
1199 | |
1148 | THIS->cmdbuf_ptr = str; |
1200 | THIS->cmdbuf_ptr = str; |
1149 | THIS->cmdbuf_endp = str + len; |
1201 | THIS->cmdbuf_endp = str + len; |
1150 | |
1202 | |
|
|
1203 | rxvt_push_locale (THIS->locale); |
1151 | THIS->cmd_parse (); |
1204 | THIS->cmd_parse (); |
|
|
1205 | rxvt_pop_locale (); |
1152 | |
1206 | |
1153 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1207 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1154 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1208 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1155 | } |
1209 | } |
1156 | |
1210 | |