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.34 by root, Fri Jan 6 21:06:09 2006 UTC vs.
Revision 1.37 by root, Sat Jan 7 20:23:52 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
583 583
584PROTOTYPES: ENABLE 584PROTOTYPES: ENABLE
585 585
586BOOT: 586BOOT:
587{ 587{
588 HV *stash = gv_stashpv ("urxvt", 1);
588# define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); 589# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name));
590
589 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 591 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
590# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 592# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
591# include "hookinc.h" 593# include "hookinc.h"
592# undef def 594# undef def
593 595
596
594 export_const (DEFAULT_RSTYLE); 597 export_const_iv (DEFAULT_RSTYLE);
595 export_const (OVERLAY_RSTYLE); 598 export_const_iv (OVERLAY_RSTYLE);
596 export_const (RS_Bold); 599 export_const_iv (RS_Bold);
597 export_const (RS_Italic); 600 export_const_iv (RS_Italic);
598 export_const (RS_Blink); 601 export_const_iv (RS_Blink);
599 export_const (RS_RVid); 602 export_const_iv (RS_RVid);
600 export_const (RS_Uline); 603 export_const_iv (RS_Uline);
604 export_const_iv (CurrentTime);
601 605
602 sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); 606 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
603} 607}
604 608
605SV * 609SV *
606new (...) 610new (...)
607 CODE: 611 CODE:
625 { 629 {
626 term->destroy (); 630 term->destroy ();
627 croak ("exception caught while initializing new terminal instance"); 631 croak ("exception caught while initializing new terminal instance");
628 } 632 }
629 633
630 RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; 634 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
631} 635}
632 OUTPUT: 636 OUTPUT:
633 RETVAL 637 RETVAL
634 638
635void 639void
704 708
705MODULE = urxvt PACKAGE = urxvt::term 709MODULE = urxvt PACKAGE = urxvt::term
706 710
707void 711void
708rxvt_term::destroy () 712rxvt_term::destroy ()
713
714void
715rxvt_term::grab_button (int button, U32 modifiers)
716 CODE:
717 XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
718 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
719 GrabModeSync, GrabModeSync, None, None);
720
721bool
722rxvt_term::grab (U32 eventtime, int sync = 0)
723 CODE:
724{
725 int mode = sync ? GrabModeSync : GrabModeAsync;
726
727 THIS->perl.grabtime = 0;
728
729 if (!XGrabPointer (THIS->display->display, THIS->vt, 0,
730 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
731 mode, mode, None, None, eventtime))
732 if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime))
733 THIS->perl.grabtime = eventtime;
734 else
735 XUngrabPointer (THIS->display->display, eventtime);
736
737 RETVAL = !!THIS->perl.grabtime;
738}
739 OUTPUT:
740 RETVAL
741
742void
743rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime)
744 CODE:
745 XAllowEvents (THIS->display->display, AsyncBoth, eventtime);
746
747void
748rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime)
749 CODE:
750 XAllowEvents (THIS->display->display, SyncBoth, eventtime);
751
752void
753rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime)
754 CODE:
755 XAllowEvents (THIS->display->display, ReplayPointer, eventtime);
756 XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime);
757
758void
759rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime)
760 CODE:
761 THIS->perl.grabtime = 0;
762 XUngrabKeyboard (THIS->display->display, eventtime);
763 XUngrabPointer (THIS->display->display, eventtime);
709 764
710int 765int
711rxvt_term::strwidth (SV *str) 766rxvt_term::strwidth (SV *str)
712 CODE: 767 CODE:
713{ 768{
1098 THIS->want_refresh = 1; 1153 THIS->want_refresh = 1;
1099 } 1154 }
1100} 1155}
1101 1156
1102int 1157int
1103rxvt_term::selection_grab (int eventtime = CurrentTime) 1158rxvt_term::selection_grab (U32 eventtime)
1104 1159
1105void 1160void
1106rxvt_term::selection (SV *newtext = 0) 1161rxvt_term::selection (SV *newtext = 0)
1107 PPCODE: 1162 PPCODE:
1108{ 1163{
1146 char *old_cmdbuf_endp = THIS->cmdbuf_endp; 1201 char *old_cmdbuf_endp = THIS->cmdbuf_endp;
1147 1202
1148 THIS->cmdbuf_ptr = str; 1203 THIS->cmdbuf_ptr = str;
1149 THIS->cmdbuf_endp = str + len; 1204 THIS->cmdbuf_endp = str + len;
1150 1205
1206 rxvt_push_locale (THIS->locale);
1151 THIS->cmd_parse (); 1207 THIS->cmd_parse ();
1208 rxvt_pop_locale ();
1152 1209
1153 THIS->cmdbuf_ptr = old_cmdbuf_ptr; 1210 THIS->cmdbuf_ptr = old_cmdbuf_ptr;
1154 THIS->cmdbuf_endp = old_cmdbuf_endp; 1211 THIS->cmdbuf_endp = old_cmdbuf_endp;
1155} 1212}
1156 1213

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines